Enum ClassLoadingStrategy.Default

java.lang.Object
java.lang.Enum<ClassLoadingStrategy.Default>
net.bytebuddy.dynamic.loading.ClassLoadingStrategy.Default
All Implemented Interfaces:
Serializable, Comparable<ClassLoadingStrategy.Default>, java.lang.constant.Constable, ClassLoadingStrategy<ClassLoader>, ClassLoadingStrategy.Configurable<ClassLoader>
Enclosing interface:
ClassLoadingStrategy<T extends ClassLoader>

public static enum ClassLoadingStrategy.Default extends Enum<ClassLoadingStrategy.Default> implements ClassLoadingStrategy.Configurable<ClassLoader>
This class contains implementations of default class loading strategies.
  • Enum Constant Details

    • WRAPPER

      public static final ClassLoadingStrategy.Default WRAPPER
      This strategy creates a new ByteArrayClassLoader with the given class loader as its parent. The byte array class loader is aware of a any dynamically created type and can natively load the given classes. This allows to load classes with cyclic load-time dependencies since the byte array class loader is queried on each encountered unknown class. Due to the encapsulation of the classes that were loaded by a byte array class loader, this strategy will lead to the unloading of these classes once this class loader, its classes or any instances of these classes become unreachable.
    • WRAPPER_PERSISTENT

      public static final ClassLoadingStrategy.Default WRAPPER_PERSISTENT
      The strategy is identical to WRAPPER but exposes the byte arrays that represent a class by ClassLoader.getResourceAsStream(String). For this purpose, all class files are persisted as byte arrays withing the wrapping class loader.
    • CHILD_FIRST

      public static final ClassLoadingStrategy.Default CHILD_FIRST

      The child-first class loading strategy is a modified version of the WRAPPER where the dynamic types are given priority over any types of a parent class loader with the same name.

      Important: This does not replace a type of the same name, but it makes the type invisible by the reach of this class loader.

    • CHILD_FIRST_PERSISTENT

      public static final ClassLoadingStrategy.Default CHILD_FIRST_PERSISTENT
      The strategy is identical to CHILD_FIRST but exposes the byte arrays that represent a class by ClassLoader.getResourceAsStream(String). For this purpose, all class files are persisted as byte arrays withing the wrapping class loader.
    • INJECTION

      public static final ClassLoadingStrategy.Default INJECTION

      This strategy does not create a new class loader but injects all classes into the given ClassLoader by reflective access. This prevents the loading of classes with cyclic load-time dependencies but avoids the creation of an additional class loader. The advantage of this strategy is that the loaded classes will have package-private access to other classes within their package of the class loader into which they are injected what is not permitted when the wrapper class loader is used. This strategy is implemented using a ClassInjector.UsingReflection. Note that this strategy usually yields a better runtime performance.

      Important: Class injection requires access to JVM internal methods that are sealed by security managers and the Java Platform module system. Since Java 11, access to these methods is no longer feasible unless those packages are explicitly opened.

      Note: This class loader does not define packages for injected classes by default. Therefore, calls to Class.getPackage() might return null. Packages are only defined manually by a class loader prior to Java 9.

  • Field Details

  • Constructor Details

  • Method Details