Class SharedClassProviderImpl

java.lang.Object
com.ibm.oti.shared.provider.SharedClassProviderImpl
All Implemented Interfaces:
com.ibm.sharedclasses.spi.SharedClassProvider

public class SharedClassProviderImpl extends Object implements com.ibm.sharedclasses.spi.SharedClassProvider
Implementation of SharedClassProvider.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    createPermission(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.

    Methods declared in class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SharedClassProviderImpl

      public SharedClassProviderImpl()
  • Method Details

    • isSharedClassEnabled

      public boolean isSharedClassEnabled()
      Description copied from interface: com.ibm.sharedclasses.spi.SharedClassProvider

      Checks whether shared classes are enabled for this JVM.

      Specified by:
      isSharedClassEnabled in interface com.ibm.sharedclasses.spi.SharedClassProvider
      Returns:
      boolean True if shared classes are enabled (using -Xshareclasses on the command-line), false otherwise.
    • 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 interface com.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 interface com.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.
    • findSharedClassURL

      public byte[] findSharedClassURL(URL path, String className)
      Description copied from interface: com.ibm.sharedclasses.spi.SharedClassProvider

      Finds a class in the shared cache by using a specific URL and class name. A class will be returned if it was stored against the same URL.

      Null is returned if the class cannot be found or if it is stale (see Dynamic cache updates).

      To obtain an instance of the class, the byte[] returned must be passed to defineClass by the caller ClassLoader.

      Specified by:
      findSharedClassURL in interface com.ibm.sharedclasses.spi.SharedClassProvider
      Parameters:
      path - URL. A URL path. Cannot be null.
      className - String. The name of the class to be found
      Returns:
      byte[]. A byte array describing the class found, or null.
    • storeSharedClassURL

      public boolean storeSharedClassURL(URL path, Class<?> clazz)
      Description copied from interface: com.ibm.sharedclasses.spi.SharedClassProvider

      Stores a class in the shared cache by using the URL location it was loaded from. The class that is being stored must have been defined by the caller ClassLoader and must exist in the URL location specified. Returns true if the class is stored successfully or false otherwise.

      Will return false if the class that is being stored was not defined by the caller ClassLoader.

      Also returns false if the URL is not a file URL or if the resource it refers to does not exist.

      Specified by:
      storeSharedClassURL in interface com.ibm.sharedclasses.spi.SharedClassProvider
      Parameters:
      path - URL. The URL path that the class was loaded from. Cannot be null.
      clazz - Class. The class to store in the shared cache
      Returns:
      boolean. True if the class was stored successfully, false otherwise.
    • findSharedClassURLClasspath

      public byte[] findSharedClassURLClasspath(String className, IntConsumer indexConsumer)
      Description copied from interface: com.ibm.sharedclasses.spi.SharedClassProvider

      Finds a class in the shared cache by using the class name given (implicitly using the caller's classpath).

      See Using classpaths for rules on when a class will be found.
      Null is returned if the class cannot be found, if it is stale (see Dynamic cache updates) or if it is found for an unconfirmed entry (see Using classpaths).

      Specified by:
      findSharedClassURLClasspath in interface com.ibm.sharedclasses.spi.SharedClassProvider
      Parameters:
      className - String. The name of the class to be found
      indexConsumer - IntConsumer. The consumer used to receive the classpath index if desired.
      Returns:
      byte[]. A byte array describing the class found, or null.
    • storeSharedClassURLClasspath

      public boolean storeSharedClassURLClasspath(Class<?> clazz, int foundAtIndex)
      Description copied from interface: com.ibm.sharedclasses.spi.SharedClassProvider

      Stores a class in the shared cache by using the caller's URL classpath.

      The class being stored must have been defined by the caller ClassLoader and must exist in the URL location specified.

      Returns true if the class is stored successfully or false otherwise.

      Will return false if the class being stored was not defined by the caller ClassLoader.

      Also returns false if the URL at foundAtIndex is not a file URL or if the resource it refers to does not exist.

      Specified by:
      storeSharedClassURLClasspath in interface com.ibm.sharedclasses.spi.SharedClassProvider
      Parameters:
      clazz - Class. The class to store in the shared cache
      foundAtIndex - int. The index in the caller's classpath where the class was loaded from (first entry is 0).
      Returns:
      boolean. True if the class was stored successfully, false otherwise.
    • setURLClasspath

      public boolean setURLClasspath(URL[] newClasspath)
      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 interface com.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 interface com.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 interface com.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 interface com.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 interface com.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 interface com.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 interface com.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 interface com.ibm.sharedclasses.spi.SharedClassProvider
      Returns:
      long. The free space of the shared classes cache.
    • createPermission

      public BasicPermission createPermission(String classLoaderClassName, String actions)
      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 interface com.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.