Skip to content

Commit 04f6aed

Browse files
committed
JEP500 add --enable-final-field-mutation/--illegal-final-field-mutation
Use addPropertiesForOptionWithAssignArg() to find all --enable-final-field-mutation options, addPropertyForOptionWithEqualsArg() to find and consume the last --illegal-final-field-mutation options. Signed-off-by: Jason Feng <[email protected]>
1 parent 59c18fd commit 04f6aed

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

runtime/oti/jvminit.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,10 @@ enum INIT_STAGE {
704704
#define VMOPT_ILLEGAL_ACCESS "--illegal-access="
705705
#define VMOPT_ENABLE_NATIVE_ACCESS "--enable-native-access"
706706
#define VMOPT_ILLEGAL_NATIVE_ACCESS "--illegal-native-access="
707+
#if JAVA_SPEC_VERSION >= 26
708+
#define VMOPT_ENABLE_FINAL_FIELD_MUTATION "--enable-final-field-mutation"
709+
#define VMOPT_ILLEGAL_FINAL_FIELD_MUTATION "--illegal-final-field-mutation="
710+
#endif /* JAVA_SPEC_VERSION >= 26 */
707711

708712
/* JEP 421: Deprecate Finalization for Removal */
709713
#define VMOPT_DISABLE_FINALIZATION "--finalization="
@@ -744,6 +748,12 @@ enum INIT_STAGE {
744748
#define SYSPROP_SUN_MISC_UNSAFE_MEMORY_ACCESS "sun.misc.unsafe.memory.access"
745749
#endif /* JAVA_SPEC_VERSION >= 23 */
746750
#define SYSPROP_JDK_MODULE_ILLEGALNATIVEACCESS "jdk.module.illegal.native.access"
751+
#if JAVA_SPEC_VERSION >= 26
752+
/* Match the system properties in jdk.internal.module.ModuleBootstrap.decodeEnableFinalFieldMutation(). */
753+
#define SYSPROP_JDK_MODULE_ENABLEL_FINAL_FIELD_MUTATION "jdk.module.enable.final.field.mutation."
754+
/* Match the system properties in jdk.internal.module.ModuleBootstrap.decodeIllegalFinalFieldMutation(). */
755+
#define SYSPROP_JDK_MODULE_ILLEGAL_FINAL_FIELD_MUTATION "jdk.module.illegal.final.field.mutation"
756+
#endif /* JAVA_SPEC_VERSION >= 26 */
747757
#define JAVA_BASE_MODULE "java.base"
748758

749759
#define SYSPROP_COM_SUN_MANAGEMENT "-Dcom.sun.management."

runtime/vm/vmprops.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,22 @@ addModularitySystemProperties(J9JavaVM *vm)
552552
}
553553
#endif /* JAVA_SPEC_VERSION >= 24 */
554554

555+
#if JAVA_SPEC_VERSION >= 26
556+
/* Find all --enable-final-field-mutation options. */
557+
rc = addPropertiesForOptionWithAssignArg(vm, VMOPT_ENABLE_FINAL_FIELD_MUTATION, LITERAL_STRLEN(VMOPT_ENABLE_FINAL_FIELD_MUTATION),
558+
SYSPROP_JDK_MODULE_ENABLEL_FINAL_FIELD_MUTATION, LITERAL_STRLEN(SYSPROP_JDK_MODULE_ENABLEL_FINAL_FIELD_MUTATION), NULL);
559+
if (J9SYSPROP_ERROR_NONE != rc) {
560+
goto _end;
561+
}
562+
563+
/* Find and consume the last --illegal-final-field-mutation options. */
564+
rc = addPropertyForOptionWithEqualsArg(vm, VMOPT_ILLEGAL_FINAL_FIELD_MUTATION, LITERAL_STRLEN(VMOPT_ILLEGAL_FINAL_FIELD_MUTATION),
565+
SYSPROP_JDK_MODULE_ILLEGAL_FINAL_FIELD_MUTATION);
566+
if (J9SYSPROP_ERROR_NONE != rc) {
567+
goto _end;
568+
}
569+
#endif /* JAVA_SPEC_VERSION >= 17 */
570+
555571
/* Find last --illegal-access */
556572
rc = addPropertyForOptionWithEqualsArg(vm, VMOPT_ILLEGAL_ACCESS, LITERAL_STRLEN(VMOPT_ILLEGAL_ACCESS), SYSPROP_JDK_MODULE_ILLEGALACCESS);
557573

0 commit comments

Comments
 (0)