From 1f184aa3f8fb1d7f2f118022b4679cd60447e7fa Mon Sep 17 00:00:00 2001 From: Jason Feng Date: Thu, 17 Feb 2022 11:51:14 -0500 Subject: [PATCH] JDK19 uses NativeLibraries.newInstance() API Also updated reference to rt-compressed.sunJava19.jar for pConfig compilation. Signed-off-by: Jason Feng --- jcl/jpp_configuration.xml | 2 +- .../share/classes/java/lang/ClassLoader.java | 37 +++++++++---------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/jcl/jpp_configuration.xml b/jcl/jpp_configuration.xml index 97aebc1f9b9..959f14bdb4d 100644 --- a/jcl/jpp_configuration.xml +++ b/jcl/jpp_configuration.xml @@ -206,7 +206,7 @@ - + diff --git a/jcl/src/java.base/share/classes/java/lang/ClassLoader.java b/jcl/src/java.base/share/classes/java/lang/ClassLoader.java index 1255babefa7..6b076dbe212 100644 --- a/jcl/src/java.base/share/classes/java/lang/ClassLoader.java +++ b/jcl/src/java.base/share/classes/java/lang/ClassLoader.java @@ -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(); }