Interface Types


public interface Types
A namespace for types describing Java types
  • Field Details

    • T_VOID

      static final Types.TVoid T_VOID
      The void type
    • T_BOOL

      static final Types.TBool T_BOOL
      The boolean type
    • T_BYTE

      static final Types.TByte T_BYTE
      The byte type
    • T_CHAR

      static final Types.TChar T_CHAR
      The char type
    • T_SHORT

      static final Types.TShort T_SHORT
      The short type
    • T_INT

      static final Types.TInt T_INT
      The int type
    • T_LONG

      static final Types.TLong T_LONG
      The long type
    • T_FLOAT

      static final Types.TFloat T_FLOAT
      The float type
    • T_DOUBLE

      static final Types.TDouble T_DOUBLE
      The double type
    • T_BOOL_ARR

      static final Types.TRef<boolean[]> T_BOOL_ARR
      The boolean[] type
    • T_BYTE_ARR

      static final Types.TRef<byte[]> T_BYTE_ARR
      The byte[] type
    • T_CHAR_ARR

      static final Types.TRef<char[]> T_CHAR_ARR
      The char[] type
    • T_SHORT_ARR

      static final Types.TRef<short[]> T_SHORT_ARR
      The short[] type
    • T_INT_ARR

      static final Types.TRef<int[]> T_INT_ARR
      The int[] type
    • T_LONG_ARR

      static final Types.TRef<long[]> T_LONG_ARR
      The long[] type
    • T_FLOAT_ARR

      static final Types.TRef<float[]> T_FLOAT_ARR
      The float[] type
    • T_DOUBLE_ARR

      static final Types.TRef<double[]> T_DOUBLE_ARR
      The double[] type
  • Method Details

    • refOf

      static <T> Types.TRef<T> refOf(Class<T> cls)
      Create a type describing a reference of the given class (or interface) type
      Type Parameters:
      T - the type of the Java class
      Parameters:
      cls - the class
      Returns:
      the type
    • refExtends

      static <ST, T extends ST> Types.TRef<T> refExtends(Class<ST> cls, String desc)
      Create a type describing an extension of the given class (or interface) type

      This is used when the type is itself dynamically generated, but it is at least known to extend a type defined by compiled Java source. This is best used with a type variable on the class in the Java source that generates the type. Unfortunately, that variable may bleed into any number of classes and methods which support that generation, esp., since this is almost always required to describe the type of this, and this is frequently accessed in generated code. Conventionally, the type variable is called THIS:

       class MyGenerator<THIS extends MyIf> {
              private final TRef<THIS> typeThis = refExtends(MyIf.class, generateDesc());
       }
       
      Type Parameters:
      ST - the super type
      T - the type variable used to refer to the extension
      Parameters:
      cls - the class of the super type
      desc - the internal name of the actual generated extension type
      Returns:
      the type
    • refExtends

      static <ST, T extends ST> Types.TRef<T> refExtends(Types.TRef<ST> st, String desc)
      Type Parameters:
      ST - the super type
      T - the type variable used to refer to the extension
      Parameters:
      st - the super type
      desc - the internal name of the actual generated extension type
      Returns:
      the type
    • refExtends

      static <ST, T extends ST> Types.TRef<T> refExtends(Types.TRef<ST> st, Class<?> reflected)
      Create a type describing a reflected extension of a given class (or interface) type

      This is used when the type is only known through reflection, but it is at least known to extend some other fixed type. This is best used with a type variable on the method that generates code wrt. the reflected class.

      Type Parameters:
      ST - the super type
      T - the type variable used to refer to the extension
      Parameters:
      st - the super type
      reflected - the reflected class
      Returns:
      the type