Save This Page
Home » openjdk-7 » com.sun.tools » javac » comp » [javadoc | source]
com.sun.tools.javac.comp
public class: Attr [javadoc | source]
java.lang.Object
   com.sun.tools.javac.tree.JCTree.Visitor
      com.sun.tools.javac.comp.Attr
This is the main context-dependent analysis phase in GJC. It encompasses name resolution, type checking and constant folding as subtasks. Some subtasks involve auxiliary classes.
Nested Class Summary:
class  Attr.PostAttrAnalyzer   
Field Summary
protected static final  Key<Attr> attrKey     
final  Names names     
final  Log log     
final  Symtab syms     
final  Resolve rs     
final  Infer infer     
final  Check chk     
final  MemberEnter memberEnter     
final  TreeMaker make     
final  ConstFold cfolder     
final  Enter enter     
final  Target target     
final  Types types     
final  Factory diags     
final  Annotate annotate     
final  DeferredLintHandler deferredLintHandler     
 boolean relax    Switch: relax some constraints for retrofit mode. 
 boolean allowGenerics    Switch: support generics? 
 boolean allowVarargs    Switch: allow variable-arity methods. 
 boolean allowEnums    Switch: support enums? 
 boolean allowBoxing    Switch: support boxing and unboxing? 
 boolean allowCovariantReturns    Switch: support covariant result types? 
 boolean allowAnonOuterThis    Switch: allow references to surrounding object from anonymous objects during constructor call? 
 boolean findDiamonds    Switch: generates a warning if diamond can be safely applied to a given new expression 
static final  boolean allowDiamondFinder    Internally enables/disables diamond finder feature 
 boolean useBeforeDeclarationWarning    Switch: warn about use of variable before declaration? RFE: 6425594 
 boolean allowStringsInSwitch    Switch: allow strings in switch? 
 String sourceName    Switch: name of source level; used for error reporting. 
 Env<AttrContext> env    Visitor argument: the current environment. 
 int pkind    Visitor argument: the currently expected proto-kind. 
 Type pt    Visitor argument: the currently expected proto-type. 
 String errKey    Visitor argument: the error key to be generated when a type error occurs 
 Type result    Visitor result: the computed type. 
 Warner noteWarner     
Constructor:
 protected Attr(Context context) 
Method from com.sun.tools.javac.comp.Attr Summary:
attrib,   attribAnnotationTypes,   attribAnyTypes,   attribArgs,   attribBase,   attribBounds,   attribClass,   attribClass,   attribDiamond,   attribExpr,   attribExpr,   attribExpr,   attribExprToTree,   attribExprs,   attribIdent,   attribLazyConstantValue,   attribStat,   attribStatToTree,   attribStats,   attribTopLevel,   attribTree,   attribTree,   attribType,   attribType,   attribType,   attribTypeVariables,   attribTypes,   check,   checkAssignable,   checkAutoCloseable,   checkBase,   checkFirstConstructorStat,   checkId,   checkMethod,   coerce,   instance,   isAssignableAsBlankFinal,   isStaticReference,   isType,   litType,   makeNullCheck,   newMethTemplate,   postAttr,   thisSym,   visitAnnotation,   visitApply,   visitAssert,   visitAssign,   visitAssignop,   visitBinary,   visitBlock,   visitBreak,   visitClassDef,   visitConditional,   visitContinue,   visitDoLoop,   visitErroneous,   visitExec,   visitForLoop,   visitForeachLoop,   visitIdent,   visitIf,   visitImport,   visitIndexed,   visitLabelled,   visitLiteral,   visitMethodDef,   visitNewArray,   visitNewClass,   visitParens,   visitReturn,   visitSelect,   visitSkip,   visitSwitch,   visitSynchronized,   visitThrow,   visitTree,   visitTry,   visitTypeApply,   visitTypeArray,   visitTypeCast,   visitTypeIdent,   visitTypeParameter,   visitTypeTest,   visitTypeUnion,   visitUnary,   visitVarDef,   visitWhileLoop,   visitWildcard
Methods from com.sun.tools.javac.tree.JCTree$Visitor:
visitAnnotation,   visitApply,   visitAssert,   visitAssign,   visitAssignop,   visitBinary,   visitBlock,   visitBreak,   visitCase,   visitCatch,   visitClassDef,   visitConditional,   visitContinue,   visitDoLoop,   visitErroneous,   visitExec,   visitForLoop,   visitForeachLoop,   visitIdent,   visitIf,   visitImport,   visitIndexed,   visitLabelled,   visitLetExpr,   visitLiteral,   visitMethodDef,   visitModifiers,   visitNewArray,   visitNewClass,   visitParens,   visitReturn,   visitSelect,   visitSkip,   visitSwitch,   visitSynchronized,   visitThrow,   visitTopLevel,   visitTree,   visitTry,   visitTypeApply,   visitTypeArray,   visitTypeBoundKind,   visitTypeCast,   visitTypeIdent,   visitTypeParameter,   visitTypeTest,   visitTypeUnion,   visitUnary,   visitVarDef,   visitWhileLoop,   visitWildcard
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.sun.tools.javac.comp.Attr Detail:
 public  void attrib(Env<AttrContext> env) 
    Attribute an env for either a top level tree or class declaration.
  void attribAnnotationTypes(List<JCAnnotation> annotations,
    Env<AttrContext> env) 
    Attribute the type references in a list of annotations.
 List<Type> attribAnyTypes(List<JCExpression> trees,
    Env<AttrContext> env) 
    Attribute a type argument list, returning a list of types. Caller is responsible for calling checkRefTypes.
 List<Type> attribArgs(List<JCExpression> trees,
    Env<AttrContext> env) 
    Attribute the arguments in a method call, returning a list of types.
 Type attribBase(JCTree tree,
    Env<AttrContext> env,
    boolean classExpected,
    boolean interfaceExpected,
    boolean checkExtensible) 
    Attribute type reference in an `extends' or `implements' clause. Supertypes of anonymous inner classes are usually already attributed.
  void attribBounds(List<JCTypeParameter> typarams) 
  void attribClass(ClassSymbol c) throws CompletionFailure 
    Attribute class definition associated with given class symbol.
 public  void attribClass(DiagnosticPosition pos,
    ClassSymbol c) 
    Main method: attribute class definition associated with given class symbol. reporting completion failures at the given position.
 Type attribDiamond(Env<AttrContext> env,
    JCNewClass tree,
    Type clazztype,
    Pair<Scope, Scope> mapping,
    List<Type> argtypes,
    List<Type> typeargtypes) 
 Type attribExpr(JCTree tree,
    Env<AttrContext> env) 
    Derived visitor method: attribute an expression tree with no constraints on the computed type.
 public Type attribExpr(JCTree tree,
    Env<AttrContext> env,
    Type pt) 
    Derived visitor method: attribute an expression tree.
 public Type attribExpr(JCTree tree,
    Env<AttrContext> env,
    Type pt,
    String key) 
 public Env<AttrContext> attribExprToTree(JCTree expr,
    Env<AttrContext> env,
    JCTree tree) 
 List<Type> attribExprs(List<JCExpression> trees,
    Env<AttrContext> env,
    Type pt) 
    Attribute a list of expressions, returning a list of types.
 public Symbol attribIdent(JCTree tree,
    JCCompilationUnit topLevel) 
    Attribute a parsed identifier.
 public Object attribLazyConstantValue(Env<AttrContext> env,
    JCExpression initializer,
    Type type) 
    Attribute a "lazy constant value".
 public Type attribStat(JCTree tree,
    Env<AttrContext> env) 
    Derived visitor method: attribute a statement or definition tree.
 public Env<AttrContext> attribStatToTree(JCTree stmt,
    Env<AttrContext> env,
    JCTree tree) 
  void attribStats(List<T> trees,
    Env<AttrContext> env) 
    Attribute a list of statements, returning nothing.
 public  void attribTopLevel(Env<AttrContext> env) 
    Attribute a top level tree. These trees are encountered when the package declaration has annotations.
 Type attribTree(JCTree tree,
    Env<AttrContext> env,
    int pkind,
    Type pt) 
    Visitor method: attribute a tree, catching any completion failure exceptions. Return the tree's type.
 Type attribTree(JCTree tree,
    Env<AttrContext> env,
    int pkind,
    Type pt,
    String errKey) 
 public Type attribType(JCTree node,
    TypeSymbol sym) 
 Type attribType(JCTree tree,
    Env<AttrContext> env) 
    Derived visitor method: attribute a type tree.
 Type attribType(JCTree tree,
    Env<AttrContext> env,
    Type pt) 
    Derived visitor method: attribute a type tree.
  void attribTypeVariables(List<JCTypeParameter> typarams,
    Env<AttrContext> env) 
    Attribute type variables (of generic classes or methods). Compound types are attributed later in attribBounds.
 List<Type> attribTypes(List<JCExpression> trees,
    Env<AttrContext> env) 
    Attribute a type argument list, returning a list of types. Check that all the types are references.
 Type check(JCTree tree,
    Type owntype,
    int ownkind,
    int pkind,
    Type pt) 
    Check kind and type of given tree against protokind and prototype. If check succeeds, store type in tree and return it. If check fails, store errType in tree and return it. No checks are performed if the prototype is a method type. It is not necessary in this case since we know that kind and type are correct.
  void checkAssignable(DiagnosticPosition pos,
    VarSymbol v,
    JCTree base,
    Env<AttrContext> env) 
    Check that variable can be assigned to.
  void checkAutoCloseable(DiagnosticPosition pos,
    Env<AttrContext> env,
    Type resource) 
 Type checkBase(Type t,
    JCTree tree,
    Env<AttrContext> env,
    boolean classExpected,
    boolean interfaceExpected,
    boolean checkExtensible) 
 boolean checkFirstConstructorStat(JCMethodInvocation tree,
    Env<AttrContext> env) 
    Check that given application node appears as first statement in a constructor call.
 Type checkId(JCTree tree,
    Type site,
    Symbol sym,
    Env<AttrContext> env,
    int pkind,
    Type pt,
    boolean useVarargs) 
    Determine type of identifier or select expression and check that (1) the referenced symbol is not deprecated (2) the symbol's type is safe (@see checkSafe) (3) if symbol is a variable, check that its type and kind are compatible with the prototype and protokind. (4) if symbol is an instance field of a raw type, which is being assigned to, issue an unchecked warning if its type changes under erasure. (5) if symbol is an instance method of a raw type, issue an unchecked warning if its argument types change under erasure. If checks succeed: If symbol is a constant, return its constant type else if symbol is a method, return its result type otherwise return its type. Otherwise return errType.
 public Type checkMethod(Type site,
    Symbol sym,
    Env<AttrContext> env,
    List<JCExpression> argtrees,
    List<Type> argtypes,
    List<Type> typeargtypes,
    boolean useVarargs) 
    Check that method arguments conform to its instantation. *
 public Type coerce(Type etype,
    Type ttype) 
 public static Attr instance(Context context) 
 boolean isAssignableAsBlankFinal(VarSymbol v,
    Env<AttrContext> env) 
    Is given blank final variable assignable, i.e. in a scope where it may be assigned to even though it is final?
 boolean isStaticReference(JCTree tree) 
    Does tree represent a static reference to an identifier? It is assumed that tree is either a SELECT or an IDENT. We have to weed out selects from non-type names here.
 static boolean isType(Symbol sym) 
    Is this symbol a type?
 Type litType(int tag) 
    Return the type of a literal with given type tag.
 public JCExpression makeNullCheck(JCExpression arg) 
    Make an attributed null check tree.
 Type newMethTemplate(List<Type> argtypes,
    List<Type> typeargtypes) 
    Obtain a method type with given argument types.
 public  void postAttr(Env<AttrContext> env) 
    Handle missing types/symbols in an AST. This routine is useful when the compiler has encountered some errors (which might have ended up terminating attribution abruptly); if the compiler is used in fail-over mode (e.g. by an IDE) and the AST contains semantic errors, this routine prevents NPE to be progagated during subsequent compilation steps.
 Symbol thisSym(DiagnosticPosition pos,
    Env<AttrContext> env) 
    The current `this' symbol.
 public  void visitAnnotation(JCAnnotation tree) 
 public  void visitApply(JCMethodInvocation tree) 
    Visitor method for method invocations. NOTE: The method part of an application will have in its type field the return type of the method, not the method's type itself!
 public  void visitAssert(JCAssert tree) 
 public  void visitAssign(JCAssign tree) 
 public  void visitAssignop(JCAssignOp tree) 
 public  void visitBinary(JCBinary tree) 
 public  void visitBlock(JCBlock tree) 
 public  void visitBreak(JCBreak tree) 
 public  void visitClassDef(JCClassDecl tree) 
 public  void visitConditional(JCConditional tree) 
 public  void visitContinue(JCContinue tree) 
 public  void visitDoLoop(JCDoWhileLoop tree) 
 public  void visitErroneous(JCErroneous tree) 
 public  void visitExec(JCExpressionStatement tree) 
 public  void visitForLoop(JCForLoop tree) 
 public  void visitForeachLoop(JCEnhancedForLoop tree) 
 public  void visitIdent(JCIdent tree) 
 public  void visitIf(JCIf tree) 
 public  void visitImport(JCImport tree) 
 public  void visitIndexed(JCArrayAccess tree) 
 public  void visitLabelled(JCLabeledStatement tree) 
 public  void visitLiteral(JCLiteral tree) 
 public  void visitMethodDef(JCMethodDecl tree) 
 public  void visitNewArray(JCNewArray tree) 
 public  void visitNewClass(JCNewClass tree) 
 public  void visitParens(JCParens tree) 
 public  void visitReturn(JCReturn tree) 
 public  void visitSelect(JCFieldAccess tree) 
 public  void visitSkip(JCSkip tree) 
 public  void visitSwitch(JCSwitch tree) 
 public  void visitSynchronized(JCSynchronized tree) 
 public  void visitThrow(JCThrow tree) 
 public  void visitTree(JCTree tree) 
    Default visitor method for all other trees.
 public  void visitTry(JCTry tree) 
 public  void visitTypeApply(JCTypeApply tree) 
    Visitor method for parameterized types. Bound checking is left until later, since types are attributed before supertype structure is completely known
 public  void visitTypeArray(JCArrayTypeTree tree) 
 public  void visitTypeCast(JCTypeCast tree) 
 public  void visitTypeIdent(JCPrimitiveTypeTree tree) 
 public  void visitTypeParameter(JCTypeParameter tree) 
 public  void visitTypeTest(JCInstanceOf tree) 
 public  void visitTypeUnion(JCTypeUnion tree) 
 public  void visitUnary(JCUnary tree) 
 public  void visitVarDef(JCVariableDecl tree) 
 public  void visitWhileLoop(JCWhileLoop tree) 
 public  void visitWildcard(JCWildcard tree)