Package ghidra.pcode.emu.jit
Enum Class JitJvmTypeUtils
- All Implemented Interfaces:
Serializable
,Comparable<JitJvmTypeUtils>
,Constable
Some utilities for generating type signatures, suitable for use with
ClassVisitor.visitField(int, String, String, String, Object)
.
WARNING: It seems to me, the internal representation of signatures as accepted by the ASM API is not fixed from version to version. In the future, these utilities may need to be updated to work with multiple versions, if the representation changes in a newer classfile format. Hopefully, the upcoming classfile API will obviate the need for any of this.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
classToInternalName
(Class<?> cls) Get the internal name of a class as inType.getInternalName(Class)
.static String
rawToInternalName
(Type type) Presume the given type is aClass
and get its internal namestatic String
typeToSignature
(Type type) Get the signature of the given typestatic JitJvmTypeUtils
Returns the enum constant of this class with the specified name.static JitJvmTypeUtils[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.static String
Get the signature of the given wildcard typesig(?) = *
sig(? super MyType) = -sig(MyType)
sig(? extends MyType) = +sig(MyType)
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
classToInternalName
Get the internal name of a class as inType.getInternalName(Class)
.- Parameters:
cls
- the class- Returns:
- the internal name
-
rawToInternalName
Presume the given type is aClass
and get its internal name- Parameters:
type
- the type- Returns:
- the internal name
-
wildToSignature
Get the signature of the given wildcard typesig(?) = *
sig(? super MyType) = -sig(MyType)
sig(? extends MyType) = +sig(MyType)
- Parameters:
wt
- the type- Returns:
- the signature
-
typeToSignature
Get the signature of the given typeFor the use case this supports, probably the best way to obtain a
Type
is viaTypeLiteral
.As of the JVM 21, internal type signatures are derived as:
sig(my.MyType) = Lmy/MyType.class;
sig(my.MyType[]) = [sig(my.MyType)
sig(my.MyType<Yet, Another, ...>) = Lmy/MyType<sig(Yet), sig(Another), ...>;
- Wildcard types as in
wildToSignature(WildcardType)
- Type variables are not supported by these utilities
- Parameters:
type
- the type- Returns:
- the signature
-