This nexus is a global dispatcher for initializing classes with
org.s. To do so, this class is to be loaded
by the system class loader in an explicit manner. Any instrumented class is then injected a code
block into its static type initializer that makes a call to this very same nexus which had the
loaded type initializer registered before hand.
Note
Availability of the Nexus class and its injection into the system class loader
can be disabled entirely by setting the Nexus#PROPERTY system property to false.
Important Note
The nexus must never be accessed directly but only by the NexusAccessor
which makes sure that the nexus is loaded by the system class loader. Otherwise, a class might not
be able to initialize itself if it is loaded by different class loader that does not have the
system class loader in its hierarchy.
| Modifier and Type | Field and Description |
|---|---|
| private final int | classLoaderHashCode
The class loader's hash code upon registration. |
| private final int | identification
A random value that uniquely identifies a Nexus entry in order to avoid conflicts when applying the self-initialization strategy in multiple transformations. |
| private final String | name
The name of a type for which a loaded type initializer is registered. |
| private static final ReferenceQueue | NO_QUEUE
An type-safe constant for a non-operational reference queue. |
| public static final String | |
| private static final ConcurrentMap | TYPE_INITIALIZERS
A map of keys identifying a loaded type by its name and class loader mapping their
potential |
| Access | Constructor and Description |
|---|---|
| private | |
| private | Nexus(String
The name of a type for which a loaded type initializer is registered. name, ClassLoader The class loader for which a loaded type initializer is registered. classLoader, ReferenceQueue<? super ClassLoader> The reference queue to notify upon the class loader's collection or referenceQueue, int null if no queue should be notified.An identification for the initializer to run. identification)Creates a key for identifying a loaded type initializer. |
| Modifier and Type | Method and Description |
|---|---|
| public static void | clean(Reference<? super ClassLoader>
The stale reference to clean. reference)Cleans any stale entries from this nexus. |
| public boolean | equals(Object
the reference object with which to compare. other)Overrides java. |
| public int | |
| public static void | initialize(Class<?>
The loaded type to initialize. type, int An identification for the initializer to run. identification)Initializes a loaded type. |
| private static String | Returns: The non-anonymous name of the given class.The name as returned by typeName)Class#getName().Normalizes a type name if it is loaded by an anonymous class loader. |
| public static void | register(String
The name of the type for the loaded type initializer. name, ClassLoader The class loader of the type for the loaded type initializer. classLoader, ReferenceQueue<? super ClassLoader> The reference queue to notify upon the class loader's collection which will be enqueued a reference which can be
handed to referenceQueue, int Nexus#clean(Reference) or null if no reference queue should be notified.An identification for the initializer to run. identification, Object The type initializer to register. The initializer must be an instance
of typeInitializer)org. where
it does however not matter which class loader loaded this latter type.Registers a new loaded type initializer. |
| public String |
| classLoaderHashCode | back to summary |
|---|---|
| private final int classLoaderHashCode The class loader's hash code upon registration. | |
| identification | back to summary |
|---|---|
| private final int identification A random value that uniquely identifies a Nexus entry in order to avoid conflicts when applying the self-initialization strategy in multiple transformations. | |
| name | back to summary |
|---|---|
| private final String name The name of a type for which a loaded type initializer is registered. | |
| NO_QUEUE | back to summary |
|---|---|
| private static final ReferenceQueue<ClassLoader> NO_QUEUE An type-safe constant for a non-operational reference queue. | |
| PROPERTY | back to summary |
|---|---|
| public static final String PROPERTY A system property that allows to disable the use of the | |
| TYPE_INITIALIZERS | back to summary |
|---|---|
| private static final ConcurrentMap<Nexus, Object> TYPE_INITIALIZERS A map of keys identifying a loaded type by its name and class loader mapping their
potential | |
| Nexus | back to summary |
|---|---|
| private Nexus(Class<?> type, int identification) Creates a key for identifying a loaded type initializer.
| |
| Nexus | back to summary |
|---|---|
| private Nexus(String name, ClassLoader classLoader, ReferenceQueue<? super ClassLoader> referenceQueue, int identification) Creates a key for identifying a loaded type initializer.
| |
| clean | back to summary |
|---|---|
| public static void clean(Reference<? super ClassLoader> reference) Cleans any stale entries from this nexus. Entries are considered stale if their class loader was collected before a class was initialized. Important Note This method must never be called directly but only by using a
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| initialize | back to summary |
|---|---|
| public static void initialize(Class<?> type, int identification) throws Exception Initializes a loaded type. This method must only be invoked via the system class loader. Important Note This method must never be called directly but only by using a
| |
| nonAnonymous | back to summary |
|---|---|
| private static String nonAnonymous(String typeName) Normalizes a type name if it is loaded by an anonymous class loader.
| |
| register | back to summary |
|---|---|
| public static void register(String name, ClassLoader classLoader, ReferenceQueue<? super ClassLoader> referenceQueue, int identification, Object typeInitializer) Registers a new loaded type initializer. Important Note This method must never be called directly but only by using a
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |