diff --git a/jcl/src/java.base/share/classes/java/lang/Class.java b/jcl/src/java.base/share/classes/java/lang/Class.java
index efd6f2c933f..a5db1dae877 100644
--- a/jcl/src/java.base/share/classes/java/lang/Class.java
+++ b/jcl/src/java.base/share/classes/java/lang/Class.java
@@ -64,9 +64,9 @@
import sun.reflect.annotation.AnnotationType;
import java.util.Arrays;
import com.ibm.oti.vm.VM;
-/*[IF JAVA_SPEC_VERSION >= 11]*/
+/*[IF (11 <= JAVA_SPEC_VERSION) & (JAVA_SPEC_VERSION < 24)]*/
import static com.ibm.oti.util.Util.doesClassLoaderDescendFrom;
-/*[ENDIF] JAVA_SPEC_VERSION >= 11*/
+/*[ENDIF] (11 <= JAVA_SPEC_VERSION) & (JAVA_SPEC_VERSION < 24) */
/*[IF JAVA_SPEC_VERSION >= 9]
import jdk.internal.misc.Unsafe;
@@ -5547,9 +5547,11 @@ static byte[] getExecutableTypeAnnotationBytes(Executable exec) {
/**
* Answers the host class of the receiver's nest.
*
+/*[IF JAVA_SPEC_VERSION < 24]
* @throws SecurityException if nestHost is not same as the current class, a security manager
* is present, the classloader of the caller is not the same or an ancestor of nestHost
* class, and checkPackageAccess() denies access
+/*[ENDIF] JAVA_SPEC_VERSION < 24
* @return the host class of the receiver.
*/
@CallerSensitive
@@ -5561,6 +5563,7 @@ public Class> getNestHost()
if (nestHost == null) {
nestHost = getNestHostImpl();
}
+ /*[IF JAVA_SPEC_VERSION < 24]*/
/* The specification requires that if:
* - the returned class is not the current class
* - a security manager is present
@@ -5582,6 +5585,7 @@ public Class> getNestHost()
}
}
}
+ /*[ENDIF] JAVA_SPEC_VERSION < 24 */
return nestHost;
}
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 d0c758c0631..9a6086334bd 100644
--- a/jcl/src/java.base/share/classes/java/lang/ClassLoader.java
+++ b/jcl/src/java.base/share/classes/java/lang/ClassLoader.java
@@ -324,14 +324,21 @@ static final void initializeClassLoaders() {
* Constructs a new instance of this class with the system
* class loader as its parent.
*
+/*[IF JAVA_SPEC_VERSION < 24]
* @exception SecurityException
* if a security manager exists and it does not
* allow the creation of new ClassLoaders.
+/*[ENDIF] JAVA_SPEC_VERSION < 24
*/
protected ClassLoader() {
+ /*[IF JAVA_SPEC_VERSION >= 24]*/
+ this(null, null, applicationClassLoader);
+ /*[ELSE] JAVA_SPEC_VERSION >= 24 */
this(checkSecurityPermission(), null, applicationClassLoader);
+ /*[ENDIF] JAVA_SPEC_VERSION >= 24 */
}
+/*[IF JAVA_SPEC_VERSION < 24]*/
/**
* This is a static helper method to perform security check earlier such that current ClassLoader object
* can't be resurrected when there is a SecurityException thrown.
@@ -346,6 +353,7 @@ private static Void checkSecurityPermission() {
}
return null;
}
+/*[ENDIF] JAVA_SPEC_VERSION < 24 */
/**
* Constructs a new instance of this class with the given
@@ -354,12 +362,18 @@ private static Void checkSecurityPermission() {
* @param parentLoader ClassLoader
* the ClassLoader to use as the new class
* loaders parent.
+/*[IF JAVA_SPEC_VERSION < 24]
* @exception SecurityException
* if a security manager exists and it does not
* allow the creation of new ClassLoaders.
+/*[ENDIF] JAVA_SPEC_VERSION < 24
*/
protected ClassLoader(ClassLoader parentLoader) {
+ /*[IF JAVA_SPEC_VERSION >= 24]*/
+ this(null, null, parentLoader);
+ /*[ELSE] JAVA_SPEC_VERSION >= 24 */
this(checkSecurityPermission(), null, parentLoader);
+ /*[ENDIF] JAVA_SPEC_VERSION >= 24 */
}
/*[IF JAVA_SPEC_VERSION >= 9]*/
@@ -374,13 +388,19 @@ protected ClassLoader(ClassLoader parentLoader) {
* loaders parent.
* @exception IllegalArgumentException
* if the name of this class loader is empty.
+/*[IF JAVA_SPEC_VERSION < 24]
* @exception SecurityException
* if a security manager exists and it does not
* allow the creation of new ClassLoaders.
+/*[ENDIF] JAVA_SPEC_VERSION < 24
*@since 9
*/
protected ClassLoader(String classLoaderName, ClassLoader parentLoader) {
+ /*[IF JAVA_SPEC_VERSION >= 24]*/
+ this(null, classLoaderName, parentLoader);
+ /*[ELSE] JAVA_SPEC_VERSION >= 24 */
this(checkSecurityPermission(), classLoaderName, parentLoader);
+ /*[ENDIF] JAVA_SPEC_VERSION >= 24 */
}
/*[ENDIF] JAVA_SPEC_VERSION >= 9 */
diff --git a/jcl/src/java.base/share/classes/java/lang/StackWalker.java b/jcl/src/java.base/share/classes/java/lang/StackWalker.java
index ec1c4f4a736..0473e7c202b 100644
--- a/jcl/src/java.base/share/classes/java/lang/StackWalker.java
+++ b/jcl/src/java.base/share/classes/java/lang/StackWalker.java
@@ -27,7 +27,9 @@
/*[ENDIF] JAVA_SPEC_VERSION >= 10 */
import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleDescriptor.Version;
+/*[IF JAVA_SPEC_VERSION < 24]*/
import java.security.Permission;
+/*[ENDIF] JAVA_SPEC_VERSION < 24 */
import java.util.Collections;
import java.util.List;
import java.util.Objects;
@@ -125,11 +127,13 @@ private StackWalker(
}
if ((flags & J9_RETAIN_CLASS_REFERENCE) != 0) {
+ /*[IF JAVA_SPEC_VERSION < 24]*/
@SuppressWarnings("removal")
SecurityManager securityMgr = System.getSecurityManager();
if (null != securityMgr) {
securityMgr.checkPermission(PermissionSingleton.perm);
}
+ /*[ENDIF] JAVA_SPEC_VERSION < 24 */
/*[IF JAVA_SPEC_VERSION >= 19]*/
this.retainClassRef = true;
} else {
@@ -166,9 +170,11 @@ public static StackWalker getInstance() {
* @param option
* select the type of information to include
* @return StackWalker instance configured with the value of option
+ /*[IF JAVA_SPEC_VERSION < 24]
* @throws SecurityException
* if option is RETAIN_CLASS_REFERENCE and the security manager
* check fails
+ /*[ENDIF] JAVA_SPEC_VERSION < 24
*/
public static StackWalker getInstance(Option option) {
Objects.requireNonNull(option);
@@ -181,9 +187,11 @@ public static StackWalker getInstance(Option option) {
* @param options
* select the types of information to include
* @return StackWalker instance configured with the given options
+ /*[IF JAVA_SPEC_VERSION < 24]
* @throws SecurityException
* if RETAIN_CLASS_REFERENCE is requested and not permitted by
* the security manager
+ /*[ENDIF] JAVA_SPEC_VERSION < 24
*/
public static StackWalker getInstance(Set