Skip to content

Commit

Permalink
Merge pull request #19018 from JasonFengJ9/addexports-v0.44
Browse files Browse the repository at this point in the history
(v0.44.0-release) CRIU adds unqualified exports java.base/jdk.crac when CRaC is enabled
  • Loading branch information
tajila authored Feb 28, 2024
2 parents 24525c3 + 0efa61f commit f62ff9c
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 11 deletions.
6 changes: 6 additions & 0 deletions jcl/src/java.base/share/classes/java/lang/J9VMInternals.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ private static void completeInitialization() {
Runtime.getRuntime().addShutdownHook(new Thread(runnable, "CommonCleanerShutdown", true, false, false, null)); //$NON-NLS-1$
}
/*[ENDIF] JAVA_SPEC_VERSION >= 9 */
/*[IF CRAC_SUPPORT]*/
if (openj9.internal.criu.InternalCRIUSupport.isCRaCSupportEnabled()) {
// export java.base/jdk.crac unconditionally
J9VMInternals.class.getModule().implAddExports("jdk.crac"); //$NON-NLS-1$
}
/*[ENDIF] CRAC_SUPPORT */
}

/**
Expand Down
3 changes: 0 additions & 3 deletions jcl/src/java.base/share/classes/module-info.java.extra
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ exports jdk.internal.access to
opens jdk.internal.access to
openj9.criu;
/*[ENDIF] JAVA_SPEC_VERSION >= 17 */
/*[IF CRAC_SUPPORT]*/
exports jdk.crac;
/*[ENDIF] CRAC_SUPPORT */
exports jdk.internal.misc to
openj9.criu;
exports openj9.internal.criu to
Expand Down
58 changes: 51 additions & 7 deletions runtime/j9vm/java11vmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,14 @@ hashPackageTableDelete(J9VMThread * currentThread, J9ClassLoader * classLoader,
return rc;
}

/** @todo The strings below need to be NLS and also provide more debug info */
/**
* A modularity helper method to throw an exception according to the incoming error code.
*
* @param[in] currentThread the current J9VMThread
* @param[in] errCode a modularity error code
*
* @return Void
*/
static void
throwExceptionHelper(J9VMThread * currentThread, UDATA errCode)
{
Expand All @@ -169,7 +176,46 @@ throwExceptionHelper(J9VMThread * currentThread, UDATA errCode)
};

if (ERRCODE_SUCCESS != errCode) {
vmFuncs->setCurrentExceptionUTF(currentThread, J9VMCONSTANTPOOL_JAVALANGILLEGALARGUMENTEXCEPTION, (const char*)errMessages[errCode]);
OMRPORT_ACCESS_FROM_J9VMTHREAD(currentThread);
U_32 moduleName = 0;
U_32 messageNumber = 0;
const char *msg = NULL;

switch (errCode) {
case ERRCODE_GENERAL_FAILURE:
moduleName = J9NLS_VM_MODULARITY_GENERAL_FAILURE__MODULE;
messageNumber = J9NLS_VM_MODULARITY_GENERAL_FAILURE__ID;
break;
case ERRCODE_PACKAGE_ALREADY_DEFINED:
moduleName = J9NLS_VM_MODULARITY_PACKAGE_ALREADY_DEFINED__MODULE;
messageNumber = J9NLS_VM_MODULARITY_PACKAGE_ALREADY_DEFINED__ID;
break;
case ERRCODE_MODULE_ALREADY_DEFINED:
moduleName = J9NLS_VM_MODULARITY_MODULE_ALREADY_DEFINED__MODULE;
messageNumber = J9NLS_VM_MODULARITY_MODULE_ALREADY_DEFINED__ID;
break;
case ERRCODE_HASHTABLE_OPERATION_FAILED:
moduleName = J9NLS_VM_MODULARITY_HASH_OPERATION_FAILED__MODULE;
messageNumber = J9NLS_VM_MODULARITY_HASH_OPERATION_FAILED__ID;
break;
case ERRCODE_DUPLICATE_PACKAGE_IN_LIST:
moduleName = J9NLS_VM_MODULARITY_DUPLICATED_PACKAGE_FOUND__MODULE;
messageNumber = J9NLS_VM_MODULARITY_DUPLICATED_PACKAGE_FOUND__ID;
break;
case ERRCODE_MODULE_WASNT_FOUND:
moduleName = J9NLS_VM_MODULARITY_MODULE_NOT_FOUND__MODULE;
messageNumber = J9NLS_VM_MODULARITY_MODULE_NOT_FOUND__ID;
break;
case ERRCODE_PACKAGE_WASNT_FOUND:
moduleName = J9NLS_VM_MODULARITY_PACKAGE_NOT_FOUND__MODULE;
messageNumber = J9NLS_VM_MODULARITY_PACKAGE_NOT_FOUND__ID;
break;
default:
Assert_SC_unreachable();
break;
}
msg = OMRPORTLIB->nls_lookup_message(OMRPORTLIB, J9NLS_DO_NOT_PRINT_MESSAGE_TAG | J9NLS_DO_NOT_APPEND_NEWLINE, moduleName, messageNumber, NULL);
currentThread->javaVM->internalVMFunctions->setCurrentExceptionUTF(currentThread, J9VMCONSTANTPOOL_JAVALANGILLEGALARGUMENTEXCEPTION, msg);
}
}

Expand Down Expand Up @@ -891,7 +937,6 @@ JVM_DefineModule(JNIEnv * env, jobject module, jboolean isOpen, jstring version,
vm->runtimeFlags |= J9_RUNTIME_JAVA_BASE_MODULE_CREATED;
Trc_MODULE_defineModule(currentThread, "java.base", j9mod);
}

TRIGGER_J9HOOK_VM_MODULE_LOAD(vm->hookInterface, currentThread, j9mod);
} else {
throwExceptionHelper(currentThread, rc);
Expand Down Expand Up @@ -1231,13 +1276,12 @@ JVM_AddModulePackage(JNIEnv * env, jobject module, const char *package)
f_monitorEnter(vm->classLoaderModuleAndLocationMutex);
{
J9Module * const j9mod = getJ9Module(currentThread, module);
UDATA rc = addPackageDefinition(currentThread, j9mod, package);
if (ERRCODE_SUCCESS != rc) {
throwExceptionHelper(currentThread, rc);
} else {
if (addPackageDefinition(currentThread, j9mod, package)) {
if (TrcEnabled_Trc_MODULE_addModulePackage) {
trcModulesAddModulePackage(currentThread, j9mod, package);
}
} else {
throwExceptionHelper(currentThread, ERRCODE_GENERAL_FAILURE);
}
}
f_monitorExit(vm->classLoaderModuleAndLocationMutex);
Expand Down
49 changes: 49 additions & 0 deletions runtime/nls/j9vm/j9vm.nls
Original file line number Diff line number Diff line change
Expand Up @@ -2336,3 +2336,52 @@ J9NLS_VM_CRIU_J9_GET_PROCESS_START_TIME_FAILURE.explanation=j9sysinfo_get_proces
J9NLS_VM_CRIU_J9_GET_PROCESS_START_TIME_FAILURE.system_action=The JVM will throw a JVMRestoreException.
J9NLS_VM_CRIU_J9_GET_PROCESS_START_TIME_FAILURE.user_response=View CRIU documentation to determine how to resolve the error.
# END NON-TRANSLATABLE

J9NLS_VM_MODULARITY_GENERAL_FAILURE=General failure
# START NON-TRANSLATABLE
J9NLS_VM_MODULARITY_GENERAL_FAILURE.explanation=The specified modularity operation failed.
J9NLS_VM_MODULARITY_GENERAL_FAILURE.system_action=The JVM will fail to start.
J9NLS_VM_MODULARITY_GENERAL_FAILURE.user_response=Contact your service representative.
# END NON-TRANSLATABLE

J9NLS_VM_MODULARITY_PACKAGE_ALREADY_DEFINED=A package in the list has already been defined
# START NON-TRANSLATABLE
J9NLS_VM_MODULARITY_PACKAGE_ALREADY_DEFINED.explanation=The specified module package has already been defined.
J9NLS_VM_MODULARITY_PACKAGE_ALREADY_DEFINED.system_action=The JVM will fail to start.
J9NLS_VM_MODULARITY_PACKAGE_ALREADY_DEFINED.user_response=Contact your service representative.
# END NON-TRANSLATABLE

J9NLS_VM_MODULARITY_MODULE_ALREADY_DEFINED=The module has already been defined
# START NON-TRANSLATABLE
J9NLS_VM_MODULARITY_MODULE_ALREADY_DEFINED.explanation=The specified module has already been defined.
J9NLS_VM_MODULARITY_MODULE_ALREADY_DEFINED.system_action=The JVM will fail to start.
J9NLS_VM_MODULARITY_MODULE_ALREADY_DEFINED.user_response=Contact your service representative.
# END NON-TRANSLATABLE

J9NLS_VM_MODULARITY_HASH_OPERATION_FAILED=The modularity hash operation failed
# START NON-TRANSLATABLE
J9NLS_VM_MODULARITY_HASH_OPERATION_FAILED.explanation=The modularity hash operation failed.
J9NLS_VM_MODULARITY_HASH_OPERATION_FAILED.system_action=The JVM will fail to start.
J9NLS_VM_MODULARITY_HASH_OPERATION_FAILED.user_response=Contact your service representative.
# END NON-TRANSLATABLE

J9NLS_VM_MODULARITY_DUPLICATED_PACKAGE_FOUND=The list contains duplicate packages
# START NON-TRANSLATABLE
J9NLS_VM_MODULARITY_DUPLICATED_PACKAGE_FOUND.explanation=The list contains duplicate packages.
J9NLS_VM_MODULARITY_DUPLICATED_PACKAGE_FOUND.system_action=The JVM will fail to start.
J9NLS_VM_MODULARITY_DUPLICATED_PACKAGE_FOUND.user_response=Contact your service representative.
# END NON-TRANSLATABLE

J9NLS_VM_MODULARITY_MODULE_NOT_FOUND=The specified module was not found
# START NON-TRANSLATABLE
J9NLS_VM_MODULARITY_MODULE_NOT_FOUND.explanation=The specified module was not found.
J9NLS_VM_MODULARITY_MODULE_NOT_FOUND.system_action=The JVM will fail to start.
J9NLS_VM_MODULARITY_MODULE_NOT_FOUND.user_response=Contact your service representative.
# END NON-TRANSLATABLE

J9NLS_VM_MODULARITY_PACKAGE_NOT_FOUND=The specified package was not found
# START NON-TRANSLATABLE
J9NLS_VM_MODULARITY_PACKAGE_NOT_FOUND.explanation=The specified package was not found.
J9NLS_VM_MODULARITY_PACKAGE_NOT_FOUND.system_action=The JVM will fail to start.
J9NLS_VM_MODULARITY_PACKAGE_NOT_FOUND.user_response=Contact your service representative.
# END NON-TRANSLATABLE
2 changes: 1 addition & 1 deletion test/functional/cmdLineTests/criu/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
</javac>
</then>
<else>
<property name="addExports" value="--add-exports java.base/openj9.internal.criu=ALL-UNNAMED --add-exports java.base/jdk.internal.misc=ALL-UNNAMED" />
<property name="addExports" value="--add-exports java.base/jdk.crac=ALL-UNNAMED --add-exports java.base/openj9.internal.criu=ALL-UNNAMED --add-exports java.base/jdk.internal.misc=ALL-UNNAMED" />
<echo>===addExports: ${addExports}</echo>
<echo>===enablePreview: ${enablePreview}</echo>
<javac srcdir="${src}" destdir="${build}" debug="true" fork="true" executable="${compiler.javac}" includeAntRuntime="false" encoding="ISO-8859-1">
Expand Down

0 comments on commit f62ff9c

Please sign in to comment.