Enum Class JitJvmTypeUtils

java.lang.Object
java.lang.Enum<JitJvmTypeUtils>
ghidra.pcode.emu.jit.JitJvmTypeUtils
All Implemented Interfaces:
Serializable, Comparable<JitJvmTypeUtils>, Constable

public enum JitJvmTypeUtils extends Enum<JitJvmTypeUtils>
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.

  • Method Details

    • values

      public static JitJvmTypeUtils[] 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

      public static JitJvmTypeUtils valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • classToInternalName

      public static String classToInternalName(Class<?> cls)
      Get the internal name of a class as in Type.getInternalName(Class).
      Parameters:
      cls - the class
      Returns:
      the internal name
    • rawToInternalName

      public static String rawToInternalName(Type type)
      Presume the given type is a Class and get its internal name
      Parameters:
      type - the type
      Returns:
      the internal name
    • wildToSignature

      public static String wildToSignature(WildcardType wt)
      Get the signature of the given wildcard type
      • sig(?) = *
      • sig(? super MyType) = -sig(MyType)
      • sig(? extends MyType) = +sig(MyType)
      Parameters:
      wt - the type
      Returns:
      the signature
    • typeToSignature

      public static String typeToSignature(Type type)
      Get the signature of the given type

      For the use case this supports, probably the best way to obtain a Type is via TypeLiteral.

      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