Class JVariableSig

  • Direct Known Subclasses:
    JVariableSig.FieldSig

    public class JVariableSig
    extends Object
    Represents a value symbol viewed in the context of a particular program point (ie under a particular Substitution).

    The type given to a symbol is context-dependent. For example, when looking in the supertypes of the current class for a field, we have:

    
    
     abstract class Sup<K> {
          K field;
    
          // In this scope the type of `field` is `K`, an abstract type variable
    
     }
    
    
     class Foo extends Sup<Integer> {
    
          {
              // in this scope, the type of `super.field` is `Integer`, not `K`,
              // because we inherit `Sup` where `K` is substituted with `Integer`.
              // `K` is not even in scope.
    
              super.field = 2;
          }
    
     }
    
     

    This interface plays a similar role to JMethodSig. It is the type of search results of a JSymbolTable, see JSymbolTable.variables().

    • Method Detail

      • getDeclaringType

        public JTypeMirror getDeclaringType()
        This is the substituted type. Eg in the example of the class javadoc, for super.field, this would be Sup<Integer>. For local variables, this is always the generic type declaration of the enclosing type.
      • getSymbol

        public JVariableSymbol getSymbol()
        Returns the symbol for this variable.
      • getTypeMirror

        public JTypeMirror getTypeMirror()
        Returns the type given to the symbol in the particular scope this signature is valid in.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object