Class ASTExpression.ConstResult

  • Enclosing interface:
    ASTExpression

    public static final class ASTExpression.ConstResult
    extends Object
    Result of constant folding an expression. This can be in one of three states:
    • No constant value: constant folding failed, meaning, the value of the expression is not known at compile time.
    • Has compile-time constant value: there is a constant value, and it is a compile-time constant in the sense of the JLS. Such constants are inlined in class files. One restriction on them is that they only use literals or CT-constant fields (which must be static final and have a CT-constant initializer), but not final variables or non-static fields for instance.
    • Has value, not compile-time constant: we could compute a constant value, but it is not CT-constant in the sense of the JLS. Maybe it uses the constant initializer of a final local variable for instance.
    Since:
    7.12.0
    • Method Detail

      • isCompileTimeConstant

        public boolean isCompileTimeConstant()
        If true, this value is a compile-time constant in the sense of the JLS. See class description.
      • hasValue

        public boolean hasValue()
        If true, a constant value could be computed. It is not necessarily a CT-constant. See class description.
      • getValue

        public @Nullable Object getValue()
        Get the value, or null if no value could be computed. The value has one of the primitive wrapper types, or String type.