Skip to content

Commit

Permalink
Merge pull request #14549 from JasonFengJ9/jdk19nativelib
Browse files Browse the repository at this point in the history
JDK19 uses NativeLibraries.newInstance() API
  • Loading branch information
pshipton authored Feb 17, 2022
2 parents 5406970 + 1f184aa commit 43f2abf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
2 changes: 1 addition & 1 deletion jcl/jpp_configuration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
<classpathentry kind="src" path="src/openj9.traceformat/share/classes"/>
<classpathentry kind="src" path="src/openj9.zosconditionhandling/share/classes"/>
<classpathentry kind="lib" path="/binaries/common/ibm/ibmjzos.jar"/>
<classpathentry kind="lib" path="/binaries/vm/third/rt-compressed.sunJava18.jar"/>
<classpathentry kind="lib" path="/binaries/vm/third/rt-compressed.sunJava19.jar"/>
<source path="src"/>
<parameter name="macro:define" value="JAVA_SPEC_VERSION=19"/>
<parameter name="msg:outputdir" value="java.base/share/classes/com/ibm/oti/util"/>
Expand Down
37 changes: 17 additions & 20 deletions jcl/src/java.base/share/classes/java/lang/ClassLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -372,56 +372,53 @@ private ClassLoader(Void staticMethodHolder, String classLoaderName, ClassLoader
// This assumes that DelegatingClassLoader is constructed via ClassLoader(parentLoader)
isDelegatingCL = DELEGATING_CL.equals(this.getClass().getName());

/*[IF Sidecar19-SE]*/
/*[IF JAVA_SPEC_VERSION > 8]*/
if ((classLoaderName != null) && classLoaderName.isEmpty()) {
/*[MSG "K0645", "The given class loader name can't be empty."]*/
throw new IllegalArgumentException(com.ibm.oti.util.Msg.getString("K0645")); //$NON-NLS-1$
}
/*[ENDIF]*/
/*[ENDIF] JAVA_SPEC_VERSION > 8 */

if (parallelCapableCollection.containsKey(this.getClass())) {
isParallelCapable = true;
}

// VM Critical: must set parent before calling initializeInternal()
parent = parentLoader;
/*[IF !Sidecar19-SE]*/
/*[IF JAVA_SPEC_VERSION == 8]*/
specialLoaderInited = (bootstrapClassLoader != null);
/*[ENDIF]*/
/*[ENDIF] JAVA_SPEC_VERSION == 8 */
if (specialLoaderInited) {
if (!lazyClassLoaderInit) {
VM.initializeClassLoader(this, VM.J9_CLASSLOADER_TYPE_OTHERS, isParallelCapable);
}
/*[IF Sidecar19-SE]*/
/*[IF JAVA_SPEC_VERSION > 8]*/
unnamedModule = new Module(this);
/*[IF JAVA_SPEC_VERSION >= 15]*/
this.nativelibs = NativeLibraries.jniNativeLibraries(this);
/*[ENDIF] JAVA_SPEC_VERSION >= 15 */
/*[ENDIF]*/
}
/*[IF Sidecar19-SE]*/
/*[ENDIF] JAVA_SPEC_VERSION > 8 */
}
/*[IF JAVA_SPEC_VERSION > 8]*/
else {
if (bootstrapClassLoader == null) {
// BootstrapClassLoader.unnamedModule is set by JVM_SetBootLoaderUnnamedModule
unnamedModule = null;
bootstrapClassLoader = this;
VM.initializeClassLoader(bootstrapClassLoader, VM.J9_CLASSLOADER_TYPE_BOOT, false);
/*[IF JAVA_SPEC_VERSION >= 15]*/
this.nativelibs = NativeLibraries.jniNativeLibraries(null);
/*[ENDIF] JAVA_SPEC_VERSION >= 15 */
} else {
// Assuming the second classloader initialized is platform classloader
VM.initializeClassLoader(this, VM.J9_CLASSLOADER_TYPE_PLATFORM, false);
specialLoaderInited = true;
unnamedModule = new Module(this);
/*[IF JAVA_SPEC_VERSION >= 15]*/
this.nativelibs = NativeLibraries.jniNativeLibraries(this);
/*[ENDIF] JAVA_SPEC_VERSION >= 15 */
}
}
this.classLoaderName = classLoaderName;
/*[ENDIF]*/

/*[ENDIF] JAVA_SPEC_VERSION > 8 */

/*[IF JAVA_SPEC_VERSION >= 19]*/
this.nativelibs = NativeLibraries.newInstance((this == bootstrapClassLoader) ? null : this);
/*[ELSEIF JAVA_SPEC_VERSION >= 17] */
this.nativelibs = NativeLibraries.jniNativeLibraries((this == bootstrapClassLoader) ? null : this);
/*[ENDIF] JAVA_SPEC_VERSION >= 19 */

if (isAssertOptionFound) {
initializeClassLoaderAssertStatus();
}
Expand Down

0 comments on commit 43f2abf

Please sign in to comment.