Class ClassInjector.UsingLookup
java.lang.Object
net.bytebuddy.dynamic.loading.ClassInjector.AbstractBase
net.bytebuddy.dynamic.loading.ClassInjector.UsingLookup
- All Implemented Interfaces:
ClassInjector
- Enclosing interface:
ClassInjector
A class injector that uses a java.lang.invoke.MethodHandles$Lookup object for defining a class.
Important: This functionality is only available starting from Java 9.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceA dispatcher forjava.lang.invoke.MethodHandles.Nested classes/interfaces inherited from interface ClassInjector
ClassInjector.AbstractBase, ClassInjector.UsingInstrumentation, ClassInjector.UsingJna, ClassInjector.UsingLookup, ClassInjector.UsingReflection, ClassInjector.UsingUnsafe -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ObjectThejava.lang.invoke.MethodHandles$Lookupto use.private static final ClassInjector.UsingLookup.MethodHandlesThe dispatcher to interacting with instances ofjava.lang.invoke.MethodHandles.private static final ClassInjector.UsingLookup.MethodHandles.LookupThe dispatcher to interacting withjava.lang.invoke.MethodHandles$Lookup.private static final intIndicates a lookup instance's package lookup mode.Fields inherited from class ClassInjector.AbstractBase
SUPPRESS_ACCESS_CHECKSFields inherited from interface ClassInjector
ALLOW_EXISTING_TYPES -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedUsingLookup(Object lookup) Creates a new class injector using a lookup instance. -
Method Summary
Modifier and TypeMethodDescriptionprivate static <T> TdoPrivileged(PrivilegedAction<T> action) A proxy forjava.security.AccessController#doPrivilegedthat is activated if available.Resolves this injector to use the supplied type's scope.injectRaw(Set<String> names, ClassFileLocator classFileLocator) Injects the given types into the represented class loader.booleanisAlive()Indicates if this class injector is available on the current VM.static booleanChecks if the current VM is capable of defining classes using a method handle lookup.Class<?> Returns the lookup type this injector is based upon.static ClassInjector.UsingLookupCreates class injector that defines a class using a method handle lookup.Methods inherited from class ClassInjector.AbstractBase
inject, inject, injectRaw
-
Field Details
-
METHOD_HANDLES
The dispatcher to interacting with instances ofjava.lang.invoke.MethodHandles. -
METHOD_HANDLES_LOOKUP
The dispatcher to interacting withjava.lang.invoke.MethodHandles$Lookup. -
PACKAGE_LOOKUP
private static final int PACKAGE_LOOKUPIndicates a lookup instance's package lookup mode.- See Also:
-
lookup
Thejava.lang.invoke.MethodHandles$Lookupto use.
-
-
Constructor Details
-
UsingLookup
Creates a new class injector using a lookup instance.- Parameters:
lookup- Thejava.lang.invoke.MethodHandles$Lookupinstance to use.
-
-
Method Details
-
doPrivileged
A proxy forjava.security.AccessController#doPrivilegedthat is activated if available.- Type Parameters:
T- The type of the action's resolved value.- Parameters:
action- The action to execute from a privileged context.- Returns:
- The action's resolved value.
-
of
Creates class injector that defines a class using a method handle lookup.- Parameters:
lookup- Thejava.lang.invoke.MethodHandles$Lookupinstance to use.- Returns:
- An appropriate class injector.
-
lookupType
Returns the lookup type this injector is based upon.- Returns:
- The lookup type.
-
in
Resolves this injector to use the supplied type's scope.- Parameters:
type- The type to resolve the access scope for.- Returns:
- An new injector with the specified scope.
-
isAlive
public boolean isAlive()Indicates if this class injector is available on the current VM.- Returns:
trueif this injector is available on the current VM.
-
injectRaw
Injects the given types into the represented class loader.- Parameters:
names- The names of the types to load via injection.classFileLocator- The class file locator to use for resolving binary representations.- Returns:
- The loaded types that were passed as arguments.
-
isAvailable
public static boolean isAvailable()Checks if the current VM is capable of defining classes using a method handle lookup.- Returns:
trueif the current VM is capable of defining classes using a lookup.
-