Profiling can also be enabled and configured through the use of registry settings on Microsoft® Windows® 95 and Microsoft® Windows NT®. The registry settings that affect the Microsoft VM when used with the profiler interfaces are located under the keys
HKEY_CURRENT_USER\Software\Microsoft\Java VM
HKEY_LOCAL_MACHINE\Software\Microsoft\Java VM
Note the space between Java and VM.
In the HKEY_CURRENT_USER\Software\Microsoft\Java VM key, you may enter the following values:
EnableEventMonitors
Set this value to a DWORD that indicates whether event monitors (profiling) is enabled. A non-zero value enables event monitors, while a value of zero disables this feature. The default value for this option is disabled if this registry value and the associated environment variable are not set.
EnableFI
Set this value to a DWORD that indicates whether the x86 fast interpreter loop is enabled. A non-zero value enables the fast interpreter, while a value of 0 (zero) disables this feature. The default value for this option is enabled if this registry value and the associated environment variable are not set.
EnableJIT
Set this value to a DWORD that indicates whether the JIT compiler is enabled. A non-zero value enables the JIT compiler, while a value of zero disables this feature. The default value for this option is enabled if this registry value and the associated environment variable are not set.
In the HKEY_LOCAL_MACHINE\Software\Microsoft\Java VM key, you may enter the following value:
DebuggingFlags
Set this value to a DWORD bitmask of flags indicating the state of the various debug options. One of the bit flags in this DWORD, MSJDBG_FL_ENABLE_PROFILING (0x02), enables event monitors when it is set before the Microsoft VM begins execution.
These registry entries are not created by default when you install the Microsoft VM. Set registry settings with code like the following.
const char s_cszJavaVMKey[] = "Software\\Microsoft\\Java VM"; const char s_cszProfilerValue[] = "EnableEventMonitors"; // Create the Microsoft VM profiler (event monitor) value. // Return TRUE on success; FALSE on failure. BOOL CreateEventMonitorValue(void) { BOOL bResult = FALSE; DWORD dwDisposition; HKEY hkeyJavaVM; if (RegCreateKeyEx(HKEY_CURRENT_USER, s_cszJavaVMKey, 0, NULL, 0, KEY_SET_VALUE, NULL, &hkeyJavaVM, &dwDisposition) == ERROR_SUCCESS) { DWORD dwEnableEventMonitorsValue = 1; if (RegSetValueEx(hkeyJavaVM, s_cszProfilerValue, 0, REG_DWORD, (CONST BYTE *)&dwEnableEventMonitorsValue, sizeof(dwEnableEventMonitorsValue)) == ERROR_SUCCESS) bResult = TRUE; RegCloseKey(hkeyJavaVM); } return(bResult); }
CAUTION These settings affect all Java applications and applets started under the Microsoft VM. Enabling the event monitors will affect all Java applications by forcing more resources to be used and requiring the Microsoft VM to execute code to handle event monitors.
You can remove or modify registry entries with the Regedit.exe utility that is included with Windows 95 and Windows NT.
You can also remove registry settings using code similar to the following example.
// Delete the Microsoft VM profiler (event monitor) value. // Return TRUE on success; FALSE on failure. BOOL DeleteEventMonitorValue(void) { BOOL bResult = FALSE; HKEY hkeyJavaVM; if (RegOpenKeyEx(HKEY_CURRENT_USER, s_cszJavaVMKey, 0, KEY_SET_VALUE, &hkeyJavaVM) == ERROR_SUCCESS) { if (RegDeleteValue(hkeyJavaVM, s_cszProfilerValue) == ERROR_SUCCESS) bResult = TRUE; RegCloseKey(hkeyJavaVM); } return(bResult); }