Interface JSymbolTable


  • @Experimental
    public interface JSymbolTable
    A symbol table for a particular region of a Java program. Keeps track of the types, values, and methods accessible from their simple name in their extent.

    Instances of this interface just tie together a few ShadowChain instances for each interesting namespace in the program.

    Since:
    7.0.0
    • Method Detail

      • variables

        ShadowChain<JVariableSig,​ScopeInfo> variables()
        The chain of tables tracking variable names that are in scope here (fields, locals, formals, etc).

        The following special cases are not handled by variable symbol tables:

        • The VariableAccess of case labels of a switch on an enum type. For example, in switch (someEnum) { case A: break; }, A may be out-of-scope in the outer expression. It is resolved relatively to the type of the tested expression (eg someEnum here). In other words, variables().resolve("A") will return a symbol that is not necessarily the actual reference for the enum constant, or no symbol at all. ASTVariableAccess.getSignature() will be accurate though.
      • types

        ShadowChain<JTypeMirror,​ScopeInfo> types()
        The chain of tables tracking type names that are in scope here (classes, type params, but not eg primitive types).

        The following special cases are not handled by type symbol tables:

        • The type reference of an inner class constructor call. For example, in new Outer().new Inner(), Inner may be out-of-scope in the outer expression. It depends on the type of the left hand expression, which may be an arbitrary expression. types().resolve("Inner") will return a symbol that is not necessarily the actual reference for Outer.Inner, or no symbol at all. TypeNode.getTypeMirror() will be accurate though.
      • methods

        ShadowChain<JMethodSig,​ScopeInfo> methods()
        The chain of tables tracking method names that are in scope here. Constructors are not tracked by this.