com.sun.tools.javac.comp
Class Attr

java.lang.Object
  extended by com.sun.tools.javac.tree.JCTree.Visitor
      extended by com.sun.tools.javac.comp.Attr

public class Attr
extends JCTree.Visitor

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.

See Also:
Check, Resolve, ConstFold,

This is NOT part of any API supported by Sun Microsystems. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.


Nested Class Summary
private static class Attr.BreakAttr
           
private  class Attr.IdentAttributer
           
 
Field Summary
(package private)  boolean allowAnonOuterThis
          Switch: allow references to surrounding object from anonymous objects during constructor call?
(package private)  boolean allowBoxing
          Switch: support boxing and unboxing?
(package private)  boolean allowCovariantReturns
          Switch: support covariant result types?
(package private)  boolean allowEnums
          Switch: support enums?
(package private)  boolean allowGenerics
          Switch: support generics?
(package private)  boolean allowVarargs
          Switch: allow variable-arity methods.
(package private)  Annotate annotate
           
protected static Context.Key<Attr> attrKey
           
private  JCTree breakTree
           
(package private)  ConstFold cfolder
           
(package private)  Check chk
           
(package private)  JCDiagnostic.Factory diags
           
(package private)  Enter enter
           
(package private)  Env<AttrContext> env
          Visitor argument: the current environment.
protected  java.util.HashMap<java.lang.String,java.lang.Boolean> hasCodeFieldsCache
          Cache for queries to hasCodeFields.
private  TreeVisitor<Symbol,Env<AttrContext>> identAttributer
           
(package private)  Log log
           
(package private)  TreeMaker make
           
(package private)  MemberEnter memberEnter
           
(package private)  Names names
           
(package private)  Warner noteWarner
           
(package private)  Options options
           
(package private)  int pkind
          Visitor argument: the currently expected proto-kind.
(package private)  Type pt
          Visitor argument: the currently expected proto-type.
(package private)  boolean relax
          Switch: relax some constraints for retrofit mode.
(package private)  Type result
          Visitor result: the computed type.
(package private)  Resolve rs
           
(package private)  Symtab syms
           
(package private)  Target target
           
(package private)  Types types
           
(package private)  boolean useBeforeDeclarationWarning
          Switch: warn about use of variable before declaration? RFE: 6425594
 
Constructor Summary
protected Attr(Context context)
           
 
Method Summary
private static void addVars(List<JCTree.JCStatement> stats, Scope switchScope)
          Add any variables defined in stats to the switch scope.
private  void assertConvertible(JCTree tree, Type actual, Type formal, Warner warn)
           
(package private)  void attribAnnotationTypes(List<JCTree.JCAnnotation> annotations, Env<AttrContext> env)
          Attribute the type references in a list of annotations.
(package private)  List<Type> attribArgs(List<JCTree.JCExpression> trees, Env<AttrContext> env)
          Attribute the arguments in a method call, returning a list of types.
(package private)  Type attribBase(JCTree tree, Env<AttrContext> env, boolean classExpected, boolean interfaceExpected, boolean checkExtensible)
          Attribute type reference in an `extends' or `implements' clause.
(package private)  void attribBounds(List<JCTree.JCTypeParameter> typarams)
           
 void attribClass(JCDiagnostic.DiagnosticPosition pos, Symbol.ClassSymbol c)
          Main method: attribute class definition associated with given class symbol.
(package private)  void attribClass(Symbol.ClassSymbol c)
          Attribute class definition associated with given class symbol.
private  void attribClassBody(Env<AttrContext> env, Symbol.ClassSymbol c)
          Finish the attribution of a class.
(package private)  Type attribExpr(JCTree tree, Env<AttrContext> env)
          Derived visitor method: attribute an expression tree with no constraints on the computed type.
 Type attribExpr(JCTree tree, Env<AttrContext> env, Type pt)
          Derived visitor method: attribute an expression tree.
(package private)  List<Type> attribExprs(List<JCTree.JCExpression> trees, Env<AttrContext> env, Type pt)
          Attribute a list of expressions, returning a list of types.
 Env<AttrContext> attribExprToTree(JCTree expr, Env<AttrContext> env, JCTree tree)
           
 Symbol attribIdent(JCTree tree, JCTree.JCCompilationUnit topLevel)
          Attribute a parsed identifier.
 Type attribStat(JCTree tree, Env<AttrContext> env)
          Derived visitor method: attribute a statement or definition tree.
(package private)
<T extends JCTree>
void
attribStats(List<T> trees, Env<AttrContext> env)
          Attribute a list of statements, returning nothing.
 Env<AttrContext> attribStatToTree(JCTree stmt, Env<AttrContext> env, JCTree tree)
           
(package private)  Type attribTree(JCTree tree, Env<AttrContext> env, int pkind, Type pt)
          Visitor method: attribute a tree, catching any completion failure exceptions.
(package private)  Type attribType(JCTree tree, Env<AttrContext> env)
          Derived visitor method: attribute a type tree.
 Type attribType(JCTree node, Symbol.TypeSymbol sym)
           
(package private)  List<Type> attribTypes(List<JCTree.JCExpression> trees, Env<AttrContext> env)
          Attribute a type argument list, returning a list of types.
(package private)  void attribTypeVariables(List<JCTree.JCTypeParameter> typarams, Env<AttrContext> env)
          Attribute type variables (of generic classes or methods).
private  boolean canOwnInitializer(Symbol sym)
          Can the given symbol be the owner of code which forms part if class initialization? This is the case if the symbol is a type or field, or if the symbol is the synthetic method.
private  Type capture(Type type)
           
(package private)  Type check(JCTree tree, Type owntype, int ownkind, int pkind, Type pt)
          Check kind and type of given tree against protokind and prototype.
(package private)  void checkAssignable(JCDiagnostic.DiagnosticPosition pos, Symbol.VarSymbol v, JCTree base, Env<AttrContext> env)
          Check that variable can be assigned to.
protected  void checkAssignEscapeSafety(JCTree.JCExpression lhs)
           
(package private)  Type checkBase(Type t, JCTree tree, Env<AttrContext> env, boolean classExpected, boolean interfaceExpected, boolean checkExtensible)
           
protected  boolean checkDefaultCtorsEscapeSafe(Symbol.MethodSymbol ctor)
           
private  void checkEnumInitializer(JCTree tree, Env<AttrContext> env, Symbol.VarSymbol v)
          Check for illegal references to static members of enum.
(package private)  boolean checkFirstConstructorStat(JCTree.JCMethodInvocation tree, Env<AttrContext> env)
          Check that given application node appears as first statement in a constructor call.
(package private)  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.
private  void checkInit(JCTree tree, Env<AttrContext> env, Symbol.VarSymbol v, boolean onlyWarning)
          Check that variable is initialized and evaluate the variable's initializer, if not yet done.
 Type checkMethod(Type site, Symbol sym, Env<AttrContext> env, List<JCTree.JCExpression> argtrees, List<Type> argtypes, List<Type> typeargtypes, boolean useVarargs)
          Check that method arguments conform to its instantation.
protected  boolean checkRuntimeExceptionEscapeSafe(Symbol.ClassSymbol clazz)
           
private  void checkSerialVersionUID(JCTree.JCClassDecl tree, Symbol.ClassSymbol c)
          Check that an appropriate serialVersionUID member is defined.
 Type coerce(Type etype, Type ttype)
           
private  Type condType(JCDiagnostic.DiagnosticPosition pos, Type condtype, Type thentype, Type elsetype)
          Compute the type of a conditional expression, after checking that it exists.
private  Type condType1(JCDiagnostic.DiagnosticPosition pos, Type condtype, Type thentype, Type elsetype)
          Compute the type of a conditional expression, after checking that it exists.
protected  void cspVariableCheck(Symbol sym, JCTree tree)
           
private  Symbol enumConstant(JCTree tree, Type enumType)
          Return the selected enumeration constant symbol, or null.
private  JCTree findJumpTarget(JCDiagnostic.DiagnosticPosition pos, int tag, Name label, Env<AttrContext> env)
          Return the target of a break or continue statement, if it exists, report an error if not.
protected  boolean hasCodeFields(Type type)
          Return true if the type has code fields.
protected  boolean hasCodeFields(Type type, java.util.HashSet<java.lang.String> visited)
          Return true if the type has code fields.
static Attr instance(Context context)
           
(package private)  boolean isAssignableAsBlankFinal(Symbol.VarSymbol v, Env<AttrContext> env)
          Is given blank final variable assignable, i.e.
protected  boolean isClassCloserThanBrackets()
          Return true if we are inside brackets, but there is an anonymous inner class even closer: <| ...
protected  boolean isCodeType(Type memberType)
           
protected  boolean isPrimitiveOrBoxedOrArrayThereof(Type type)
           
private  boolean isSerializable(Symbol.ClassSymbol c)
          check if a class is a subtype of Serializable, if that is available.
private  boolean isStaticEnumField(Symbol.VarSymbol v)
          Is the given symbol a static, non-constant field of an Enum? Note: enum literals should not be regarded as such
(package private)  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.
(package private) static boolean isType(Symbol sym)
          Is this symbol a type?
(package private)  Type litType(int tag)
          Return the type of a literal with given type tag.
 JCTree.JCExpression makeNullCheck(JCTree.JCExpression arg)
          Make an attributed null check tree.
(package private)  Type newMethTemplate(List<Type> argtypes, List<Type> typeargtypes)
          Obtain a method type with given argument types.
private  Symbol selectSym(JCTree.JCFieldAccess tree, Type site, Env<AttrContext> env, Type pt, int pkind)
          Determine symbol referenced by a Select expression,
protected  void setClosestBracketUnsafe(JCTree tree)
           
protected  Type substList(Type t, List<Type> from, List<Type> to)
           
(package private)  Symbol thisSym(JCDiagnostic.DiagnosticPosition pos, Env<AttrContext> env)
          The current `this' symbol.
 void visitAnnotation(JCTree.JCAnnotation tree)
           
 void visitApply(JCTree.JCMethodInvocation tree)
          Visitor method for method invocations.
 void visitAssert(JCTree.JCAssert tree)
           
 void visitAssign(JCTree.JCAssign tree)
           
 void visitAssignop(JCTree.JCAssignOp tree)
           
 void visitBinary(JCTree.JCBinary tree)
           
 void visitBlock(JCTree.JCBlock tree)
           
 void visitBracketExpr(JCTree.JCBracketExpr tree)
           
 void visitBracketStat(JCTree.JCBracketStat tree)
           
 void visitBreak(JCTree.JCBreak tree)
           
 void visitClassDef(JCTree.JCClassDecl tree)
           
 void visitConditional(JCTree.JCConditional tree)
           
 void visitContinue(JCTree.JCContinue tree)
           
 void visitDoLoop(JCTree.JCDoWhileLoop tree)
           
 void visitErroneous(JCTree.JCErroneous tree)
           
 void visitEscapeExpr(JCTree.JCEscapeExpr tree)
           
 void visitEscapeStat(JCTree.JCEscapeStat tree)
           
 void visitExec(JCTree.JCExpressionStatement tree)
           
 void visitForeachLoop(JCTree.JCEnhancedForLoop tree)
           
 void visitForLoop(JCTree.JCForLoop tree)
           
 void visitIdent(JCTree.JCIdent tree)
           
 void visitIf(JCTree.JCIf tree)
           
 void visitImport(JCTree.JCImport tree)
           
 void visitIndexed(JCTree.JCArrayAccess tree)
           
 void visitLabelled(JCTree.JCLabeledStatement tree)
           
 void visitLetExpr(JCTree.LetExpr tree)
           
 void visitLiteral(JCTree.JCLiteral tree)
           
 void visitMethodDef(JCTree.JCMethodDecl tree)
           
 void visitNewArray(JCTree.JCNewArray tree)
           
 void visitNewClass(JCTree.JCNewClass tree)
           
 void visitParens(JCTree.JCParens tree)
           
 void visitReturn(JCTree.JCReturn tree)
           
 void visitSelect(JCTree.JCFieldAccess tree)
           
 void visitSkip(JCTree.JCSkip tree)
           
 void visitSwitch(JCTree.JCSwitch tree)
           
 void visitSynchronized(JCTree.JCSynchronized tree)
           
 void visitThrow(JCTree.JCThrow tree)
           
 void visitTree(JCTree tree)
          Default visitor method for all other trees.
 void visitTry(JCTree.JCTry tree)
           
 void visitTypeApply(JCTree.JCTypeApply tree)
          Visitor method for parameterized types.
 void visitTypeArray(JCTree.JCArrayTypeTree tree)
           
 void visitTypeCast(JCTree.JCTypeCast tree)
           
 void visitTypeIdent(JCTree.JCPrimitiveTypeTree tree)
           
 void visitTypeParameter(JCTree.JCTypeParameter tree)
           
 void visitTypeTest(JCTree.JCInstanceOf tree)
           
 void visitUnary(JCTree.JCUnary tree)
           
 void visitVarDef(JCTree.JCVariableDecl tree)
           
 void visitWhileLoop(JCTree.JCWhileLoop tree)
           
 void visitWildcard(JCTree.JCWildcard tree)
           
 
Methods inherited from class com.sun.tools.javac.tree.JCTree.Visitor
visitCase, visitCatch, visitModifiers, visitTopLevel, visitTypeBoundKind
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

attrKey

protected static final Context.Key<Attr> attrKey

names

final Names names

log

final Log log

syms

final Symtab syms

rs

final Resolve rs

chk

final Check chk

memberEnter

final MemberEnter memberEnter

make

final TreeMaker make

cfolder

final ConstFold cfolder

enter

final Enter enter

target

final Target target

types

final Types types

diags

final JCDiagnostic.Factory diags

annotate

final Annotate annotate

options

final Options options

relax

boolean relax
Switch: relax some constraints for retrofit mode.


allowGenerics

boolean allowGenerics
Switch: support generics?


allowVarargs

boolean allowVarargs
Switch: allow variable-arity methods.


allowEnums

boolean allowEnums
Switch: support enums?


allowBoxing

boolean allowBoxing
Switch: support boxing and unboxing?


allowCovariantReturns

boolean allowCovariantReturns
Switch: support covariant result types?


allowAnonOuterThis

boolean allowAnonOuterThis
Switch: allow references to surrounding object from anonymous objects during constructor call?


useBeforeDeclarationWarning

boolean useBeforeDeclarationWarning
Switch: warn about use of variable before declaration? RFE: 6425594


identAttributer

private TreeVisitor<Symbol,Env<AttrContext>> identAttributer

breakTree

private JCTree breakTree

env

Env<AttrContext> env
Visitor argument: the current environment.


pkind

int pkind
Visitor argument: the currently expected proto-kind.


pt

Type pt
Visitor argument: the currently expected proto-type.


result

Type result
Visitor result: the computed type.


hasCodeFieldsCache

protected java.util.HashMap<java.lang.String,java.lang.Boolean> hasCodeFieldsCache
Cache for queries to hasCodeFields. Key: type, value: true if the key has code fields


noteWarner

Warner noteWarner
Constructor Detail

Attr

protected Attr(Context context)
Method Detail

instance

public static Attr instance(Context context)

check

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.

Parameters:
tree - The tree whose kind and type is checked
owntype - The computed type of the tree
ownkind - The computed kind of the tree
pkind - The expected kind (or: protokind) of the tree
pt - The expected type (or: prototype) of the tree

isAssignableAsBlankFinal

boolean isAssignableAsBlankFinal(Symbol.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?

Parameters:
v - The blank final variable.
env - The current environment.

checkAssignable

void checkAssignable(JCDiagnostic.DiagnosticPosition pos,
                     Symbol.VarSymbol v,
                     JCTree base,
                     Env<AttrContext> env)
Check that variable can be assigned to.

Parameters:
pos - The current source code position.
v - The assigned varaible
base - If the variable is referred to in a Select, the part to the left of the `.', null otherwise.
env - The current environment.

isStaticReference

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.

Parameters:
tree - The candidate tree.

isType

static boolean isType(Symbol sym)
Is this symbol a type?


thisSym

Symbol thisSym(JCDiagnostic.DiagnosticPosition pos,
               Env<AttrContext> env)
The current `this' symbol.

Parameters:
env - The current environment.

attribIdent

public Symbol attribIdent(JCTree tree,
                          JCTree.JCCompilationUnit topLevel)
Attribute a parsed identifier.

Parameters:
tree - Parsed identifier name
topLevel - The toplevel to use

coerce

public Type coerce(Type etype,
                   Type ttype)

attribType

public Type attribType(JCTree node,
                       Symbol.TypeSymbol sym)

attribExprToTree

public Env<AttrContext> attribExprToTree(JCTree expr,
                                         Env<AttrContext> env,
                                         JCTree tree)

attribStatToTree

public Env<AttrContext> attribStatToTree(JCTree stmt,
                                         Env<AttrContext> env,
                                         JCTree tree)

attribTree

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.

Parameters:
tree - The tree to be visited.
env - The environment visitor argument.
pkind - The protokind visitor argument.
pt - The prototype visitor argument.

attribExpr

public Type attribExpr(JCTree tree,
                       Env<AttrContext> env,
                       Type pt)
Derived visitor method: attribute an expression tree.


attribExpr

Type attribExpr(JCTree tree,
                Env<AttrContext> env)
Derived visitor method: attribute an expression tree with no constraints on the computed type.


attribType

Type attribType(JCTree tree,
                Env<AttrContext> env)
Derived visitor method: attribute a type tree.


attribStat

public Type attribStat(JCTree tree,
                       Env<AttrContext> env)
Derived visitor method: attribute a statement or definition tree.


attribExprs

List<Type> attribExprs(List<JCTree.JCExpression> trees,
                       Env<AttrContext> env,
                       Type pt)
Attribute a list of expressions, returning a list of types.


attribStats

<T extends JCTree> void attribStats(List<T> trees,
                                    Env<AttrContext> env)
Attribute a list of statements, returning nothing.


attribArgs

List<Type> attribArgs(List<JCTree.JCExpression> trees,
                      Env<AttrContext> env)
Attribute the arguments in a method call, returning a list of types.


attribTypes

List<Type> attribTypes(List<JCTree.JCExpression> trees,
                       Env<AttrContext> env)
Attribute a type argument list, returning a list of types.


attribTypeVariables

void attribTypeVariables(List<JCTree.JCTypeParameter> typarams,
                         Env<AttrContext> env)
Attribute type variables (of generic classes or methods). Compound types are attributed later in attribBounds.

Parameters:
typarams - the type variables to enter
env - the current environment

attribBounds

void attribBounds(List<JCTree.JCTypeParameter> typarams)

attribAnnotationTypes

void attribAnnotationTypes(List<JCTree.JCAnnotation> annotations,
                           Env<AttrContext> env)
Attribute the type references in a list of annotations.


attribBase

Type attribBase(JCTree tree,
                Env<AttrContext> env,
                boolean classExpected,
                boolean interfaceExpected,
                boolean checkExtensible)
Attribute type reference in an `extends' or `implements' clause.

Parameters:
tree - The tree making up the type reference.
env - The environment current at the reference.
classExpected - true if only a class is expected here.
interfaceExpected - true if only an interface is expected here.

checkBase

Type checkBase(Type t,
               JCTree tree,
               Env<AttrContext> env,
               boolean classExpected,
               boolean interfaceExpected,
               boolean checkExtensible)

visitClassDef

public void visitClassDef(JCTree.JCClassDecl tree)
Overrides:
visitClassDef in class JCTree.Visitor

visitMethodDef

public void visitMethodDef(JCTree.JCMethodDecl tree)
Overrides:
visitMethodDef in class JCTree.Visitor

visitVarDef

public void visitVarDef(JCTree.JCVariableDecl tree)
Overrides:
visitVarDef in class JCTree.Visitor

visitSkip

public void visitSkip(JCTree.JCSkip tree)
Overrides:
visitSkip in class JCTree.Visitor

visitBlock

public void visitBlock(JCTree.JCBlock tree)
Overrides:
visitBlock in class JCTree.Visitor

visitBracketExpr

public void visitBracketExpr(JCTree.JCBracketExpr tree)
Overrides:
visitBracketExpr in class JCTree.Visitor

visitBracketStat

public void visitBracketStat(JCTree.JCBracketStat tree)
Overrides:
visitBracketStat in class JCTree.Visitor

visitEscapeExpr

public void visitEscapeExpr(JCTree.JCEscapeExpr tree)
Overrides:
visitEscapeExpr in class JCTree.Visitor

visitEscapeStat

public void visitEscapeStat(JCTree.JCEscapeStat tree)
Overrides:
visitEscapeStat in class JCTree.Visitor

visitDoLoop

public void visitDoLoop(JCTree.JCDoWhileLoop tree)
Overrides:
visitDoLoop in class JCTree.Visitor

visitWhileLoop

public void visitWhileLoop(JCTree.JCWhileLoop tree)
Overrides:
visitWhileLoop in class JCTree.Visitor

visitForLoop

public void visitForLoop(JCTree.JCForLoop tree)
Overrides:
visitForLoop in class JCTree.Visitor

visitForeachLoop

public void visitForeachLoop(JCTree.JCEnhancedForLoop tree)
Overrides:
visitForeachLoop in class JCTree.Visitor

visitLabelled

public void visitLabelled(JCTree.JCLabeledStatement tree)
Overrides:
visitLabelled in class JCTree.Visitor

visitSwitch

public void visitSwitch(JCTree.JCSwitch tree)
Overrides:
visitSwitch in class JCTree.Visitor

addVars

private static void addVars(List<JCTree.JCStatement> stats,
                            Scope switchScope)
Add any variables defined in stats to the switch scope.


enumConstant

private Symbol enumConstant(JCTree tree,
                            Type enumType)
Return the selected enumeration constant symbol, or null.


visitSynchronized

public void visitSynchronized(JCTree.JCSynchronized tree)
Overrides:
visitSynchronized in class JCTree.Visitor

visitTry

public void visitTry(JCTree.JCTry tree)
Overrides:
visitTry in class JCTree.Visitor

visitConditional

public void visitConditional(JCTree.JCConditional tree)
Overrides:
visitConditional in class JCTree.Visitor

condType

private Type condType(JCDiagnostic.DiagnosticPosition pos,
                      Type condtype,
                      Type thentype,
                      Type elsetype)
Compute the type of a conditional expression, after checking that it exists. See Spec 15.25.

Parameters:
pos - The source position to be used for error diagnostics.
condtype - The type of the expression's condition.
thentype - The type of the expression's then-part.
elsetype - The type of the expression's else-part.

condType1

private Type condType1(JCDiagnostic.DiagnosticPosition pos,
                       Type condtype,
                       Type thentype,
                       Type elsetype)
Compute the type of a conditional expression, after checking that it exists. Does not take into account the special case where condition and both arms are constants.

Parameters:
pos - The source position to be used for error diagnostics.
condtype - The type of the expression's condition.
thentype - The type of the expression's then-part.
elsetype - The type of the expression's else-part.

visitIf

public void visitIf(JCTree.JCIf tree)
Overrides:
visitIf in class JCTree.Visitor

visitExec

public void visitExec(JCTree.JCExpressionStatement tree)
Overrides:
visitExec in class JCTree.Visitor

visitBreak

public void visitBreak(JCTree.JCBreak tree)
Overrides:
visitBreak in class JCTree.Visitor

visitContinue

public void visitContinue(JCTree.JCContinue tree)
Overrides:
visitContinue in class JCTree.Visitor

findJumpTarget

private JCTree findJumpTarget(JCDiagnostic.DiagnosticPosition pos,
                              int tag,
                              Name label,
                              Env<AttrContext> env)
Return the target of a break or continue statement, if it exists, report an error if not. Note: The target of a labelled break or continue is the (non-labelled) statement tree referred to by the label, not the tree representing the labelled statement itself.

Parameters:
pos - The position to be used for error diagnostics
tag - The tag of the jump statement. This is either Tree.BREAK or Tree.CONTINUE.
label - The label of the jump statement, or null if no label is given.
env - The environment current at the jump statement.

visitReturn

public void visitReturn(JCTree.JCReturn tree)
Overrides:
visitReturn in class JCTree.Visitor

checkRuntimeExceptionEscapeSafe

protected boolean checkRuntimeExceptionEscapeSafe(Symbol.ClassSymbol clazz)

visitThrow

public void visitThrow(JCTree.JCThrow tree)
Overrides:
visitThrow in class JCTree.Visitor

visitAssert

public void visitAssert(JCTree.JCAssert tree)
Overrides:
visitAssert in class JCTree.Visitor

isClassCloserThanBrackets

protected boolean isClassCloserThanBrackets()
Return true if we are inside brackets, but there is an anonymous inner class even closer: <| ... new Foo() { HERE } ... |> Also returns true if we aren't inside brackets at all.


setClosestBracketUnsafe

protected void setClosestBracketUnsafe(JCTree tree)

visitApply

public void visitApply(JCTree.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!

Overrides:
visitApply in class JCTree.Visitor

checkFirstConstructorStat

boolean checkFirstConstructorStat(JCTree.JCMethodInvocation tree,
                                  Env<AttrContext> env)
Check that given application node appears as first statement in a constructor call.

Parameters:
tree - The application node
env - The environment current at the application.

newMethTemplate

Type newMethTemplate(List<Type> argtypes,
                     List<Type> typeargtypes)
Obtain a method type with given argument types.


visitNewClass

public void visitNewClass(JCTree.JCNewClass tree)
Overrides:
visitNewClass in class JCTree.Visitor

checkDefaultCtorsEscapeSafe

protected boolean checkDefaultCtorsEscapeSafe(Symbol.MethodSymbol ctor)

makeNullCheck

public JCTree.JCExpression makeNullCheck(JCTree.JCExpression arg)
Make an attributed null check tree.


visitNewArray

public void visitNewArray(JCTree.JCNewArray tree)
Overrides:
visitNewArray in class JCTree.Visitor

visitParens

public void visitParens(JCTree.JCParens tree)
Overrides:
visitParens in class JCTree.Visitor

visitAssign

public void visitAssign(JCTree.JCAssign tree)
Overrides:
visitAssign in class JCTree.Visitor

checkAssignEscapeSafety

protected void checkAssignEscapeSafety(JCTree.JCExpression lhs)

visitAssignop

public void visitAssignop(JCTree.JCAssignOp tree)
Overrides:
visitAssignop in class JCTree.Visitor

visitUnary

public void visitUnary(JCTree.JCUnary tree)
Overrides:
visitUnary in class JCTree.Visitor

visitBinary

public void visitBinary(JCTree.JCBinary tree)
Overrides:
visitBinary in class JCTree.Visitor

visitTypeCast

public void visitTypeCast(JCTree.JCTypeCast tree)
Overrides:
visitTypeCast in class JCTree.Visitor

visitTypeTest

public void visitTypeTest(JCTree.JCInstanceOf tree)
Overrides:
visitTypeTest in class JCTree.Visitor

visitIndexed

public void visitIndexed(JCTree.JCArrayAccess tree)
Overrides:
visitIndexed in class JCTree.Visitor

visitIdent

public void visitIdent(JCTree.JCIdent tree)
Overrides:
visitIdent in class JCTree.Visitor

hasCodeFields

protected boolean hasCodeFields(Type type)
Return true if the type has code fields. Uses the cache.

Parameters:
type - type to check
Returns:
true if the type has code fields

hasCodeFields

protected boolean hasCodeFields(Type type,
                                java.util.HashSet<java.lang.String> visited)
Return true if the type has code fields. Uses the passed hash set to prevent infinite recursion in cycles.

Parameters:
type - type to check
visited - hash set of types already visited
Returns:
true if the type has code fields

isCodeType

protected boolean isCodeType(Type memberType)

substList

protected Type substList(Type t,
                         List<Type> from,
                         List<Type> to)

isPrimitiveOrBoxedOrArrayThereof

protected boolean isPrimitiveOrBoxedOrArrayThereof(Type type)

cspVariableCheck

protected void cspVariableCheck(Symbol sym,
                                JCTree tree)

visitSelect

public void visitSelect(JCTree.JCFieldAccess tree)
Overrides:
visitSelect in class JCTree.Visitor

selectSym

private Symbol selectSym(JCTree.JCFieldAccess tree,
                         Type site,
                         Env<AttrContext> env,
                         Type pt,
                         int pkind)
Determine symbol referenced by a Select expression,

Parameters:
tree - The select tree.
site - The type of the selected expression,
env - The current environment.
pt - The current prototype.
pkind - The expected kind(s) of the Select expression.

checkId

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.

Parameters:
tree - The syntax tree representing the identifier
site - If this is a select, the type of the selected expression, otherwise the type of the current class.
sym - The symbol representing the identifier.
env - The current environment.
pkind - The set of expected kinds.
pt - The expected type.

checkInit

private void checkInit(JCTree tree,
                       Env<AttrContext> env,
                       Symbol.VarSymbol v,
                       boolean onlyWarning)
Check that variable is initialized and evaluate the variable's initializer, if not yet done. Also check that variable is not referenced before it is defined.

Parameters:
tree - The tree making up the variable reference.
env - The current environment.
v - The variable's symbol.

checkEnumInitializer

private void checkEnumInitializer(JCTree tree,
                                  Env<AttrContext> env,
                                  Symbol.VarSymbol v)
Check for illegal references to static members of enum. In an enum type, constructors and initializers may not reference its static members unless they are constant.

Parameters:
tree - The tree making up the variable reference.
env - The current environment.
v - The variable's symbol.
See Also:
3rd Ed. (8.9 Enums)

isStaticEnumField

private boolean isStaticEnumField(Symbol.VarSymbol v)
Is the given symbol a static, non-constant field of an Enum? Note: enum literals should not be regarded as such


canOwnInitializer

private boolean canOwnInitializer(Symbol sym)
Can the given symbol be the owner of code which forms part if class initialization? This is the case if the symbol is a type or field, or if the symbol is the synthetic method. owning a block.


checkMethod

public Type checkMethod(Type site,
                        Symbol sym,
                        Env<AttrContext> env,
                        List<JCTree.JCExpression> argtrees,
                        List<Type> argtypes,
                        List<Type> typeargtypes,
                        boolean useVarargs)
Check that method arguments conform to its instantation.


assertConvertible

private void assertConvertible(JCTree tree,
                               Type actual,
                               Type formal,
                               Warner warn)

visitLiteral

public void visitLiteral(JCTree.JCLiteral tree)
Overrides:
visitLiteral in class JCTree.Visitor

litType

Type litType(int tag)
Return the type of a literal with given type tag.


visitTypeIdent

public void visitTypeIdent(JCTree.JCPrimitiveTypeTree tree)
Overrides:
visitTypeIdent in class JCTree.Visitor

visitTypeArray

public void visitTypeArray(JCTree.JCArrayTypeTree tree)
Overrides:
visitTypeArray in class JCTree.Visitor

visitTypeApply

public void visitTypeApply(JCTree.JCTypeApply tree)
Visitor method for parameterized types. Bound checking is left until later, since types are attributed before supertype structure is completely known

Overrides:
visitTypeApply in class JCTree.Visitor

visitTypeParameter

public void visitTypeParameter(JCTree.JCTypeParameter tree)
Overrides:
visitTypeParameter in class JCTree.Visitor

visitWildcard

public void visitWildcard(JCTree.JCWildcard tree)
Overrides:
visitWildcard in class JCTree.Visitor

visitAnnotation

public void visitAnnotation(JCTree.JCAnnotation tree)
Overrides:
visitAnnotation in class JCTree.Visitor

visitErroneous

public void visitErroneous(JCTree.JCErroneous tree)
Overrides:
visitErroneous in class JCTree.Visitor

visitTree

public void visitTree(JCTree tree)
Default visitor method for all other trees.

Overrides:
visitTree in class JCTree.Visitor

attribClass

public void attribClass(JCDiagnostic.DiagnosticPosition pos,
                        Symbol.ClassSymbol c)
Main method: attribute class definition associated with given class symbol. reporting completion failures at the given position.

Parameters:
pos - The source position at which completion errors are to be reported.
c - The class symbol whose definition will be attributed.

attribClass

void attribClass(Symbol.ClassSymbol c)
           throws Symbol.CompletionFailure
Attribute class definition associated with given class symbol.

Parameters:
c - The class symbol whose definition will be attributed.
Throws:
Symbol.CompletionFailure

visitImport

public void visitImport(JCTree.JCImport tree)
Overrides:
visitImport in class JCTree.Visitor

visitLetExpr

public void visitLetExpr(JCTree.LetExpr tree)
Overrides:
visitLetExpr in class JCTree.Visitor

attribClassBody

private void attribClassBody(Env<AttrContext> env,
                             Symbol.ClassSymbol c)
Finish the attribution of a class.


isSerializable

private boolean isSerializable(Symbol.ClassSymbol c)
check if a class is a subtype of Serializable, if that is available.


checkSerialVersionUID

private void checkSerialVersionUID(JCTree.JCClassDecl tree,
                                   Symbol.ClassSymbol c)
Check that an appropriate serialVersionUID member is defined.


capture

private Type capture(Type type)