Skip to content

Commit

Permalink
Merge pull request #20862 from ThanHenderson/extinitsnap
Browse files Browse the repository at this point in the history
Properly initialize the extensionClassLoader from the VM snapshot
  • Loading branch information
babsingh authored Dec 20, 2024
2 parents 4ed5932 + 767a9d8 commit 9a1177f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
25 changes: 16 additions & 9 deletions runtime/vm/BytecodeInterpreter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4748,15 +4748,22 @@ class INTERPRETER_CLASS
allClassesEndDo(&classWalkState);
} else {
updateVMStruct(REGISTER_ARGS);
J9ClassLoader* result = internalAllocateClassLoader(_vm, classLoaderObject);
VMStructHasBeenUpdated(REGISTER_ARGS); // likely unnecessary - no code runs in internalAllocateClassLoader
if (NULL == result) {
rc = GOTO_THROW_CURRENT_EXCEPTION;
goto done;
}
if (J9_CLASSLOADER_TYPE_PLATFORM == loaderType) {
/* extensionClassLoader holds the platform class loader in Java 11+ */
_vm->extensionClassLoader = result;
#if defined(J9VM_OPT_SNAPSHOTS)
if (IS_RESTORE_RUN(_vm) && (J9_CLASSLOADER_TYPE_PLATFORM == loaderType)) {
_vm->internalVMFunctions->initializeSnapshotClassLoaderObject(_vm, _vm->extensionClassLoader, classLoaderObject);
} else
#endif /* defined(J9VM_OPT_SNAPSHOTS) */
{
J9ClassLoader *result = internalAllocateClassLoader(_vm, classLoaderObject);
VMStructHasBeenUpdated(REGISTER_ARGS); // likely unnecessary - no code runs in internalAllocateClassLoader
if (NULL == result) {
rc = GOTO_THROW_CURRENT_EXCEPTION;
goto done;
}
if (J9_CLASSLOADER_TYPE_PLATFORM == loaderType) {
/* extensionClassLoader holds the platform class loader in Java 11+ */
_vm->extensionClassLoader = result;
}
}
}
restoreInternalNativeStackFrame(REGISTER_ARGS);
Expand Down
15 changes: 11 additions & 4 deletions runtime/vm/FastJNI_com_ibm_oti_vm_VM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,17 @@ Fast_com_ibm_oti_vm_VM_initializeClassLoader(J9VMThread *currentThread, j9object
}
allClassesEndDo(&classWalkState);
} else {
J9ClassLoader *classLoaderStruct = internalAllocateClassLoader(vm, classLoaderObject);
if (J9_CLASSLOADER_TYPE_PLATFORM == loaderType) {
/* extensionClassLoader holds the platform class loader in Java 11+ */
vm->extensionClassLoader = classLoaderStruct;
#if defined(J9VM_OPT_SNAPSHOTS)
if (IS_RESTORE_RUN(vm) && (J9_CLASSLOADER_TYPE_PLATFORM == loaderType)) {
vm->internalVMFunctions->initializeSnapshotClassLoaderObject(vm, vm->extensionClassLoader, classLoaderObject);
} else
#endif /* defined(J9VM_OPT_SNAPSHOTS) */
{
J9ClassLoader *classLoaderStruct = internalAllocateClassLoader(vm, classLoaderObject);
if (J9_CLASSLOADER_TYPE_PLATFORM == loaderType) {
/* extensionClassLoader holds the platform class loader in Java 11+ */
vm->extensionClassLoader = classLoaderStruct;
}
}
}
}
Expand Down

0 comments on commit 9a1177f

Please sign in to comment.