Skip to content

Commit d51767b

Browse files
committed
The java.compiler system property is obsolete in jdk21+
Issue #18430 Signed-off-by: Peter Shipton <[email protected]>
1 parent 73dd4df commit d51767b

File tree

9 files changed

+73
-11
lines changed

9 files changed

+73
-11
lines changed

jcl/src/java.management/share/classes/com/ibm/java/lang/management/internal/CompilationMXBeanImpl.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ public static CompilationMXBeanImpl getInstance() {
7272
*/
7373
@Override
7474
public String getName() {
75-
return com.ibm.oti.vm.VM.getVMLangAccess().internalGetProperties().getProperty("java.compiler"); //$NON-NLS-1$
75+
return com.ibm.oti.vm.VM.getVMLangAccess().internalGetProperties().
76+
/*[IF JAVA_SPEC_VERSION < 21]*/
77+
getProperty("java.compiler"); //$NON-NLS-1$
78+
/*[ELSE] JAVA_SPEC_VERSION < 21 */
79+
getProperty("openj9.compiler"); //$NON-NLS-1$
80+
/*[ENDIF] JAVA_SPEC_VERSION < 21*/
7681
}
7782

7883
/**

runtime/include/vmi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ GetInitArgs(VMInterface* vmi);
276276
<BR>OpenJ9 - 1ca0ab98
277277
<BR>OMR - 05d2b8a2
278278
<BR>JCL - c2aa0348 based on jdk8u172-b11"</TD></TR>
279-
* <TR><TD>java.compiler</TD> <TD>"j9jit29"</TD></TR>
279+
* <TR><TD>java.compiler</TD> <TD>"j9jit29" - not supported from jdk21</TD></TR>
280280
* <TR><TD>java.class.version</TD> <TD>"52.0"</TD></TR>
281281
* <TR><TD>java.home</TD> <TD>the absolute path of the parent directory of the directory containing the vm
282282
<BR>i.e. for a vm /clear/bin/vm.exe, java.home is /clear</TD></TR>

runtime/jcl/common/system.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "jclprots.h"
3737

3838
#include "ut_j9jcl.h"
39+
#include "j9jclnls.h"
3940

4041
#if defined(J9ZOS390)
4142
#include "atoe.h"
@@ -551,6 +552,17 @@ systemPropertyIterator(char* key, char* value, void* userData)
551552
return;
552553
}
553554

555+
#if JAVA_SPEC_VERSION >= 21
556+
if (0 == strcmp("java.compiler", key)) {
557+
PORT_ACCESS_FROM_ENV(env);
558+
if ((0 == strcmp("jitc", value)) || (0 == strcmp(J9_JIT_DLL_NAME, value))) {
559+
j9nls_printf(PORTLIB, J9NLS_WARNING, J9NLS_JCL_JAVA_COMPILER_WARNING_XJIT);
560+
} else {
561+
j9nls_printf(PORTLIB, J9NLS_WARNING, J9NLS_JCL_JAVA_COMPILER_WARNING_XINT);
562+
}
563+
return;
564+
}
565+
#endif /* JAVA_SPEC_VERSION >= 21 */
554566

555567
/* check for overridden system properties, use linear scan for now */
556568
for (i=0; i < defaultCount; i+=2) {

runtime/nls/j9cl/j9jcl.nls

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,3 +588,21 @@ J9NLS_JCL_CRIU_FAILED_TO_ENABLE_ALL_RESTORE_OPTIONS.explanation=CRIUSupport::che
588588
J9NLS_JCL_CRIU_FAILED_TO_ENABLE_ALL_RESTORE_OPTIONS.system_action=The JVM will throw a JVMRestoreException.
589589
J9NLS_JCL_CRIU_FAILED_TO_ENABLE_ALL_RESTORE_OPTIONS.user_response=Check documentation to see which options are allowed on restore.
590590
# END NON-TRANSLATABLE
591+
592+
# Note: "java.compiler" is a system property name and should not be translated.
593+
# Note: "-Xjit" is a command line parameter and should not be translated.
594+
J9NLS_JCL_JAVA_COMPILER_WARNING_XJIT=Setting the java.compiler system property is obsolete in version 21 and later, use -Xjit instead.
595+
# START NON-TRANSLATABLE
596+
J9NLS_JCL_JAVA_COMPILER_WARNING_XJIT.explanation=The java.compiler system property can no longer be used to enable or disable the JIT.
597+
J9NLS_JCL_JAVA_COMPILER_WARNING_XJIT.system_action=Setting the java.compiler system property is ignored.
598+
J9NLS_JCL_JAVA_COMPILER_WARNING_XJIT.user_response=Use the -Xjit option to enable the JIT.
599+
# END NON-TRANSLATABLE
600+
601+
# Note: "java.compiler" is a system property name and should not be translated.
602+
# Note: "-Xint" is a command line parameter and should not be translated.
603+
J9NLS_JCL_JAVA_COMPILER_WARNING_XINT=Setting the java.compiler system property is obsolete in version 21 and later, use -Xint instead.
604+
# START NON-TRANSLATABLE
605+
J9NLS_JCL_JAVA_COMPILER_WARNING_XINT.explanation=The java.compiler system property can no longer be used to enable or disable the JIT.
606+
J9NLS_JCL_JAVA_COMPILER_WARNING_XINT.system_action=Setting the java.compiler system property is ignored.
607+
J9NLS_JCL_JAVA_COMPILER_WARNING_XINT.user_response=Use the -Xint option to disable the JIT.
608+
# END NON-TRANSLATABLE

runtime/util/vmargs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,9 @@ addEnvironmentVariables(J9PortLibrary *portLib, JavaVMInitArgs *launcherArgs, J9
13881388
IDATA status = 0;
13891389
if (
13901390
(0 != mapEnvVarToArgument(portLib, ENVVAR_IBM_MIXED_MODE_THRESHOLD, MAPOPT_XJIT_COUNT_EQUALS, vmArgumentsList, EXACT_MAP_WITH_OPTIONS, verboseFlags))
1391+
#if JAVA_SPEC_VERSION < 21
13911392
|| (0 != mapEnvVarToArgument(portLib, ENVVAR_JAVA_COMPILER, SYSPROP_DJAVA_COMPILER_EQUALS, vmArgumentsList, EXACT_MAP_WITH_OPTIONS, verboseFlags))
1393+
#endif /* JAVA_SPEC_VERSION < 21 */
13921394
|| (0 != mapEnvVarToArgument(portLib, ENVVAR_IBM_NOSIGHANDLER, VMOPT_XRS, vmArgumentsList, EXACT_MAP_NO_OPTIONS, verboseFlags))
13931395
#if defined(J9ZOS390)
13941396
|| (0 != mapEnvVarToArgument(portLib, ENVVAR_JAVA_THREAD_MODEL, MAPOPT_XTHR_TW_EQUALS, vmArgumentsList, EXACT_MAP_WITH_OPTIONS, verboseFlags))

runtime/vm/jvminit.c

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,9 @@ static void loadDLL (void* dllLoadInfo, void* userDataTemp);
266266
static void registerIgnoredOptions (J9PortLibrary *portLibrary, J9VMInitArgs* j9vm_args);
267267
static UDATA protectedInitializeJavaVM (J9PortLibrary* portLibrary, void * userData);
268268
static J9Pool *initializeDllLoadTable (J9PortLibrary *portLibrary, J9VMInitArgs* j9vm_args, UDATA verboseFlags, J9JavaVM *vm);
269-
#if (defined(J9VM_OPT_SIDECAR))
269+
#if defined(J9VM_OPT_SIDECAR) && (JAVA_SPEC_VERSION < 21)
270270
static IDATA checkDjavacompiler (J9PortLibrary *portLibrary, J9VMInitArgs* j9vm_args);
271-
#endif /* J9VM_OPT_SIDECAR */
271+
#endif /* defined(J9VM_OPT_SIDECAR) && (JAVA_SPEC_VERSION < 21) */
272272
static void* getOptionExtraInfo (J9PortLibrary *portLibrary, J9VMInitArgs* j9vm_args, IDATA match, char* optionName);
273273
static void closeAllDLLs (J9JavaVM* vm);
274274

@@ -4865,6 +4865,7 @@ registerCmdLineMapping(J9JavaVM* vm, char* sov_option, char* j9_option, UDATA ma
48654865
static IDATA
48664866
registerVMCmdLineMappings(J9JavaVM* vm)
48674867
{
4868+
#if JAVA_SPEC_VERSION < 21
48684869
char jitOpt[SMALL_STRING_BUF_SIZE]; /* Plenty big enough */
48694870
char* changeCursor;
48704871
IDATA bufLeft = 0;
@@ -4873,6 +4874,7 @@ registerVMCmdLineMappings(J9JavaVM* vm)
48734874
strcpy(jitOpt, SYSPROP_DJAVA_COMPILER_EQUALS);
48744875
bufLeft = SMALL_STRING_BUF_SIZE - strlen(jitOpt) - 1;
48754876
changeCursor = &jitOpt[strlen(jitOpt)];
4877+
#endif /* JAVA_SPEC_VERSION < 21 */
48764878

48774879
#ifdef J9VM_OPT_JVMTI
48784880
if (registerCmdLineMapping(vm, MAPOPT_JAVAAGENT_COLON, MAPOPT_AGENTLIB_INSTRUMENT_EQUALS, MAP_WITH_INCLUSIVE_OPTIONS) == RC_FAILED) {
@@ -4883,6 +4885,7 @@ registerVMCmdLineMappings(J9JavaVM* vm)
48834885
if (registerCmdLineMapping(vm, MAPOPT_XCOMP, MAPOPT_XJIT_COUNT0, EXACT_MAP_NO_OPTIONS) == RC_FAILED) {
48844886
return RC_FAILED;
48854887
}
4888+
#if JAVA_SPEC_VERSION < 21
48864889
strncpy(changeCursor, DJCOPT_JITC, bufLeft);
48874890
if (registerCmdLineMapping(vm, jitOpt, VMOPT_XJIT, EXACT_MAP_NO_OPTIONS) == RC_FAILED) {
48884891
return RC_FAILED;
@@ -4894,6 +4897,7 @@ registerVMCmdLineMappings(J9JavaVM* vm)
48944897
if (registerCmdLineMapping(vm, SYSPROP_DJAVA_COMPILER_EQUALS, VMOPT_XINT, STARTSWITH_MAP_NO_OPTIONS) == RC_FAILED) { /* any other -Djava.compiler= found is mapped to -Xint */
48954898
return RC_FAILED;
48964899
}
4900+
#endif /* JAVA_SPEC_VERSION < 21 */
48974901
if (registerCmdLineMapping(vm, MAPOPT_XDISABLEJAVADUMP, MAPOPT_XDUMP_JAVA_NONE, EXACT_MAP_NO_OPTIONS) == RC_FAILED) {
48984902
return RC_FAILED;
48994903
}
@@ -6238,7 +6242,7 @@ testOptionValueOps(J9JavaVM* vm)
62386242
#endif
62396243

62406244

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

62446248
static IDATA
@@ -6263,7 +6267,7 @@ checkDjavacompiler(J9PortLibrary *portLibrary, J9VMInitArgs* j9vm_args)
62636267
}
62646268
return 0;
62656269
}
6266-
#endif /* J9VM_OPT_SIDECAR */
6270+
#endif /* defined(J9VM_OPT_SIDECAR) && (JAVA_SPEC_VERSION < 21) */
62676271

62686272

62696273
static IDATA
@@ -7208,10 +7212,12 @@ protectedInitializeJavaVM(J9PortLibrary* portLibrary, void * userData)
72087212
#endif
72097213

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

72167222
if (doParseXlogForCompatibility) {
72177223
if (JNI_OK != parseXlogForCompatibility(vm)) {
@@ -7367,17 +7373,23 @@ protectedInitializeJavaVM(J9PortLibrary* portLibrary, void * userData)
73677373
goto error;
73687374
}
73697375

7370-
/* If the JIT started, set the java.compiler system property and allocate the global OSR buffer */
7376+
/* If the JIT started, set the java.compiler/openj9.compiler system property and allocate the global OSR buffer */
73717377
if (NULL != vm->jitConfig) {
7372-
J9VMSystemProperty * property = NULL;
73737378
#ifndef DELETEME
73747379
UDATA osrGlobalBufferSize = sizeof(J9JITDecompilationInfo);
73757380
#endif
7381+
#if JAVA_SPEC_VERSION < 21
7382+
J9VMSystemProperty * property = NULL;
73767383

73777384
if (J9SYSPROP_ERROR_NONE == getSystemProperty(vm, "java.compiler", &property)) {
73787385
setSystemProperty(vm, property, J9_JIT_DLL_NAME);
73797386
property->flags &= ~J9SYSPROP_FLAG_WRITEABLE;
73807387
}
7388+
#else /* JAVA_SPEC_VERSION < 21 */
7389+
if (J9SYSPROP_ERROR_NONE != addSystemProperty(vm, "openj9.compiler", J9_JIT_DLL_NAME, 0)) {
7390+
goto error;
7391+
}
7392+
#endif /* JAVA_SPEC_VERSION < 21 */
73817393
#ifndef DELETEME
73827394
osrGlobalBufferSize += ROUND_TO(sizeof(UDATA), vm->jitConfig->osrFramesMaximumSize);
73837395
osrGlobalBufferSize += ROUND_TO(sizeof(UDATA), vm->jitConfig->osrScratchBufferMaximumSize);
@@ -7422,6 +7434,12 @@ protectedInitializeJavaVM(J9PortLibrary* portLibrary, void * userData)
74227434
}
74237435

74247436
} else {
7437+
#if JAVA_SPEC_VERSION >= 21
7438+
if (J9SYSPROP_ERROR_NONE != addSystemProperty(vm, "openj9.compiler", "", 0)) {
7439+
goto error;
7440+
}
7441+
#endif /* JAVA_SPEC_VERSION >= 21 */
7442+
74257443
/* If there is no JIT, change the vm phase so RAS will enable level 2 tracepoints */
74267444
jvmPhaseChange(vm, J9VM_PHASE_NOT_STARTUP);
74277445
}

runtime/vm/vmifunc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ vmi_getPortLibrary(VMInterface* vmi)
204204
<BR>OpenJ9 - 1ca0ab98
205205
<BR>OMR - 05d2b8a2
206206
<BR>JCL - c2aa0348 based on jdk8u172-b11"</TD></TR>
207-
* <TR><TD>java.compiler</TD> <TD>"j9jit29"</TD></TR>
207+
* <TR><TD>java.compiler</TD> <TD>"j9jit29" - not supported from jdk21</TD></TR>
208208
* <TR><TD>java.class.version</TD> <TD>"52.0"</TD></TR>
209209
* <TR><TD>java.home</TD> <TD>the absolute path of the parent directory of the directory containing the vm
210210
<BR>i.e. for a vm /clear/bin/vm.exe, java.home is /clear</TD></TR>

runtime/vm/vmprops.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,11 +744,13 @@ initializeSystemProperties(J9JavaVM * vm)
744744
}
745745
#endif
746746

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

753755
/* We don't have enough information yet. Put in placeholders. */
754756
#if defined(J9VM_OPT_SIDECAR) && !defined(WIN32)

test/functional/Java8andUp/src/org/openj9/test/vmArguments/VmArgumentTests.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public class VmArgumentTests {
115115
private static final String MAPOPT_XJIT_COUNT_EQUALS = "-Xjit:count="+MIXED_MODE_THRESHOLD_VALUE;
116116

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

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

501501
actualArguments = runAndGetArgumentList(pb);
502-
final String[] expectedArguments = new String[] {MAPOPT_XJIT_COUNT_EQUALS, SYSPROP_DJAVA_COMPILER_EQUALS, VMOPT_XRS, ibmJavaOptionsArg};
502+
final String[] expectedArguments;
503+
if (VersionCheck.major() < 21) {
504+
expectedArguments = new String[] {MAPOPT_XJIT_COUNT_EQUALS, SYSPROP_DJAVA_COMPILER_EQUALS, VMOPT_XRS, ibmJavaOptionsArg};
505+
} else {
506+
expectedArguments = new String[] {MAPOPT_XJIT_COUNT_EQUALS, VMOPT_XRS, ibmJavaOptionsArg};
507+
}
503508
HashMap<String, Integer> argumentPositions = checkArguments(actualArguments, expectedArguments);
504509
checkArgumentSequence(expectedArguments, argumentPositions, true);
505510
/* mapped options in environment variables should come before other non-implicit arguments */

0 commit comments

Comments
 (0)