Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDK18 adds --finalization=[enabled|disabled] #14116

Merged
merged 1 commit into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions runtime/j9vm/javanextvmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,12 @@ JVM_DumpDynamicArchive(JNIEnv *env, jstring str)
JNIEXPORT jboolean JNICALL
JVM_IsFinalizationEnabled(JNIEnv *env)
{
assert(!"JVM_IsFinalizationEnabled unimplemented");
return JNI_FALSE;
jboolean isFinalizationEnabled = JNI_TRUE;
J9VMThread *currentThread = (J9VMThread*)env;
if (J9_ARE_ANY_BITS_SET(currentThread->javaVM->extendedRuntimeFlags, J9_EXTENDED_RUNTIME_DISABLE_FINALIZATION)) {
isFinalizationEnabled = JNI_FALSE;
}
return isFinalizationEnabled;
}

JNIEXPORT void JNICALL
Expand Down
2 changes: 1 addition & 1 deletion runtime/oti/j9consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ extern "C" {
#define J9_EXTENDED_RUNTIME_RESTRICT_IFA 0x10
#define J9_EXTENDED_RUNTIME_FLAG_JSCRATCH_ADV_ON_FREE 0x20
#define J9_EXTENDED_RUNTIME_CHECK_DEBUG_INFO_COMPRESSION 0x40
#define J9_EXTENDED_RUNTIME_UNUSED_0x80 0x80
#define J9_EXTENDED_RUNTIME_DISABLE_FINALIZATION 0x80
#define J9_EXTENDED_RUNTIME_USE_J9JIMAGE_READER 0x100
#define J9_EXTENDED_RUNTIME_DEBUG_VM_ACCESS 0x200
#define J9_EXTENDED_RUNTIME_ENABLE_HCR 0x400
Expand Down
3 changes: 3 additions & 0 deletions runtime/oti/jvminit.h
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,9 @@ enum INIT_STAGE {
#define VMOPT_ILLEGAL_ACCESS "--illegal-access="
#define VMOPT_ENABLE_NATIVE_ACCESS "--enable-native-access"

/* JEP 421: Deprecate Finalization for Removal */
#define VMOPT_DISABLE_FINALIZATION "--finalization="

#define ENVVAR_IBM_MIXED_MODE_THRESHOLD "IBM_MIXED_MODE_THRESHOLD"
#define ENVVAR_JAVA_COMPILER "JAVA_COMPILER"
#define ENVVAR_JAVA_OPTIONS "_JAVA_OPTIONS"
Expand Down
26 changes: 26 additions & 0 deletions runtime/vm/jvminit.c
Original file line number Diff line number Diff line change
Expand Up @@ -3761,6 +3761,32 @@ processVMArgsFromFirstToLast(J9JavaVM * vm)
}
#endif /* defined(OMR_GC_COMPRESSED_POINTERS) && defined(OMR_GC_FULL_POINTERS) */

#if JAVA_SPEC_VERSION >= 18
{
/* JEP 421: Deprecate Finalization for Removal - Expecting values: "enabled" and "disabled".
* The default value for now will be "enabled", i.e., finalization is enabled by default.
* Other values will cause an error, additional values may be added in the future.
*/
IDATA argIndex = FIND_AND_CONSUME_ARG(STARTSWITH_MATCH, VMOPT_DISABLE_FINALIZATION, NULL);
if (argIndex >= 0) {
PORT_ACCESS_FROM_JAVAVM(vm);
char *optionArg = NULL;
GET_OPTION_VALUE(argIndex, '=', &optionArg);
if (NULL != optionArg) {
if (strcmp(optionArg, "disabled") == 0) {
vm->extendedRuntimeFlags |= J9_EXTENDED_RUNTIME_DISABLE_FINALIZATION;
} else if (strcmp(optionArg, "enabled") == 0) {
/* do nothing as finalization is enabled by default */
} else {
j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_VM_UNRECOGNISED_CMD_LINE_OPT, VMOPT_DISABLE_FINALIZATION);
}
} else {
j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_VM_UNRECOGNISED_CMD_LINE_OPT, VMOPT_DISABLE_FINALIZATION);
}
}
}
#endif /* JAVA_SPEC_VERSION >= 18 */

return JNI_OK;
}

Expand Down