Skip to content

Commit

Permalink
Merge pull request eclipse-openj9#18582 from pshipton/compiler
Browse files Browse the repository at this point in the history
The java.compiler system property is obsolete in jdk21+
  • Loading branch information
keithc-ca committed Dec 8, 2023
2 parents 21f742f + f88cf9e commit bb24cfb
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ public static CompilationMXBeanImpl getInstance() {
*/
@Override
public String getName() {
return com.ibm.oti.vm.VM.getVMLangAccess().internalGetProperties().getProperty("java.compiler"); //$NON-NLS-1$
return com.ibm.oti.vm.VM.getVMLangAccess().internalGetProperties().
/*[IF JAVA_SPEC_VERSION < 21]*/
getProperty("java.compiler"); //$NON-NLS-1$
/*[ELSE] JAVA_SPEC_VERSION < 21 */
getProperty("openj9.compiler"); //$NON-NLS-1$
/*[ENDIF] JAVA_SPEC_VERSION < 21*/
}

/**
Expand Down
2 changes: 1 addition & 1 deletion runtime/include/vmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ GetInitArgs(VMInterface* vmi);
<BR>OpenJ9 - 1ca0ab98
<BR>OMR - 05d2b8a2
<BR>JCL - c2aa0348 based on jdk8u172-b11"</TD></TR>
* <TR><TD>java.compiler</TD> <TD>"j9jit29"</TD></TR>
* <TR><TD>java.compiler</TD> <TD>"j9jit29" - not supported from jdk21</TD></TR>
* <TR><TD>java.class.version</TD> <TD>"52.0"</TD></TR>
* <TR><TD>java.home</TD> <TD>the absolute path of the parent directory of the directory containing the vm
<BR>i.e. for a vm /clear/bin/vm.exe, java.home is /clear</TD></TR>
Expand Down
12 changes: 12 additions & 0 deletions runtime/jcl/common/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "jclprots.h"

#include "ut_j9jcl.h"
#include "j9jclnls.h"

#if defined(J9ZOS390)
#include "atoe.h"
Expand Down Expand Up @@ -551,6 +552,17 @@ systemPropertyIterator(char* key, char* value, void* userData)
return;
}

#if JAVA_SPEC_VERSION >= 21
if (0 == strcmp("java.compiler", key)) {
PORT_ACCESS_FROM_ENV(env);
if ((0 == strcmp("jitc", value)) || (0 == strcmp(J9_JIT_DLL_NAME, value))) {
j9nls_printf(PORTLIB, J9NLS_WARNING, J9NLS_JCL_JAVA_COMPILER_WARNING_XJIT);
} else {
j9nls_printf(PORTLIB, J9NLS_WARNING, J9NLS_JCL_JAVA_COMPILER_WARNING_XINT);
}
return;
}
#endif /* JAVA_SPEC_VERSION >= 21 */

/* check for overridden system properties, use linear scan for now */
for (i=0; i < defaultCount; i+=2) {
Expand Down
18 changes: 18 additions & 0 deletions runtime/nls/j9cl/j9jcl.nls
Original file line number Diff line number Diff line change
Expand Up @@ -588,3 +588,21 @@ J9NLS_JCL_CRIU_FAILED_TO_ENABLE_ALL_RESTORE_OPTIONS.explanation=NOTAG
J9NLS_JCL_CRIU_FAILED_TO_ENABLE_ALL_RESTORE_OPTIONS.system_action=
J9NLS_JCL_CRIU_FAILED_TO_ENABLE_ALL_RESTORE_OPTIONS.user_response=
# END NON-TRANSLATABLE

# Note: "java.compiler" is a system property name and should not be translated.
# Note: "-Xjit" is a command line parameter and should not be translated.
J9NLS_JCL_JAVA_COMPILER_WARNING_XJIT=Setting the java.compiler system property is obsolete in version 21 and later, use -Xjit instead.
# START NON-TRANSLATABLE
J9NLS_JCL_JAVA_COMPILER_WARNING_XJIT.explanation=The java.compiler system property can no longer be used to enable or disable the JIT.
J9NLS_JCL_JAVA_COMPILER_WARNING_XJIT.system_action=Setting the java.compiler system property is ignored.
J9NLS_JCL_JAVA_COMPILER_WARNING_XJIT.user_response=Use the -Xjit option to enable the JIT.
# END NON-TRANSLATABLE

# Note: "java.compiler" is a system property name and should not be translated.
# Note: "-Xint" is a command line parameter and should not be translated.
J9NLS_JCL_JAVA_COMPILER_WARNING_XINT=Setting the java.compiler system property is obsolete in version 21 and later, use -Xint instead.
# START NON-TRANSLATABLE
J9NLS_JCL_JAVA_COMPILER_WARNING_XINT.explanation=The java.compiler system property can no longer be used to enable or disable the JIT.
J9NLS_JCL_JAVA_COMPILER_WARNING_XINT.system_action=Setting the java.compiler system property is ignored.
J9NLS_JCL_JAVA_COMPILER_WARNING_XINT.user_response=Use the -Xint option to disable the JIT.
# END NON-TRANSLATABLE
2 changes: 2 additions & 0 deletions runtime/util/vmargs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,9 @@ addEnvironmentVariables(J9PortLibrary *portLib, JavaVMInitArgs *launcherArgs, J9
IDATA status = 0;
if (
(0 != mapEnvVarToArgument(portLib, ENVVAR_IBM_MIXED_MODE_THRESHOLD, MAPOPT_XJIT_COUNT_EQUALS, vmArgumentsList, EXACT_MAP_WITH_OPTIONS, verboseFlags))
#if JAVA_SPEC_VERSION < 21
|| (0 != mapEnvVarToArgument(portLib, ENVVAR_JAVA_COMPILER, SYSPROP_DJAVA_COMPILER_EQUALS, vmArgumentsList, EXACT_MAP_WITH_OPTIONS, verboseFlags))
#endif /* JAVA_SPEC_VERSION < 21 */
|| (0 != mapEnvVarToArgument(portLib, ENVVAR_IBM_NOSIGHANDLER, VMOPT_XRS, vmArgumentsList, EXACT_MAP_NO_OPTIONS, verboseFlags))
#if defined(J9ZOS390)
|| (0 != mapEnvVarToArgument(portLib, ENVVAR_JAVA_THREAD_MODEL, MAPOPT_XTHR_TW_EQUALS, vmArgumentsList, EXACT_MAP_WITH_OPTIONS, verboseFlags))
Expand Down
30 changes: 24 additions & 6 deletions runtime/vm/jvminit.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,9 @@ static void loadDLL (void* dllLoadInfo, void* userDataTemp);
static void registerIgnoredOptions (J9PortLibrary *portLibrary, J9VMInitArgs* j9vm_args);
static UDATA protectedInitializeJavaVM (J9PortLibrary* portLibrary, void * userData);
static J9Pool *initializeDllLoadTable (J9PortLibrary *portLibrary, J9VMInitArgs* j9vm_args, UDATA verboseFlags, J9JavaVM *vm);
#if (defined(J9VM_OPT_SIDECAR))
#if defined(J9VM_OPT_SIDECAR) && (JAVA_SPEC_VERSION < 21)
static IDATA checkDjavacompiler (J9PortLibrary *portLibrary, J9VMInitArgs* j9vm_args);
#endif /* J9VM_OPT_SIDECAR */
#endif /* defined(J9VM_OPT_SIDECAR) && (JAVA_SPEC_VERSION < 21) */
static void* getOptionExtraInfo (J9PortLibrary *portLibrary, J9VMInitArgs* j9vm_args, IDATA match, char* optionName);
static void closeAllDLLs (J9JavaVM* vm);

Expand Down Expand Up @@ -4914,6 +4914,7 @@ registerCmdLineMapping(J9JavaVM* vm, char* sov_option, char* j9_option, UDATA ma
static IDATA
registerVMCmdLineMappings(J9JavaVM* vm)
{
#if JAVA_SPEC_VERSION < 21
char jitOpt[SMALL_STRING_BUF_SIZE]; /* Plenty big enough */
char* changeCursor;
IDATA bufLeft = 0;
Expand All @@ -4922,6 +4923,7 @@ registerVMCmdLineMappings(J9JavaVM* vm)
strcpy(jitOpt, SYSPROP_DJAVA_COMPILER_EQUALS);
bufLeft = SMALL_STRING_BUF_SIZE - strlen(jitOpt) - 1;
changeCursor = &jitOpt[strlen(jitOpt)];
#endif /* JAVA_SPEC_VERSION < 21 */

#ifdef J9VM_OPT_JVMTI
if (registerCmdLineMapping(vm, MAPOPT_JAVAAGENT_COLON, MAPOPT_AGENTLIB_INSTRUMENT_EQUALS, MAP_WITH_INCLUSIVE_OPTIONS) == RC_FAILED) {
Expand All @@ -4932,6 +4934,7 @@ registerVMCmdLineMappings(J9JavaVM* vm)
if (registerCmdLineMapping(vm, MAPOPT_XCOMP, MAPOPT_XJIT_COUNT0, EXACT_MAP_NO_OPTIONS) == RC_FAILED) {
return RC_FAILED;
}
#if JAVA_SPEC_VERSION < 21
strncpy(changeCursor, DJCOPT_JITC, bufLeft);
if (registerCmdLineMapping(vm, jitOpt, VMOPT_XJIT, EXACT_MAP_NO_OPTIONS) == RC_FAILED) {
return RC_FAILED;
Expand All @@ -4943,6 +4946,7 @@ registerVMCmdLineMappings(J9JavaVM* vm)
if (registerCmdLineMapping(vm, SYSPROP_DJAVA_COMPILER_EQUALS, VMOPT_XINT, STARTSWITH_MAP_NO_OPTIONS) == RC_FAILED) { /* any other -Djava.compiler= found is mapped to -Xint */
return RC_FAILED;
}
#endif /* JAVA_SPEC_VERSION < 21 */
if (registerCmdLineMapping(vm, MAPOPT_XDISABLEJAVADUMP, MAPOPT_XDUMP_JAVA_NONE, EXACT_MAP_NO_OPTIONS) == RC_FAILED) {
return RC_FAILED;
}
Expand Down Expand Up @@ -6287,7 +6291,7 @@ testOptionValueOps(J9JavaVM* vm)
#endif


#if (defined(J9VM_OPT_SIDECAR))
#if defined(J9VM_OPT_SIDECAR) && (JAVA_SPEC_VERSION < 21)
/* Whine about -Djava.compiler if the option is not used correctly */

static IDATA
Expand All @@ -6312,7 +6316,7 @@ checkDjavacompiler(J9PortLibrary *portLibrary, J9VMInitArgs* j9vm_args)
}
return 0;
}
#endif /* J9VM_OPT_SIDECAR */
#endif /* defined(J9VM_OPT_SIDECAR) && (JAVA_SPEC_VERSION < 21) */


static IDATA
Expand Down Expand Up @@ -7257,10 +7261,12 @@ protectedInitializeJavaVM(J9PortLibrary* portLibrary, void * userData)
#endif

#ifdef J9VM_OPT_SIDECAR
#if JAVA_SPEC_VERSION < 21
/* Whine about -Djava.compiler after extra VM options are added, but before mappings are set */
if (RC_FAILED == checkDjavacompiler(portLibrary, vm->vmArgsArray)) {
goto error;
}
#endif /* JAVA_SPEC_VERSION < 21 */

if (doParseXlogForCompatibility) {
if (JNI_OK != parseXlogForCompatibility(vm)) {
Expand Down Expand Up @@ -7416,17 +7422,23 @@ protectedInitializeJavaVM(J9PortLibrary* portLibrary, void * userData)
goto error;
}

/* If the JIT started, set the java.compiler system property and allocate the global OSR buffer */
/* If the JIT started, set the java.compiler/openj9.compiler system property and allocate the global OSR buffer */
if (NULL != vm->jitConfig) {
J9VMSystemProperty * property = NULL;
#ifndef DELETEME
UDATA osrGlobalBufferSize = sizeof(J9JITDecompilationInfo);
#endif
#if JAVA_SPEC_VERSION < 21
J9VMSystemProperty * property = NULL;

if (J9SYSPROP_ERROR_NONE == getSystemProperty(vm, "java.compiler", &property)) {
setSystemProperty(vm, property, J9_JIT_DLL_NAME);
property->flags &= ~J9SYSPROP_FLAG_WRITEABLE;
}
#else /* JAVA_SPEC_VERSION < 21 */
if (J9SYSPROP_ERROR_NONE != addSystemProperty(vm, "openj9.compiler", J9_JIT_DLL_NAME, 0)) {
goto error;
}
#endif /* JAVA_SPEC_VERSION < 21 */
#ifndef DELETEME
osrGlobalBufferSize += ROUND_TO(sizeof(UDATA), vm->jitConfig->osrFramesMaximumSize);
osrGlobalBufferSize += ROUND_TO(sizeof(UDATA), vm->jitConfig->osrScratchBufferMaximumSize);
Expand Down Expand Up @@ -7471,6 +7483,12 @@ protectedInitializeJavaVM(J9PortLibrary* portLibrary, void * userData)
}

} else {
#if JAVA_SPEC_VERSION >= 21
if (J9SYSPROP_ERROR_NONE != addSystemProperty(vm, "openj9.compiler", "", 0)) {
goto error;
}
#endif /* JAVA_SPEC_VERSION >= 21 */

/* If there is no JIT, change the vm phase so RAS will enable level 2 tracepoints */
jvmPhaseChange(vm, J9VM_PHASE_NOT_STARTUP);
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/vm/vmifunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ vmi_getPortLibrary(VMInterface* vmi)
<BR>OpenJ9 - 1ca0ab98
<BR>OMR - 05d2b8a2
<BR>JCL - c2aa0348 based on jdk8u172-b11"</TD></TR>
* <TR><TD>java.compiler</TD> <TD>"j9jit29"</TD></TR>
* <TR><TD>java.compiler</TD> <TD>"j9jit29" - not supported from jdk21</TD></TR>
* <TR><TD>java.class.version</TD> <TD>"52.0"</TD></TR>
* <TR><TD>java.home</TD> <TD>the absolute path of the parent directory of the directory containing the vm
<BR>i.e. for a vm /clear/bin/vm.exe, java.home is /clear</TD></TR>
Expand Down
2 changes: 2 additions & 0 deletions runtime/vm/vmprops.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,11 +744,13 @@ initializeSystemProperties(J9JavaVM * vm)
}
#endif

#if JAVA_SPEC_VERSION < 21
/* Don't know the JIT yet, put in a placeholder and make it writeable for now */
rc = addSystemProperty(vm, "java.compiler", "", J9SYSPROP_FLAG_WRITEABLE);
if (J9SYSPROP_ERROR_NONE != rc) {
goto fail;
}
#endif /* JAVA_SPEC_VERSION < 21 */

/* We don't have enough information yet. Put in placeholders. */
#if defined(J9VM_OPT_SIDECAR) && !defined(WIN32)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public class VmArgumentTests {
private static final String MAPOPT_XJIT_COUNT_EQUALS = "-Xjit:count="+MIXED_MODE_THRESHOLD_VALUE;

private static final String JAVA_COMPILER = "JAVA_COMPILER";
private static final String JAVA_COMPILER_VALUE=System.getProperty("java.compiler");
private static final String JAVA_COMPILER_VALUE = System.getProperty(VersionCheck.major() < 21 ? "java.compiler" : "openj9.compiler");
private static final String SYSPROP_DJAVA_COMPILER_EQUALS = "-Djava.compiler="+JAVA_COMPILER_VALUE;

private static final boolean isIBM;
Expand Down Expand Up @@ -499,7 +499,12 @@ public void testMappedOptions() {
env.put(IBM_JAVA_OPTIONS, ibmJavaOptionsArg);

actualArguments = runAndGetArgumentList(pb);
final String[] expectedArguments = new String[] {MAPOPT_XJIT_COUNT_EQUALS, SYSPROP_DJAVA_COMPILER_EQUALS, VMOPT_XRS, ibmJavaOptionsArg};
final String[] expectedArguments;
if (VersionCheck.major() < 21) {
expectedArguments = new String[] {MAPOPT_XJIT_COUNT_EQUALS, SYSPROP_DJAVA_COMPILER_EQUALS, VMOPT_XRS, ibmJavaOptionsArg};
} else {
expectedArguments = new String[] {MAPOPT_XJIT_COUNT_EQUALS, VMOPT_XRS, ibmJavaOptionsArg};
}
HashMap<String, Integer> argumentPositions = checkArguments(actualArguments, expectedArguments);
checkArgumentSequence(expectedArguments, argumentPositions, true);
/* mapped options in environment variables should come before other non-implicit arguments */
Expand Down

0 comments on commit bb24cfb

Please sign in to comment.