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 interface
A dispatcher to representjava.lang.constant.ConstantDesc
.protected static class
Represents a trivial constant value that represents itself.protected static class
Represents 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.OfClassDesc
A dispatcher for interaction withjava.lang.constant.ClassDesc
.protected static final JavaConstant.Simple.Dispatcher
A dispatcher for interaction withjava.lang.constant.ClassDesc
.protected static final JavaConstant.Simple.Dispatcher.OfDirectMethodHandleDesc
A dispatcher for interaction withjava.lang.constant.DirectMethodHandleDesc
.protected static final JavaConstant.Simple.Dispatcher.OfDirectMethodHandleDesc.ForKind
A dispatcher for interaction withjava.lang.constant.DirectMethodHandleDesc
.protected static final JavaConstant.Simple.Dispatcher.OfDynamicConstantDesc
A dispatcher for interaction withjava.lang.constant.DirectMethodHandleDesc
.protected static final JavaConstant.Simple.Dispatcher.OfMethodHandleDesc
A dispatcher for interaction withjava.lang.constant.MethodHandleDesc
.protected static final JavaConstant.Simple.Dispatcher.OfMethodTypeDesc
A dispatcher for interaction withjava.lang.constant.MethodTypeDesc
.private final TypeDescription
A description of the type of the constant.protected final T
The represented constant pool value. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Simple
(T value, TypeDescription typeDescription) Creates a simple Java constant. -
Method Summary
Modifier and TypeMethodDescriptionprivate static <T> T
doPrivileged
(PrivilegedAction<T> action) A proxy forjava.security.AccessController#doPrivileged
that is activated if available.boolean
Returns a description of the type of this constant.getValue()
Returns the represented value.int
hashCode()
static JavaConstant
of
(TypeDescription typeDescription) Returns a Java constant representation for aTypeDescription
.static JavaConstant
ofDescription
(Object value, ClassLoader classLoader) Creates a Java constant value from ajava.lang.constant.ConstantDesc
.static JavaConstant
ofDescription
(Object value, ClassFileLocator classFileLocator) Creates a Java constant value from ajava.lang.constant.ConstantDesc
.static JavaConstant
ofDescription
(Object value, TypePool typePool) Creates a Java constant value from ajava.lang.constant.ConstantDesc
.static JavaConstant
Resolves a loaded Java value to a Java constant representation.protected static JavaConstant
ofLoadedOrNull
(Object value) Resolves a loaded Java value to a Java constant representation.toString()
static JavaConstant
Wraps a value representing a loaded or unloaded constant asJavaConstant
instance.static List
<JavaConstant> Wraps a list of either loaded or unloaded constant representations asJavaConstant
instances.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.bytebuddy.utility.ConstantValue
toStackManipulation
Methods 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#doPrivileged
that 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
null
if 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.ConstantDesc
to 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.ConstantDesc
to 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.ConstantDesc
to 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 asJavaConstant
instance.- Parameters:
value
- The value to wrap.- Returns:
- A wrapped Java constant.
-
wrap
Wraps a list of either loaded or unloaded constant representations asJavaConstant
instances.- 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:
getTypeDescription
in interfaceConstantValue
- Returns:
- A description of the type of this constant.
-
hashCode
public int hashCode() -
equals
-
toString
-