Class SharedClassProviderImpl
- All Implemented Interfaces:
com.ibm.sharedclasses.spi.SharedClassProvider
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreatePermission
(String classLoaderClassName, String actions) Constructs a new instance of SharedClassPermission which is a sub-class of BasicPermission.byte[]
findSharedClassURL
(URL path, String className) Finds a class in the shared cache by using a specific URL and class name.byte[]
findSharedClassURLClasspath
(String className, IntConsumer indexConsumer) Finds a class in the shared cache by using the class name given (implicitly using the caller's classpath).long
Returns the size of the cache that the JVM is currently connected to.long
Returns the free space in bytes of the cache that the JVM is currently connected to.long
Returns the maximum space allowed for AOT data of the cache that the JVM is currently connected to.long
Returns the maximum space allowed for JIT data of the cache that the JVM is currently connected to.long
Returns the minimum space reserved for AOT data of the cache that the JVM is currently connected to.long
Returns the minimum space reserved for JIT data of the cache that the JVM is currently connected to.long
Returns the soft limit in bytes for the available space of the cache that the JVM is currently connected to.com.ibm.sharedclasses.spi.SharedClassProvider
initializeProvider
(ClassLoader loader, URL[] classpath) Initializes a SharedClassProvider.com.ibm.sharedclasses.spi.SharedClassProvider
initializeProvider
(ClassLoader loader, URL[] classpath, boolean urlHelper, boolean tokenHelper) Initializes a SharedClassProvider.boolean
Checks whether shared classes are enabled for this JVM.boolean
setURLClasspath
(URL[] newClasspath) Updates the URLClasspath helper's classpath with a new classpath.boolean
storeSharedClassURL
(URL path, Class<?> clazz) Stores a class in the shared cache by using the URL location it was loaded from.boolean
storeSharedClassURLClasspath
(Class<?> clazz, int foundAtIndex) Stores a class in the shared cache by using the caller's URL classpath.
-
Constructor Details
-
SharedClassProviderImpl
public SharedClassProviderImpl()
-
-
Method Details
-
initializeProvider
public com.ibm.sharedclasses.spi.SharedClassProvider initializeProvider(ClassLoader loader, URL[] classpath) Description copied from interface:com.ibm.sharedclasses.spi.SharedClassProvider
Initializes a SharedClassProvider.
- Specified by:
initializeProvider
in interfacecom.ibm.sharedclasses.spi.SharedClassProvider
- Parameters:
loader
- ClassLoader The ClassLoader that uses SharedClassProvider.classpath
- URL[] The current URL classpath array of the ClassLoader.- Returns:
- SharedClassProvider A SharedClassProvider if it is successfully initialized, or null otherwise.
-
initializeProvider
public com.ibm.sharedclasses.spi.SharedClassProvider initializeProvider(ClassLoader loader, URL[] classpath, boolean urlHelper, boolean tokenHelper) Description copied from interface:com.ibm.sharedclasses.spi.SharedClassProvider
Initializes a SharedClassProvider.
- Specified by:
initializeProvider
in interfacecom.ibm.sharedclasses.spi.SharedClassProvider
- Parameters:
loader
- ClassLoader The ClassLoader that uses SharedClassProvider.classpath
- URL[] The current URL classpath array of the ClassLoader.urlHelper
- True if a SharedClassURLHelper needs to be created for this class loader, false otherwise.tokenHelper
- True if a SharedClassTokenHelper needs to be created for this class loader, false otherwise.- Returns:
- SharedClassProvider A SharedClassProvider if it is successfully initialized, or null otherwise.
-
setURLClasspath
Description copied from interface:com.ibm.sharedclasses.spi.SharedClassProvider
Updates the URLClasspath helper's classpath with a new classpath.
This function is useful for ClassLoaders that compute their classpath lazily. The initial classpath is passed to the constructor optimistically, but if the classloader discovers a change while reading an entry, it can update the classpath by using this function.
Note: It is essential that the helper's classpath is kept up-to-date with the classloader.
The classpath that is passed to this function must be exactly the same as the original classpath up to and including the right-most entry that classes have been loaded from (the right-most
confirmed
entry).After the classpath has been updated, any indexes passed to storeSharedClassURLClasspath and returned from findSharedClassURLClasspath correspond to the new classpath.
- Specified by:
setURLClasspath
in interfacecom.ibm.sharedclasses.spi.SharedClassProvider
- Parameters:
newClasspath
- The new URL classpath array- Returns:
- boolean. True if the classpath has been set, false otherwise.
-
getCacheSize
public long getCacheSize()Description copied from interface:com.ibm.sharedclasses.spi.SharedClassProvider
Returns the size of the cache that the JVM is currently connected to.
- Specified by:
getCacheSize
in interfacecom.ibm.sharedclasses.spi.SharedClassProvider
- Returns:
- long. The total size in bytes of the shared cache.
-
getSoftmxBytes
public long getSoftmxBytes()Description copied from interface:com.ibm.sharedclasses.spi.SharedClassProvider
Returns the soft limit in bytes for the available space of the cache that the JVM is currently connected to.
- Specified by:
getSoftmxBytes
in interfacecom.ibm.sharedclasses.spi.SharedClassProvider
- Returns:
- long. The soft max size or cache size in bytes if it is not set.
-
getMinAotBytes
public long getMinAotBytes()Description copied from interface:com.ibm.sharedclasses.spi.SharedClassProvider
Returns the minimum space reserved for AOT data of the cache that the JVM is currently connected to.
- Specified by:
getMinAotBytes
in interfacecom.ibm.sharedclasses.spi.SharedClassProvider
- Returns:
- long. The minimum shared classes cache space reserved for AOT data in bytes or -1 if it is not set.
-
getMaxAotBytes
public long getMaxAotBytes()Description copied from interface:com.ibm.sharedclasses.spi.SharedClassProvider
Returns the maximum space allowed for AOT data of the cache that the JVM is currently connected to.
- Specified by:
getMaxAotBytes
in interfacecom.ibm.sharedclasses.spi.SharedClassProvider
- Returns:
- long. The maximum shared classes cache space allowed for AOT data in bytes or -1 if it is not set.
-
getMinJitDataBytes
public long getMinJitDataBytes()Description copied from interface:com.ibm.sharedclasses.spi.SharedClassProvider
Returns the minimum space reserved for JIT data of the cache that the JVM is currently connected to.
- Specified by:
getMinJitDataBytes
in interfacecom.ibm.sharedclasses.spi.SharedClassProvider
- Returns:
- long. The minimum shared classes cache space reserved for JIT data in bytes or -1 if it is not set.
-
getMaxJitDataBytes
public long getMaxJitDataBytes()Description copied from interface:com.ibm.sharedclasses.spi.SharedClassProvider
Returns the maximum space allowed for JIT data of the cache that the JVM is currently connected to.
- Specified by:
getMaxJitDataBytes
in interfacecom.ibm.sharedclasses.spi.SharedClassProvider
- Returns:
- long. The maximum shared classes cache space allowed for JIT data in bytes or -1 if it is not set.
-
getFreeSpace
public long getFreeSpace()Description copied from interface:com.ibm.sharedclasses.spi.SharedClassProvider
Returns the free space in bytes of the cache that the JVM is currently connected to.
- Specified by:
getFreeSpace
in interfacecom.ibm.sharedclasses.spi.SharedClassProvider
- Returns:
- long. The free space of the shared classes cache.
-
createPermission
Description copied from interface:com.ibm.sharedclasses.spi.SharedClassProvider
Constructs a new instance of SharedClassPermission which is a sub-class of BasicPermission.
- Specified by:
createPermission
in interfacecom.ibm.sharedclasses.spi.SharedClassProvider
- Parameters:
classLoaderClassName
- java.lang.String. The class name of the class loader requiring the permission.actions
- java.lang.String. The actions which are applicable to it.- Returns:
- BasicPermission. A new instance of SharedClassPermission which is a sub-class of BasicPermission, or null if shared classes are not enabled.