Interface Variable

All Known Subinterfaces:
Field

public interface Variable
Represents a variable bound to the body of a method.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    add(Object value)
    Add this variable with another variable or a constant, and assign the result to a new variable.
    addAnnotation(Object annotationType, boolean visible)
    Add an annotation to this variable.
    aget(Object index)
    Access an element from this array.
    Access the length of this array.
    and(Object value)
    Compute the bitwise and of this variable with another variable or a constant, and assign the result to a new variable.
    void
    aset(Object index, Object value)
    Set an element into this array.
    box()
    Box this primitive variable into its object peer.
    cast(Object type)
    Cast this variable to another type, and assign the result to a new variable.
    Returns the type of this variable, if bound to an existing class.
    Assign a value of 0, false, or null to this variable, depending on its type.
    com()
    Compute the bitwise complement of this variable and assign the result to a new variable.
    condy(String name, Object... args)
    Specify a static bootstrap method for dynamically generating constants, as found in the class type of this variable.
    div(Object value)
    Divide this variable with another variable or a constant, and assign the result to a new variable.
    eq(Object value)
    Determine if this variable is equal to another variable or constant, and assign the result to a new boolean variable.
    field(String name)
    Access a static or instance field from the object referred to by this variable.
    ge(Object value)
    Determine if this variable is greater than or equal to another variable or constant, and assign the result to a new boolean variable.
    get()
    Return a new variable with the same type and value as this one.
    gt(Object value)
    Determine if this variable is greater than another variable or constant, and assign the result to a new boolean variable.
    default void
    ifEq(Object value, Runnable then)
    Convenience method to generate conditional code if this variable is equal to another variable or constant.
    default void
    ifEq(Object value, Runnable then, Runnable else_)
    Convenience method to generate conditional code if this variable is equal to another variable or constant.
    void
    ifEq(Object value, Label label)
    Conditional goto if this variable is equal to another variable or constant.
    default void
    Convenience method to generate conditional code if this variable is false.
    default void
    ifFalse(Runnable then, Runnable else_)
    Convenience method to generate conditional code if this variable is false.
    void
    ifFalse(Label label)
    Conditional goto if this variable is false.
    default void
    ifGe(Object value, Runnable then)
    Convenience method to generate conditional code if this variable is greater than or equal to another variable or constant.
    default void
    ifGe(Object value, Runnable then, Runnable else_)
    Convenience method to generate conditional code if this variable is greater than or equal to another variable or constant.
    void
    ifGe(Object value, Label label)
    Conditional goto if this variable is greater than or equal to another variable or constant.
    default void
    ifGt(Object value, Runnable then)
    Convenience method to generate conditional code if this variable is greater than another variable or constant.
    default void
    ifGt(Object value, Runnable then, Runnable else_)
    Convenience method to generate conditional code if this variable is greater than another variable or constant.
    void
    ifGt(Object value, Label label)
    Conditional goto if this variable is greater than another variable or constant.
    default void
    ifLe(Object value, Runnable then)
    Convenience method to generate conditional code if this variable is less than or equal to another variable or constant.
    default void
    ifLe(Object value, Runnable then, Runnable else_)
    Convenience method to generate conditional code if this variable is less than or equal to another variable or constant.
    void
    ifLe(Object value, Label label)
    Conditional goto if this variable is less than or equal to another variable or constant.
    default void
    ifLt(Object value, Runnable then)
    Convenience method to generate conditional code if this variable is less than another variable or constant.
    default void
    ifLt(Object value, Runnable then, Runnable else_)
    Convenience method to generate conditional code if this variable is less than another variable or constant.
    void
    ifLt(Object value, Label label)
    Conditional goto if this variable is less than another variable or constant.
    default void
    ifNe(Object value, Runnable then)
    Convenience method to generate conditional code if this variable is not equal to another variable or constant.
    default void
    ifNe(Object value, Runnable then, Runnable else_)
    Convenience method to generate conditional code if this variable is not equal to another variable or constant.
    void
    ifNe(Object value, Label label)
    Conditional goto if this variable is not equal to another variable or constant.
    default void
    Convenience method to generate conditional code if this variable is true.
    default void
    ifTrue(Runnable then, Runnable else_)
    Convenience method to generate conditional code if this variable is true.
    void
    ifTrue(Label label)
    Conditional goto if this variable is true.
    void
    inc(Object value)
    Add this variable with another variable or a constant, and assign the result back to this variable.
    indy(String name, Object... args)
    Specify a static bootstrap method for dynamically generating methods, as found in the class type of this variable.
    Determine if this variable is an instance of the given class or interface, and assign the result to a new boolean variable.
    invoke(Object returnType, String name, Object[] types, Object... values)
    Invoke a static or instance method on the object referenced by this variable.
    invoke(String name, Object... values)
    Invoke a static or instance method on the object referenced by this variable.
    le(Object value)
    Determine if this variable is less than or equal to another variable or constant, and assign the result to a new boolean variable.
    lt(Object value)
    Determine if this variable is less than another variable or constant, and assign the result to a new boolean variable.
    Returns the type of this variable, if bound to a class which is being made.
    methodHandle(Object returnType, String name, Object... types)
    Returns a MethodHandle variable which can invoke a static or instance method on the object referenced by this variable.
    Returns the MethodMaker that this variable belongs to.
    void
    Enter a synchronized block on this variable.
    void
    Exit a synchronized block on this variable.
    mul(Object value)
    Multiply this variable with another variable or a constant, and assign the result to a new variable.
    Returns the name of this variable, which is null if unnamed.
    name(String name)
    Optionally assign a variable name.
    ne(Object value)
    Determine if this variable is not equal to another variable or constant, and assign the result to a new boolean variable.
    neg()
    Negate the value of this variable and assign the result to a new variable.
    not()
    Compute the logical negation of this boolean variable, and assign the result to a new variable.
    or(Object value)
    Compute the bitwise or of this variable with another variable or a constant, and assign the result to a new variable.
    rem(Object value)
    Compute the division remainder of this variable with another variable or a constant, and assign the result to a new variable.
    set(Object value)
    Assign a value to this variable, either from another variable or from a constant.
    Assign an exact object instance this variable, supported only when the class is built dynamically instead of loaded from a file.
    shl(Object value)
    Compute the bitwise left shift of this variable with another variable or a constant, and assign the result to a new variable.
    shr(Object value)
    Compute the bitwise right shift of this variable with another variable or a constant, and assign the result to a new variable.
    signature(Object... components)
    Define a signature for this named variable, which is a string for supporting generic types.
    sub(Object value)
    Subtract this variable with another variable or a constant, and assign the result to a new variable.
    void
    switch_(Label defaultLabel, int[] cases, Label... labels)
    Generates a switch statement against this int or non-null Integer variable.
    void
    switch_(Label defaultLabel, String[] cases, Label... labels)
    Generates a switch statement against this non-null String variable.
    void
    Convenience method for defining a synchronized block on this variable.
    void
    Throw the exception object referred to by this variable.
    Unbox this object variable into its primitive peer.
    ushr(Object value)
    Compute the bitwise unsigned right shift of this variable with another variable or a constant, and assign the result to a new variable.
    xor(Object value)
    Compute the bitwise xor of this variable with another variable or a constant, and assign the result to a new variable.
  • Method Details

    • classType

      Class<?> classType()
      Returns the type of this variable, if bound to an existing class. Null is returned if bound to a class which is being made.
    • makerType

      ClassMaker makerType()
      Returns the type of this variable, if bound to a class which is being made. Null is returned if bound to an existing class.
    • name

      String name()
      Returns the name of this variable, which is null if unnamed.
    • name

      Variable name(String name)
      Optionally assign a variable name.
      Returns:
      this variable
      Throws:
      IllegalStateException - if already named
    • signature

      Variable signature(Object... components)
      Define a signature for this named variable, which is a string for supporting generic types. The components can be strings or types (class, ClassMaker, etc), which are concatenated into a single string. Consult the JVM specification for the signature syntax.
      Returns:
      this
      Throws:
      IllegalArgumentException - if given an unsupported component
      IllegalStateException - if this isn't a plain local variable
    • addAnnotation

      AnnotationMaker addAnnotation(Object annotationType, boolean visible)
      Add an annotation to this variable.
      Parameters:
      annotationType - name or class which refers to an annotation interface
      visible - true if annotation is visible at runtime
      Throws:
      IllegalArgumentException - if the annotation type is unsupported
      IllegalStateException - if this variable doesn't support annotations
    • clear

      Variable clear()
      Assign a value of 0, false, or null to this variable, depending on its type.
      Returns:
      this variable
      Throws:
      IllegalStateException - if this variable cannot be modified
    • set

      Variable set(Object value)
      Assign a value to this variable, either from another variable or from a constant. A constant value can be a primitive type (boxed or unboxed), null, a String, a Class, an Enum, a MethodType, a MethodHandleInfo, a ConstantDesc, or a Constable.

      Note that a MethodHandle can be set with a MethodHandleInfo, which is converted automatically at link time. Handling of ConstantDesc and Constable is also treated specially — the actual type is determined by the resolved constant.

      Parameters:
      value - a Variable or a constant
      Returns:
      this variable
      Throws:
      IllegalArgumentException - if not given a variable or a constant
      IllegalStateException - if this variable cannot be modified, or if it's not compatible with the value type
    • setExact

      Variable setExact(Object value)
      Assign an exact object instance this variable, supported only when the class is built dynamically instead of loaded from a file. At runtime, the object instance provided here is exactly the same as referenced by the generated class. For simple constants, the regular set method is preferred.
      Parameters:
      value - exact object instance to assign
      Returns:
      this variable
      Throws:
      IllegalStateException - if this variable cannot be modified, or if it's not compatible with the value type
    • get

      Variable get()
      Return a new variable with the same type and value as this one.
      Returns:
      the result in a new variable, with the same type as this one
    • ifTrue

      void ifTrue(Label label)
      Conditional goto if this variable is true. The label doesn't need to be positioned yet.
    • ifTrue

      default void ifTrue(Runnable then)
      Convenience method to generate conditional code if this variable is true.
      Parameters:
      then - called to generate the body of the "then" case
    • ifTrue

      default void ifTrue(Runnable then, Runnable else_)
      Convenience method to generate conditional code if this variable is true.
      Parameters:
      then - called to generate the body of the "then" case
      else_ - called to generate the body of the "else" case
    • ifFalse

      void ifFalse(Label label)
      Conditional goto if this variable is false. The label doesn't need to be positioned yet.
    • ifFalse

      default void ifFalse(Runnable then)
      Convenience method to generate conditional code if this variable is false.
      Parameters:
      then - called to generate the body of the "then" case
    • ifFalse

      default void ifFalse(Runnable then, Runnable else_)
      Convenience method to generate conditional code if this variable is false.
      Parameters:
      then - called to generate the body of the "then" case
      else_ - called to generate the body of the "else" case
    • ifEq

      void ifEq(Object value, Label label)
      Conditional goto if this variable is equal to another variable or constant. The label doesn't need to be positioned yet.
      Parameters:
      value - a Variable or a constant
      Throws:
      IllegalArgumentException - if not given a variable or a constant
    • ifEq

      default void ifEq(Object value, Runnable then)
      Convenience method to generate conditional code if this variable is equal to another variable or constant.
      Parameters:
      value - a Variable or a constant
      then - called to generate the body of the "then" case
    • ifEq

      default void ifEq(Object value, Runnable then, Runnable else_)
      Convenience method to generate conditional code if this variable is equal to another variable or constant.
      Parameters:
      value - a Variable or a constant
      then - called to generate the body of the "then" case
      else_ - called to generate the body of the "else" case
    • ifNe

      void ifNe(Object value, Label label)
      Conditional goto if this variable is not equal to another variable or constant. The label doesn't need to be positioned yet.
      Parameters:
      value - a Variable or a constant
      Throws:
      IllegalArgumentException - if not given a variable or a constant
    • ifNe

      default void ifNe(Object value, Runnable then)
      Convenience method to generate conditional code if this variable is not equal to another variable or constant.
      Parameters:
      value - a Variable or a constant
      then - called to generate the body of the "then" case
    • ifNe

      default void ifNe(Object value, Runnable then, Runnable else_)
      Convenience method to generate conditional code if this variable is not equal to another variable or constant.
      Parameters:
      value - a Variable or a constant
      then - called to generate the body of the "then" case
      else_ - called to generate the body of the "else" case
    • ifLt

      void ifLt(Object value, Label label)
      Conditional goto if this variable is less than another variable or constant. The label doesn't need to be positioned yet.
      Parameters:
      value - a Variable or a constant
      Throws:
      IllegalArgumentException - if not given a variable or a constant
    • ifLt

      default void ifLt(Object value, Runnable then)
      Convenience method to generate conditional code if this variable is less than another variable or constant.
      Parameters:
      value - a Variable or a constant
      then - called to generate the body of the "then" case
    • ifLt

      default void ifLt(Object value, Runnable then, Runnable else_)
      Convenience method to generate conditional code if this variable is less than another variable or constant.
      Parameters:
      value - a Variable or a constant
      then - called to generate the body of the "then" case
      else_ - called to generate the body of the "else" case
    • ifGe

      void ifGe(Object value, Label label)
      Conditional goto if this variable is greater than or equal to another variable or constant. The label doesn't need to be positioned yet.
      Parameters:
      value - a Variable or a constant
      Throws:
      IllegalArgumentException - if not given a variable or a constant
    • ifGe

      default void ifGe(Object value, Runnable then)
      Convenience method to generate conditional code if this variable is greater than or equal to another variable or constant.
      Parameters:
      value - a Variable or a constant
      then - called to generate the body of the "then" case
    • ifGe

      default void ifGe(Object value, Runnable then, Runnable else_)
      Convenience method to generate conditional code if this variable is greater than or equal to another variable or constant.
      Parameters:
      value - a Variable or a constant
      then - called to generate the body of the "then" case
      else_ - called to generate the body of the "else" case
    • ifGt

      void ifGt(Object value, Label label)
      Conditional goto if this variable is greater than another variable or constant. The label doesn't need to be positioned yet.
      Parameters:
      value - a Variable or a constant
      Throws:
      IllegalArgumentException - if not given a variable or a constant
    • ifGt

      default void ifGt(Object value, Runnable then)
      Convenience method to generate conditional code if this variable is greater than another variable or constant.
      Parameters:
      value - a Variable or a constant
      then - called to generate the body of the "then" case
    • ifGt

      default void ifGt(Object value, Runnable then, Runnable else_)
      Convenience method to generate conditional code if this variable is greater than another variable or constant.
      Parameters:
      value - a Variable or a constant
      then - called to generate the body of the "then" case
      else_ - called to generate the body of the "else" case
    • ifLe

      void ifLe(Object value, Label label)
      Conditional goto if this variable is less than or equal to another variable or constant. The label doesn't need to be positioned yet.
      Parameters:
      value - a Variable or a constant
      Throws:
      IllegalArgumentException - if not given a variable or a constant
    • ifLe

      default void ifLe(Object value, Runnable then)
      Convenience method to generate conditional code if this variable is less than or equal to another variable or constant.
      Parameters:
      value - a Variable or a constant
      then - called to generate the body of the "then" case
    • ifLe

      default void ifLe(Object value, Runnable then, Runnable else_)
      Convenience method to generate conditional code if this variable is less than or equal to another variable or constant.
      Parameters:
      value - a Variable or a constant
      then - called to generate the body of the "then" case
      else_ - called to generate the body of the "else" case
    • switch_

      void switch_(Label defaultLabel, int[] cases, Label... labels)
      Generates a switch statement against this int or non-null Integer variable. None of the labels need to be positioned yet.
      Parameters:
      defaultLabel - required
      Throws:
      IllegalArgumentException - if the number of cases and labels don't match
      IllegalStateException - if this type cannot be automatically cast to an int
    • switch_

      void switch_(Label defaultLabel, String[] cases, Label... labels)
      Generates a switch statement against this non-null String variable. None of the labels need to be positioned yet.
      Parameters:
      defaultLabel - required
      Throws:
      IllegalArgumentException - if the number of cases and labels don't match
      IllegalStateException - if this type isn't a String
    • inc

      void inc(Object value)
      Add this variable with another variable or a constant, and assign the result back to this variable.
      Parameters:
      value - a Variable or a constant
      Throws:
      IllegalArgumentException - if not given a variable or a constant
      IllegalStateException - if this variable doesn't support the operation, or if value is incompatible
    • add

      Variable add(Object value)
      Add this variable with another variable or a constant, and assign the result to a new variable.
      Parameters:
      value - a Variable or a constant
      Returns:
      the result in a new variable, with the same type as this one
      Throws:
      IllegalArgumentException - if not given a variable or a constant
      IllegalStateException - if this variable doesn't support the operation, or if value is incompatible
    • sub

      Variable sub(Object value)
      Subtract this variable with another variable or a constant, and assign the result to a new variable.
      Parameters:
      value - a Variable or a constant
      Returns:
      the result in a new variable, with the same type as this one
      Throws:
      IllegalArgumentException - if not given a variable or a constant
      IllegalStateException - if this variable doesn't support the operation, or if value is incompatible
    • mul

      Variable mul(Object value)
      Multiply this variable with another variable or a constant, and assign the result to a new variable.
      Parameters:
      value - a Variable or a constant
      Returns:
      the result in a new variable, with the same type as this one
      Throws:
      IllegalArgumentException - if not given a variable or a constant
      IllegalStateException - if this variable doesn't support the operation, or if value is incompatible
    • div

      Variable div(Object value)
      Divide this variable with another variable or a constant, and assign the result to a new variable.
      Parameters:
      value - a Variable or a constant
      Returns:
      the result in a new variable, with the same type as this one
      Throws:
      IllegalArgumentException - if not given a variable or a constant
      IllegalStateException - if this variable doesn't support the operation, or if value is incompatible
    • rem

      Variable rem(Object value)
      Compute the division remainder of this variable with another variable or a constant, and assign the result to a new variable.
      Parameters:
      value - a Variable or a constant
      Returns:
      the result in a new variable, with the same type as this one
      Throws:
      IllegalArgumentException - if not given a variable or a constant
      IllegalStateException - if this variable doesn't support the operation, or if value is incompatible
    • eq

      Variable eq(Object value)
      Determine if this variable is equal to another variable or constant, and assign the result to a new boolean variable.
      Parameters:
      value - a Variable or a constant
      Returns:
      the result in a new boolean variable
      Throws:
      IllegalArgumentException - if not given a variable or a constant
      See Also:
    • ne

      Variable ne(Object value)
      Determine if this variable is not equal to another variable or constant, and assign the result to a new boolean variable.
      Parameters:
      value - a Variable or a constant
      Returns:
      the result in a new boolean variable
      Throws:
      IllegalArgumentException - if not given a variable or a constant
      See Also:
    • lt

      Variable lt(Object value)
      Determine if this variable is less than another variable or constant, and assign the result to a new boolean variable.
      Parameters:
      value - a Variable or a constant
      Returns:
      the result in a new boolean variable
      Throws:
      IllegalArgumentException - if not given a variable or a constant
      See Also:
    • ge

      Variable ge(Object value)
      Determine if this variable is greater than or equal to another variable or constant, and assign the result to a new boolean variable.
      Parameters:
      value - a Variable or a constant
      Returns:
      the result in a new boolean variable
      Throws:
      IllegalArgumentException - if not given a variable or a constant
      See Also:
    • gt

      Variable gt(Object value)
      Determine if this variable is greater than another variable or constant, and assign the result to a new boolean variable.
      Parameters:
      value - a Variable or a constant
      Returns:
      the result in a new boolean variable
      Throws:
      IllegalArgumentException - if not given a variable or a constant
      See Also:
    • le

      Variable le(Object value)
      Determine if this variable is less than or equal to another variable or constant, and assign the result to a new boolean variable.
      Parameters:
      value - a Variable or a constant
      Returns:
      the result in a new boolean variable
      Throws:
      IllegalArgumentException - if not given a variable or a constant
      See Also:
    • instanceOf

      Variable instanceOf(Object type)
      Determine if this variable is an instance of the given class or interface, and assign the result to a new boolean variable.
      Parameters:
      type - class or interface
      Returns:
      the result in a new boolean variable
    • cast

      Variable cast(Object type)
      Cast this variable to another type, and assign the result to a new variable. If the variable represents a primitive type, a conversion might be applied.
      Parameters:
      type - class or interface
      Returns:
      the result in a new variable
    • not

      Variable not()
      Compute the logical negation of this boolean variable, and assign the result to a new variable.
      Returns:
      the result in a new variable, with the same type as this one
    • and

      Variable and(Object value)
      Compute the bitwise and of this variable with another variable or a constant, and assign the result to a new variable.
      Parameters:
      value - a Variable or a constant
      Returns:
      the result in a new variable, with the same type as this one
      Throws:
      IllegalArgumentException - if not given a variable or a constant
      IllegalStateException - if this variable doesn't support the operation, or if value is incompatible
    • or

      Variable or(Object value)
      Compute the bitwise or of this variable with another variable or a constant, and assign the result to a new variable.
      Parameters:
      value - a Variable or a constant
      Returns:
      the result in a new variable, with the same type as this one
      Throws:
      IllegalArgumentException - if not given a variable or a constant
      IllegalStateException - if this variable doesn't support the operation, or if value is incompatible
    • xor

      Variable xor(Object value)
      Compute the bitwise xor of this variable with another variable or a constant, and assign the result to a new variable.
      Parameters:
      value - a Variable or a constant
      Returns:
      the result in a new variable, with the same type as this one
      Throws:
      IllegalArgumentException - if not given a variable or a constant
      IllegalStateException - if this variable doesn't support the operation, or if value is incompatible
    • shl

      Variable shl(Object value)
      Compute the bitwise left shift of this variable with another variable or a constant, and assign the result to a new variable.
      Parameters:
      value - a Variable or a constant
      Returns:
      the result in a new variable, with the same type as this one
      Throws:
      IllegalArgumentException - if not given a variable or a constant
      IllegalStateException - if this variable doesn't support the operation, or if value is incompatible
    • shr

      Variable shr(Object value)
      Compute the bitwise right shift of this variable with another variable or a constant, and assign the result to a new variable.
      Parameters:
      value - a Variable or a constant
      Returns:
      the result in a new variable, with the same type as this one
      Throws:
      IllegalArgumentException - if not given a variable or a constant
      IllegalStateException - if this variable doesn't support the operation, or if value is incompatible
    • ushr

      Variable ushr(Object value)
      Compute the bitwise unsigned right shift of this variable with another variable or a constant, and assign the result to a new variable.
      Parameters:
      value - a Variable or a constant
      Returns:
      the result in a new variable, with the same type as this one
      Throws:
      IllegalArgumentException - if not given a variable or a constant
      IllegalStateException - if this variable doesn't support the operation, or if value is incompatible
    • neg

      Variable neg()
      Negate the value of this variable and assign the result to a new variable.
      Returns:
      the result in a new variable, with the same type as this one
      Throws:
      IllegalStateException - if this variable doesn't support the operation
    • com

      Variable com()
      Compute the bitwise complement of this variable and assign the result to a new variable.
      Returns:
      the result in a new variable, with the same type as this one
      Throws:
      IllegalStateException - if this variable doesn't support the operation
    • box

      Variable box()
      Box this primitive variable into its object peer. If not a primitive type, then this is equivalent to calling get.
      Returns:
      the result in a new variable
    • unbox

      Variable unbox()
      Unbox this object variable into its primitive peer. If already a primitive type, then this is equivalent to calling get.
      Returns:
      the result in a new variable
      Throws:
      IllegalStateException - if this variable cannot be unboxed
    • alength

      Variable alength()
      Access the length of this array.
      Returns:
      the result in a new int variable
      Throws:
      IllegalStateException - if not an array type
    • aget

      Variable aget(Object index)
      Access an element from this array.
      Parameters:
      index - a Variable or a constant
      Returns:
      the result in a new variable
      Throws:
      IllegalStateException - if not an array type
    • aset

      void aset(Object index, Object value)
      Set an element into this array.
      Parameters:
      index - a Variable or a constant
      value - a Variable or a constant
      Throws:
      IllegalArgumentException - if not given a variable or a constant
      IllegalStateException - if not an array type, or if type doesn't match
      See Also:
    • field

      Field field(String name)
      Access a static or instance field from the object referred to by this variable.
      Parameters:
      name - field name
      Throws:
      IllegalStateException - if field isn't found
    • invoke

      Variable invoke(String name, Object... values)
      Invoke a static or instance method on the object referenced by this variable.
      Parameters:
      name - method name
      values - Variables or constants
      Returns:
      the result of the method, which is null if void
      Throws:
      IllegalArgumentException - if not given a variable or a constant
      IllegalStateException - if method isn't found
    • invoke

      Variable invoke(Object returnType, String name, Object[] types, Object... values)
      Invoke a static or instance method on the object referenced by this variable.
      Parameters:
      returnType - method return type
      name - method name; can be ".new" to construct an instance of this variable type, and returnType can be null
      types - method parameter types; the entire array or individual elements can be null to infer the actual type from the corresponding value
      values - Variables or constants
      Returns:
      the result of the method, which is null if void
      Throws:
      IllegalArgumentException - if not given a variable or a constant
      IllegalStateException - if method isn't found
    • methodHandle

      Variable methodHandle(Object returnType, String name, Object... types)
      Returns a MethodHandle variable which can invoke a static or instance method on the object referenced by this variable. The returned variable is actually a constant, and so it can be supplied as an argument to a bootstrap method or be used by another method in the same class.
      Parameters:
      returnType - method return type
      name - method name; can be ".new" to construct an instance of this variable type, and returnType can be null
      types - method parameter types; can be null if none
      Throws:
      IllegalArgumentException - if not given a supported type object
      IllegalStateException - if method isn't found
    • indy

      Bootstrap indy(String name, Object... args)
      Specify a static bootstrap method for dynamically generating methods, as found in the class type of this variable.
      Parameters:
      name - bootstrap method name
      args - constants which are passed to the bootstrap method, not including the first three standard arguments: (Lookup caller, String name, MethodType type)
      See Also:
    • condy

      Bootstrap condy(String name, Object... args)
      Specify a static bootstrap method for dynamically generating constants, as found in the class type of this variable. The variable returned by the bootstrap method cannot be modified. Since it is a constant, it can be supplied as an argument to another bootstrap method or be used by another method in the same class.
      Parameters:
      name - bootstrap method name
      args - constants which are passed to the bootstrap method, not including the first three standard arguments: (Lookup caller, String name, Class type)
      See Also:
    • throw_

      void throw_()
      Throw the exception object referred to by this variable.
      Throws:
      IllegalStateException - if not an exception type
    • monitorEnter

      void monitorEnter()
      Enter a synchronized block on this variable.
      Throws:
      IllegalStateException - if this variable isn't an object type
    • monitorExit

      void monitorExit()
      Exit a synchronized block on this variable.
      Throws:
      IllegalStateException - if this variable isn't an object type
    • synchronized_

      void synchronized_(Runnable body)
      Convenience method for defining a synchronized block on this variable.
      Parameters:
      body - called to generate the body of the synchronized block
      Throws:
      IllegalStateException - if this variable isn't an object type
    • methodMaker

      MethodMaker methodMaker()
      Returns the MethodMaker that this variable belongs to.