Interface JavaConstant

All Known Implementing Classes:
JavaConstant.Dynamic, JavaConstant.MethodHandle, JavaConstant.MethodType, JavaConstant.Simple, JavaConstant.Simple.OfTrivialValue, JavaConstant.Simple.OfTypeDescription

public interface JavaConstant
Returns a Java instance of an object that has a special meaning to the Java virtual machine and that is not available to Java in versions 6.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    Represents a dynamically resolved constant pool entry of a class file.
    static class 
    Represents a java.lang.invoke.MethodHandle object.
    static class 
    Represents a java.lang.invoke.MethodType object.
    static class 
    Represents a simple Java constant, either a primitive constant, a String or a Class.
    static interface 
    A visitor to resolve a JavaConstant based on its implementation.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    Applies the supplied visitor to this constant type with its respective callback.
    Returns a description of the type of the represented instance or at least a stub.
    Returns this constant as a Java java.lang.constant.ConstantDesc if the current VM is of at least version 12.
  • Method Details

    • toDescription

      Object toDescription()
      Returns this constant as a Java java.lang.constant.ConstantDesc if the current VM is of at least version 12. If the current VM is of an older version and does not support the type, an exception is thrown.
      Returns:
      This constant as a Java java.lang.constant.ConstantDesc.
    • getTypeDescription

      TypeDescription getTypeDescription()
      Returns a description of the type of the represented instance or at least a stub.
      Returns:
      A description of the type of the represented instance or at least a stub.
    • accept

      <T> T accept(JavaConstant.Visitor<T> visitor)
      Applies the supplied visitor to this constant type with its respective callback.
      Type Parameters:
      T - The type of the value that is returned by the visitor.
      Parameters:
      visitor - The visitor to dispatch.
      Returns:
      The value that is returned by the supplied visitor.