Package net.bytebuddy.utility
Class JavaConstant.Simple<T>
java.lang.Object
net.bytebuddy.utility.JavaConstant.Simple<T>
- Type Parameters:
T- The represented type.
- All Implemented Interfaces:
ConstantValue,JavaConstant
- Direct Known Subclasses:
JavaConstant.Simple.OfTrivialValue,JavaConstant.Simple.OfTypeDescription
- Enclosing interface:
JavaConstant
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceA dispatcher to representjava.lang.constant.ConstantDesc.protected static classRepresents a trivial constant value that represents itself.protected static classRepresents a type constant.Nested classes/interfaces inherited from interface net.bytebuddy.utility.JavaConstant
JavaConstant.Dynamic, JavaConstant.MethodHandle, JavaConstant.MethodType, JavaConstant.Simple<T>, JavaConstant.Visitor<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final JavaConstant.Simple.Dispatcher.OfClassDescA dispatcher for interaction withjava.lang.constant.ClassDesc.protected static final JavaConstant.Simple.DispatcherA dispatcher for interaction withjava.lang.constant.ClassDesc.protected static final JavaConstant.Simple.Dispatcher.OfDirectMethodHandleDescA dispatcher for interaction withjava.lang.constant.DirectMethodHandleDesc.protected static final JavaConstant.Simple.Dispatcher.OfDirectMethodHandleDesc.ForKindA dispatcher for interaction withjava.lang.constant.DirectMethodHandleDesc.protected static final JavaConstant.Simple.Dispatcher.OfDynamicConstantDescA dispatcher for interaction withjava.lang.constant.DirectMethodHandleDesc.protected static final JavaConstant.Simple.Dispatcher.OfMethodHandleDescA dispatcher for interaction withjava.lang.constant.MethodHandleDesc.protected static final JavaConstant.Simple.Dispatcher.OfMethodTypeDescA dispatcher for interaction withjava.lang.constant.MethodTypeDesc.private final TypeDescriptionA description of the type of the constant.protected final TThe represented constant pool value. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSimple(T value, TypeDescription typeDescription) Creates a simple Java constant. -
Method Summary
Modifier and TypeMethodDescriptionprivate static <T> TdoPrivileged(PrivilegedAction<T> action) A proxy forjava.security.AccessController#doPrivilegedthat is activated if available.booleanReturns a description of the type of this constant.getValue()Returns the represented value.inthashCode()static JavaConstantof(TypeDescription typeDescription) Returns a Java constant representation for aTypeDescription.static JavaConstantofDescription(Object value, ClassLoader classLoader) Creates a Java constant value from ajava.lang.constant.ConstantDesc.static JavaConstantofDescription(Object value, ClassFileLocator classFileLocator) Creates a Java constant value from ajava.lang.constant.ConstantDesc.static JavaConstantofDescription(Object value, TypePool typePool) Creates a Java constant value from ajava.lang.constant.ConstantDesc.static JavaConstantResolves a loaded Java value to a Java constant representation.protected static JavaConstantofLoadedOrNull(Object value) Resolves a loaded Java value to a Java constant representation.toString()static JavaConstantWraps a value representing a loaded or unloaded constant asJavaConstantinstance.static List<JavaConstant> Wraps a list of either loaded or unloaded constant representations asJavaConstantinstances.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.bytebuddy.utility.ConstantValue
toStackManipulationMethods inherited from interface net.bytebuddy.utility.JavaConstant
accept, toDescription
-
Field Details
-
CONSTANT_DESC
A dispatcher for interaction withjava.lang.constant.ClassDesc. -
CLASS_DESC
A dispatcher for interaction withjava.lang.constant.ClassDesc. -
METHOD_TYPE_DESC
A dispatcher for interaction withjava.lang.constant.MethodTypeDesc. -
METHOD_HANDLE_DESC
A dispatcher for interaction withjava.lang.constant.MethodHandleDesc. -
DIRECT_METHOD_HANDLE_DESC
protected static final JavaConstant.Simple.Dispatcher.OfDirectMethodHandleDesc DIRECT_METHOD_HANDLE_DESCA dispatcher for interaction withjava.lang.constant.DirectMethodHandleDesc. -
DIRECT_METHOD_HANDLE_DESC_KIND
protected static final JavaConstant.Simple.Dispatcher.OfDirectMethodHandleDesc.ForKind DIRECT_METHOD_HANDLE_DESC_KINDA dispatcher for interaction withjava.lang.constant.DirectMethodHandleDesc. -
DYNAMIC_CONSTANT_DESC
A dispatcher for interaction withjava.lang.constant.DirectMethodHandleDesc. -
value
The represented constant pool value. -
typeDescription
A description of the type of the constant.
-
-
Constructor Details
-
Simple
Creates a simple Java constant.- Parameters:
value- The represented constant pool value.typeDescription- A description of the type of the constant.
-
-
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.
-
ofLoaded
Resolves a loaded Java value to a Java constant representation.- Parameters:
value- The value to represent.- Returns:
- An appropriate Java constant representation.
-
ofLoadedOrNull
Resolves a loaded Java value to a Java constant representation.- Parameters:
value- The value to represent.- Returns:
- An appropriate Java constant representation or
nullif the supplied argument is not a compile-time constant.
-
ofDescription
Creates a Java constant value from ajava.lang.constant.ConstantDesc.- Parameters:
value- Thejava.lang.constant.ConstantDescto represent.classLoader- The class loader to use for resolving type information from the supplied value.- Returns:
- An appropriate Java constant representation.
-
ofDescription
Creates a Java constant value from ajava.lang.constant.ConstantDesc.- Parameters:
value- Thejava.lang.constant.ConstantDescto represent.classFileLocator- The class file locator to use for resolving type information from the supplied value.- Returns:
- An appropriate Java constant representation.
-
ofDescription
Creates a Java constant value from ajava.lang.constant.ConstantDesc.- Parameters:
value- Thejava.lang.constant.ConstantDescto represent.typePool- The type pool to use for resolving type information from the supplied value.- Returns:
- An appropriate Java constant representation.
-
of
Returns a Java constant representation for aTypeDescription.- Parameters:
typeDescription- The type to represent as a constant.- Returns:
- An appropriate Java constant representation.
-
wrap
Wraps a value representing a loaded or unloaded constant asJavaConstantinstance.- Parameters:
value- The value to wrap.- Returns:
- A wrapped Java constant.
-
wrap
Wraps a list of either loaded or unloaded constant representations asJavaConstantinstances.- Parameters:
values- The values to wrap.- Returns:
- A list of wrapped Java constants.
-
getValue
Returns the represented value.- Returns:
- The represented value.
-
getTypeDescription
Returns a description of the type of this constant.- Specified by:
getTypeDescriptionin interfaceConstantValue- Returns:
- A description of the type of this constant.
-
hashCode
public int hashCode() -
equals
-
toString
-