public class ClassLoaderForClassArtifacts
extends ClassLoader
A specialized ClassLoader used to define per-class artifact classes such as generated meta-method dispatchers.
Since Groovy 6.0 this loader first attempts to define each artifact as a hidden nestmate of the target via HiddenClassDefiner.tryDefineNestmate. When that soft-fails (unopened package, unsuitable host, …) it falls back to ClassLoader.defineClass with the protection domain captured at construction. Module / nest-host policy is documented on HiddenClassDefiner.
| Modifiers | Name | Description |
|---|---|---|
SoftReference<Class> |
klazz |
Soft reference to the class for which artifacts are generated. |
| Constructor and description |
|---|
ClassLoaderForClassArtifacts(Class klazz)Creates a new artifact class loader for the specified class. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public String |
createClassName(Method method)Generates a unique class name for an artifact associated with the given method. |
|
public String |
createClassName(String methodName)Generates a unique class name for an artifact associated with the given method name. |
|
public Class |
define(String name, byte[] bytes)Defines a class from bytecode, preferring a hidden nestmate of the target. |
|
public Constructor |
defineClassAndGetConstructor(String name, byte[] bytes, Class<?> parameterTypes)Defines a class from bytecode and returns the public constructor matching the given parameter types, or null if definition or
lookup fails. |
|
public Class |
loadClass(String name)Loads the class with the specified binary name. This method searches for classes in the same manner as the loadClass(String, boolean) method. It is invoked by the Java virtual machine to resolve class references. Invoking this method is equivalent to invoking loadClass(name,.
|
| Methods inherited from class | Name |
|---|---|
class ClassLoader |
clearAssertionStatus, equals, getClass, getDefinedPackage, getDefinedPackages, getName, getParent, getPlatformClassLoader, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, hashCode, isRegisteredAsParallelCapable, loadClass, notify, notifyAll, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, toString, wait, wait, wait |
Soft reference to the class for which artifacts are generated.
Creates a new artifact class loader for the specified class.
klazz - the class whose artifact classes are to be defined via this loaderGenerates a unique class name for an artifact associated with the given method.
method - the method for which the artifact is generatedGenerates a unique class name for an artifact associated with the given method name.
For classes in the java.* package hierarchy the name is
prefixed to avoid the restricted java. namespace. The counter
suffix ensures uniqueness when multiple artifacts share the same logical
name.
methodName - the method name component of the artifact class nameDefines a class from bytecode, preferring a hidden nestmate of the target.
name - the binary name used for the fallback (visible-class) pathbytes - the class-file bytes Defines a class from bytecode and returns the public constructor
matching the given parameter types, or null if definition or
lookup fails.
Uses Class.getConstructor so the returned constructor is always publicly accessible (same contract as before hidden-class support).
name - the binary name (for fallback visible-class definition)bytes - the class-file bytesparameterTypes - the constructor parameter types to look upnullLoads the class with the specified binary name. This method searches for classes in the same manner as the loadClass(String, boolean) method. It is invoked by the Java virtual machine to resolve class references. Invoking this method is equivalent to invoking loadClass(name,.
name
- The binary name of the classClass objectCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.