Class NexusAccessor
java.lang.Object
net.bytebuddy.dynamic.NexusAccessor
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new accessor for theNexuswithout any active management of stale references within a nexus.NexusAccessor(ReferenceQueue<? super ClassLoader> referenceQueue) Creates a new accessor for aNexuswhere any GC eligible are enqueued to the supplied reference queue. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclean(Reference<? extends ClassLoader> reference) Removes a stale entries that are registered in theNexus.static booleanisAlive()Checks if thisNexusAccessoris capable of registering loaded type initializers.voidregister(String name, ClassLoader classLoader, int identification, LoadedTypeInitializer loadedTypeInitializer) Registers a loaded type initializer in Byte Buddy'sNexuswhich is injected into the system class loader.
-
Constructor Details
-
NexusAccessor
public NexusAccessor()Creates a new accessor for theNexuswithout any active management of stale references within a nexus. -
NexusAccessor
Creates a new accessor for aNexuswhere any GC eligible are enqueued to the supplied reference queue. Any such enqueued reference can be explicitly removed from the nexus via theclean(Reference)method. Nexus entries can become stale if a class loader is garbage collected after a class was loaded but before a class was initialized.- Parameters:
referenceQueue- The reference queue onto which stale references should be enqueued ornullif no reference queue should be notified.
-
-
Method Details
-
isAlive
public static boolean isAlive()Checks if thisNexusAccessoris capable of registering loaded type initializers.- Returns:
trueif this accessor is alive.
-
clean
Removes a stale entries that are registered in theNexus. Entries can become stale if a class is loaded but never initialized prior to its garbage collection. As all class loaders within a nexus are only referenced weakly, such class loaders are always garbage collected. However, the initialization data stored by Byte Buddy does not become eligible which is why it needs to be cleaned explicitly.- Parameters:
reference- The reference to remove. References are collected via a reference queue that is supplied to theNexusAccessor.
-
register
public void register(String name, @MaybeNull ClassLoader classLoader, int identification, LoadedTypeInitializer loadedTypeInitializer) Registers a loaded type initializer in Byte Buddy'sNexuswhich is injected into the system class loader.
-