Class SignatureUtils

java.lang.Object
io.micronaut.sourcegen.bytecode.core.SignatureUtils

@Internal public final class SignatureUtils extends Object
JVM generic-signature operations shared by bytecode writers.

The result is the standard JVMS signature string. Keeping this operation independent of a bytecode library lets the ASM and JDK ClassFile backends use exactly the same generic metadata.

Since:
2.2
  • Method Details

    • getFieldSignature

      public static @Nullable String getFieldSignature(@Nullable ObjectDef objectDef, FieldDef fieldDef)
      The signature outside the write of an inner class: no variables of an enclosing class are in scope.
      Parameters:
      objectDef - The contextual object, if any
      fieldDef - The field
      Returns:
      The field signature, or null when its descriptor is sufficient
    • getFieldSignature

      public static @Nullable String getFieldSignature(@Nullable ObjectDef objectDef, FieldDef fieldDef, EnclosingScope enclosing)
      Parameters:
      objectDef - The contextual object, if any
      fieldDef - The field
      enclosing - The enclosing scope of the class being written
      Returns:
      The field signature, or null when its descriptor is sufficient
    • getClassSignature

      public static String getClassSignature(ClassDef classDef)
      The signature outside the write of an inner class: no variables of an enclosing class are in scope.
      Parameters:
      classDef - The class
      Returns:
      The class signature
    • getClassSignature

      public static String getClassSignature(ClassDef classDef, EnclosingScope enclosing)
      Parameters:
      classDef - The class
      enclosing - The enclosing scope of the class being written
      Returns:
      The class signature
    • getRecordSignature

      public static String getRecordSignature(RecordDef recordDef)
      The signature outside the write of an inner class: no variables of an enclosing class are in scope.
      Parameters:
      recordDef - The record
      Returns:
      The record signature
    • getRecordSignature

      public static String getRecordSignature(RecordDef recordDef, EnclosingScope enclosing)
      Parameters:
      recordDef - The record
      enclosing - The enclosing scope of the class being written
      Returns:
      The record signature
    • getInterfaceSignature

      public static @Nullable String getInterfaceSignature(InterfaceDef interfaceDef)
      The signature outside the write of an inner class: no variables of an enclosing class are in scope.
      Parameters:
      interfaceDef - The interface
      Returns:
      The interface signature, or null when no generic metadata is needed
    • getInterfaceSignature

      public static @Nullable String getInterfaceSignature(InterfaceDef interfaceDef, EnclosingScope enclosing)
      Parameters:
      interfaceDef - The interface
      enclosing - The enclosing scope of the class being written
      Returns:
      The interface signature, or null when no generic metadata is needed
    • getMethodSignature

      public static @Nullable String getMethodSignature(@Nullable ObjectDef objectDef, MethodDef methodDef)
      The signature outside the write of an inner class: no variables of an enclosing class are in scope.
      Parameters:
      objectDef - The contextual object, if any
      methodDef - The method
      Returns:
      The method signature, or null when its descriptor is sufficient
    • getMethodSignature

      public static @Nullable String getMethodSignature(@Nullable ObjectDef objectDef, MethodDef methodDef, EnclosingScope enclosing)
      Parameters:
      objectDef - The contextual object, if any
      methodDef - The method
      enclosing - The enclosing scope of the class being written
      Returns:
      The method signature, or null when its descriptor is sufficient
    • boundIndex

      public static int boundIndex(List<TypeDef> bounds, int index)
      The index a bound of a type parameter has in a type annotation's target: 0 is the class bound, which is absent where the first bound is an interface, whose bounds then count from 1.
      Parameters:
      bounds - The bounds of the type parameter
      index - The position of the bound among them
      Returns:
      The bound index
      Since:
      2.3