diff --git a/jcl/src/java.base/share/classes/com/ibm/sharedclasses/spi/SharedClassProvider.java b/jcl/src/java.base/share/classes/com/ibm/sharedclasses/spi/SharedClassProvider.java index 012401189fa..432ecde7475 100644 --- a/jcl/src/java.base/share/classes/com/ibm/sharedclasses/spi/SharedClassProvider.java +++ b/jcl/src/java.base/share/classes/com/ibm/sharedclasses/spi/SharedClassProvider.java @@ -23,7 +23,9 @@ package com.ibm.sharedclasses.spi; import java.net.URL; +/*[IF JAVA_SPEC_VERSION < 24]*/ import java.security.BasicPermission; +/*[ENDIF] JAVA_SPEC_VERSION < 24 */ import java.util.function.IntConsumer; /** @@ -216,6 +218,7 @@ public interface SharedClassProvider { */ public long getFreeSpace(); + /*[IF JAVA_SPEC_VERSION < 24]*/ /** *
Constructs a new instance of SharedClassPermission which is a sub-class of BasicPermission.
* @@ -227,4 +230,5 @@ public interface SharedClassProvider { * A new instance of SharedClassPermission which is a sub-class of BasicPermission, or null if shared classes are not enabled. */ public BasicPermission createPermission(String classLoaderClassName, String actions); + /*[ENDIF] JAVA_SPEC_VERSION < 24 */ } diff --git a/jcl/src/java.management/share/classes/com/ibm/java/lang/management/internal/MemoryMXBeanImpl.java b/jcl/src/java.management/share/classes/com/ibm/java/lang/management/internal/MemoryMXBeanImpl.java index 082d26b89a2..1fca0403866 100644 --- a/jcl/src/java.management/share/classes/com/ibm/java/lang/management/internal/MemoryMXBeanImpl.java +++ b/jcl/src/java.management/share/classes/com/ibm/java/lang/management/internal/MemoryMXBeanImpl.java @@ -41,7 +41,9 @@ /*[IF JAVA_SPEC_VERSION >= 9]*/ import com.ibm.sharedclasses.spi.SharedClassProvider; import java.net.URL; +/*[IF JAVA_SPEC_VERSION < 24]*/ import java.security.BasicPermission; +/*[ENDIF] JAVA_SPEC_VERSION < 24 */ import java.util.ServiceLoader; import java.util.concurrent.atomic.AtomicReference; import java.util.function.IntConsumer; @@ -106,10 +108,12 @@ private static final class DisabledSharedClassProvider implements SharedClassPro super(); } + /*[IF JAVA_SPEC_VERSION < 24]*/ @Override public BasicPermission createPermission(String classLoaderClassName, String actions) { return null; } + /*[ENDIF] JAVA_SPEC_VERSION < 24 */ @Override public byte[] findSharedClassURL(URL path, String className) { diff --git a/jcl/src/openj9.sharedclasses/share/classes/com/ibm/oti/shared/SharedAbstractHelper.java b/jcl/src/openj9.sharedclasses/share/classes/com/ibm/oti/shared/SharedAbstractHelper.java index 4243285582f..0a5a6abee30 100644 --- a/jcl/src/openj9.sharedclasses/share/classes/com/ibm/oti/shared/SharedAbstractHelper.java +++ b/jcl/src/openj9.sharedclasses/share/classes/com/ibm/oti/shared/SharedAbstractHelper.java @@ -23,7 +23,9 @@ package com.ibm.oti.shared; import java.lang.ref.WeakReference; +/*[IF JAVA_SPEC_VERSION < 24]*/ import java.security.AccessControlException; +/*[ENDIF] JAVA_SPEC_VERSION < 24 */ import com.ibm.oti.util.Msg; @@ -36,11 +38,12 @@ public abstract class SharedAbstractHelper implements SharedHelper { private Boolean verbose; private WeakReferenceIf a ClassLoader stores multiple versions of the same class by using the same token, only the most recent will be returned by findSharedClass.
*A SharedClassHelper will only allow classes to be stored in the cache which were defined by the ClassLoader that owns the SharedClassHelper.
+/*[IF JAVA_SPEC_VERSION < 24] *If a SecurityManager is installed, SharedClassPermissions must be used to permit read/write access to the shared class cache. * Permissions are granted by ClassLoader classname in the java.policy file and are fixed when the SharedClassHelper is created.
+/*[ENDIF] JAVA_SPEC_VERSION < 24 *Note also that if the createClassLoader RuntimePermission is not granted, ClassLoaders cannot be created, * which in turn means that SharedClassHelpers cannot be created.
*If findSharedClass returns null, then load the class from disk, cache the metadata from the entry anyway, define the class, and store it.
*A SharedClassHelper will only allow classes that were defined by the ClassLoader that owns the SharedClassHelper to be stored in the cache.
+/*[IF JAVA_SPEC_VERSION < 24] *If a SecurityManager is installed, SharedClassPermissions must be used to permit read/write access to the shared class cache. * Permissions are granted by ClassLoader classname in the java.policy file and are fixed when the SharedClassHelper is created.
+/*[ENDIF] JAVA_SPEC_VERSION < 24 *Note also that if the createClassLoader RuntimePermission is not granted, ClassLoaders cannot be created, * which in turn means that SharedClassHelpers cannot be created.
*A SharedClassHelper will only allow classes that were defined by the ClassLoader that owns the SharedClassHelper to be stored in the cache.
+/*[IF JAVA_SPEC_VERSION < 24] *If a SecurityManager is installed, SharedClassPermissions must be used to permit read/write access to the shared class cache. * Permissions are granted by ClassLoader classname in the java.policy file and are fixed when the SharedClassHelper is created.
+/*[ENDIF] JAVA_SPEC_VERSION < 24 *Note also that if the createClassLoader RuntimePermission is not granted, ClassLoaders cannot be created, * which in turn means that SharedClassHelpers cannot be created.
*flags
is not a valid value.
+ /*[IF JAVA_SPEC_VERSION < 24]
* @throws SecurityException
* If a security manager is enabled and the calling thread does not
* have SharedClassesNamedPermission("getSharedCacheInfo")
+ /*[ENDIF] JAVA_SPEC_VERSION < 24
*/
public static ListcacheType
is not a valid value.
+ /*[IF JAVA_SPEC_VERSION < 24]
* @throws SecurityException
* If a security manager is enabled and the calling thread does not
* have SharedClassesNamedPermission("destroySharedCache")
+ /*[ENDIF] JAVA_SPEC_VERSION < 24
*/
public static int destroySharedCache(String cacheDir, int cacheType, String cacheName, boolean useCommandLineValues) {
+ /*[IF JAVA_SPEC_VERSION < 24]*/
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(SharedPermissions.destroySharedCache);
}
+ /*[ENDIF] JAVA_SPEC_VERSION < 24 */
/*
* check if cacheType has a valid value only if we are not using command line values.
diff --git a/jcl/src/openj9.sharedclasses/share/classes/com/ibm/oti/shared/SharedDataHelper.java b/jcl/src/openj9.sharedclasses/share/classes/com/ibm/oti/shared/SharedDataHelper.java
index f2afeb4dcca..ac484e1ee61 100644
--- a/jcl/src/openj9.sharedclasses/share/classes/com/ibm/oti/shared/SharedDataHelper.java
+++ b/jcl/src/openj9.sharedclasses/share/classes/com/ibm/oti/shared/SharedDataHelper.java
@@ -47,7 +47,9 @@
*
* @see SharedHelper
* @see SharedDataHelperFactory
+/*[IF JAVA_SPEC_VERSION < 24]
* @see SharedClassPermission
+/*[ENDIF] JAVA_SPEC_VERSION < 24
*/
public interface SharedDataHelper extends SharedHelper {
@@ -55,8 +57,10 @@ public interface SharedDataHelper extends SharedHelper {
* Find data in the shared cache using a specific token.
* Data will be returned only for an exact String match of the token. Otherwise, null is returned.
* The ByteBuffer returned is read-only and cannot be modified.
+ /*[IF JAVA_SPEC_VERSION < 24]
* If a SecurityManager is installed, findSharedData can only be called by code whose caller-classloader
* has been granted read
permissions to the shared class cache.
+ /*[ENDIF] JAVA_SPEC_VERSION < 24
*
* @param token a token to be used as a key
*
@@ -70,8 +74,10 @@ public interface SharedDataHelper extends SharedHelper {
* If data already exists for the token specified, the old data is marked stale
in the cache and is replaced by the new data.
* If the exact same data already exists in the cache under the same token, the data is not duplicated and the cached version is returned.
* If null is passed as the data argument, the data currently stored against that token is marked stale
and null is returned.
+ /*[IF JAVA_SPEC_VERSION < 24]
* If a SecurityManager is installed, storeSharedData can only be called by code whose caller-classloader
* has been granted write
permissions to the shared class cache.
+ /*[ENDIF] JAVA_SPEC_VERSION < 24
*
* @param token a token to be used as a key
* @param data a ByteBuffer of data to copy to the cache
diff --git a/jcl/src/openj9.sharedclasses/share/classes/com/ibm/oti/shared/SharedDataHelperFactoryImpl.java b/jcl/src/openj9.sharedclasses/share/classes/com/ibm/oti/shared/SharedDataHelperFactoryImpl.java
index e7b5ee4c08f..622d9493980 100644
--- a/jcl/src/openj9.sharedclasses/share/classes/com/ibm/oti/shared/SharedDataHelperFactoryImpl.java
+++ b/jcl/src/openj9.sharedclasses/share/classes/com/ibm/oti/shared/SharedDataHelperFactoryImpl.java
@@ -52,6 +52,11 @@ public SharedDataHelper getDataHelper(ClassLoader owner) {
return (SharedDataHelper)helper;
}
} else {
+ /*[IF JAVA_SPEC_VERSION >= 24]*/
+ SharedDataHelper result = new SharedDataHelperImpl(owner, getNewID());
+ helpers.put(owner, result);
+ return result;
+ /*[ELSE] JAVA_SPEC_VERSION >= 24 */
boolean canFind = canFind(owner);
boolean canStore = canStore(owner);
@@ -60,6 +65,7 @@ public SharedDataHelper getDataHelper(ClassLoader owner) {
helpers.put(owner, result);
return result;
}
+ /*[ENDIF] JAVA_SPEC_VERSION >= 24 */
}
}
return null;
diff --git a/jcl/src/openj9.sharedclasses/share/classes/com/ibm/oti/shared/SharedDataHelperImpl.java b/jcl/src/openj9.sharedclasses/share/classes/com/ibm/oti/shared/SharedDataHelperImpl.java
index d7b4b5c68c1..de649e0572c 100644
--- a/jcl/src/openj9.sharedclasses/share/classes/com/ibm/oti/shared/SharedDataHelperImpl.java
+++ b/jcl/src/openj9.sharedclasses/share/classes/com/ibm/oti/shared/SharedDataHelperImpl.java
@@ -35,9 +35,15 @@
*/
final class SharedDataHelperImpl extends SharedAbstractHelper implements SharedDataHelper {
/* Not public - should only be created by factory */
+ /*[IF JAVA_SPEC_VERSION >= 24]*/
+ SharedDataHelperImpl(ClassLoader loader, int id) {
+ initialize(loader, id);
+ }
+ /*[ELSE] JAVA_SPEC_VERSION >= 24 */
SharedDataHelperImpl(ClassLoader loader, int id, boolean canFind, boolean canStore) {
initialize(loader, id, canFind, canStore);
}
+ /*[ENDIF] JAVA_SPEC_VERSION >= 24 */
private native ByteBuffer findSharedDataImpl(int loaderId, String token);
@@ -51,6 +57,7 @@ public ByteBuffer findSharedData(String token) {
printVerboseInfo(Msg.getString("K059f")); //$NON-NLS-1$
return null;
}
+ /*[IF JAVA_SPEC_VERSION < 24]*/
if (!canFind) {
return null;
}
@@ -59,6 +66,7 @@ public ByteBuffer findSharedData(String token) {
printVerboseError(Msg.getString("K05b5")); //$NON-NLS-1$
return null;
}
+ /*[ENDIF] JAVA_SPEC_VERSION < 24 */
if (token==null) {
/*[MSG "K05b6", "Cannot call findSharedData with null token. Returning null."]*/
printVerboseError(Msg.getString("K05b6")); //$NON-NLS-1$
@@ -75,6 +83,7 @@ public ByteBuffer storeSharedData(String token, ByteBuffer data) {
printVerboseInfo(Msg.getString("K059f")); //$NON-NLS-1$
return null;
}
+ /*[IF JAVA_SPEC_VERSION < 24]*/
if (!canStore) {
return null;
}
@@ -83,6 +92,7 @@ public ByteBuffer storeSharedData(String token, ByteBuffer data) {
printVerboseError(Msg.getString("K05b7")); //$NON-NLS-1$
return null;
}
+ /*[ENDIF] JAVA_SPEC_VERSION < 24 */
if (token==null) {
/*[MSG "K05b8", "Cannot call storeSharedData with null token. Returning null."]*/
printVerboseError(Msg.getString("K05b8")); //$NON-NLS-1$
diff --git a/jcl/src/openj9.sharedclasses/share/classes/com/ibm/oti/shared/provider/SharedClassProviderImpl.java b/jcl/src/openj9.sharedclasses/share/classes/com/ibm/oti/shared/provider/SharedClassProviderImpl.java
index e5bd52cedfe..4d3dbfd3018 100644
--- a/jcl/src/openj9.sharedclasses/share/classes/com/ibm/oti/shared/provider/SharedClassProviderImpl.java
+++ b/jcl/src/openj9.sharedclasses/share/classes/com/ibm/oti/shared/provider/SharedClassProviderImpl.java
@@ -24,14 +24,18 @@
package com.ibm.oti.shared.provider;
import java.net.URL;
+/*[IF JAVA_SPEC_VERSION < 24]*/
import java.security.BasicPermission;
+/*[ENDIF] JAVA_SPEC_VERSION < 24 */
import java.util.function.IntConsumer;
import com.ibm.sharedclasses.spi.SharedClassProvider;
import com.ibm.oti.shared.CannotSetClasspathException;
import com.ibm.oti.shared.HelperAlreadyDefinedException;
import com.ibm.oti.shared.Shared;
import com.ibm.oti.shared.SharedClassHelperFactory;
+/*[IF JAVA_SPEC_VERSION < 24]*/
import com.ibm.oti.shared.SharedClassPermission;
+/*[ENDIF] JAVA_SPEC_VERSION < 24 */
import com.ibm.oti.shared.SharedClassStatistics;
import com.ibm.oti.shared.SharedClassURLClasspathHelper;
import com.ibm.oti.shared.SharedClassURLHelper;
@@ -196,6 +200,7 @@ public long getFreeSpace() {
return 0;
}
}
+ /*[IF JAVA_SPEC_VERSION < 24]*/
@Override
public BasicPermission createPermission(String classLoaderClassName, String actions) {
if (!isSharedClassEnabled()) {
@@ -203,4 +208,5 @@ public BasicPermission createPermission(String classLoaderClassName, String acti
}
return new SharedClassPermission(classLoaderClassName, actions);
}
+ /*[ENDIF] JAVA_SPEC_VERSION < 24 */
}