com.sun.tools.javac.comp
Class Check

java.lang.Object
  extended by com.sun.tools.javac.comp.Check

public class Check
extends java.lang.Object

Type checking helper class for the attribution phase.

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  class Check.ConversionWarner
           
(package private)  class Check.Validator
          A visitor class for type validation.
 
Field Summary
(package private)  boolean allowAnnotations
          Switch: annotations enabled?
(package private)  boolean allowGenerics
          Switch: generics enabled?
protected static Context.Key<Check> checkKey
           
 java.util.Map<Name,Symbol.ClassSymbol> compiled
          A table mapping flat names of all compiled classes in this run to their symbols; maintained from outside.
(package private)  boolean complexInference
          Switch: -complexinference option set?
private  MandatoryWarningHandler deprecationHandler
          A handler for messages about deprecated usage.
private  JCDiagnostic.Factory diags
           
private  Infer infer
           
private  Lint lint
           
private  Log log
           
private  Names names
           
(package private)  Warner overrideWarner
           
private  boolean skipAnnotations
           
private  Source source
           
private  Symtab syms
           
private  Target target
           
private  TreeInfo treeinfo
           
private  Types types
           
private  MandatoryWarningHandler uncheckedHandler
          A handler for messages about unchecked or unsafe usage.
private  Check.Validator validator
          Validate a type expression.
 
Constructor Summary
protected Check(Context context)
           
 
Method Summary
(package private)  boolean annotationApplicable(JCTree.JCAnnotation a, Symbol s)
          Is the annotation applicable to the symbol?
(package private)  java.lang.Object cannotOverride(Symbol.MethodSymbol m, Symbol.MethodSymbol other)
          A customized "cannot override" error message.
 Warner castWarner(JCDiagnostic.DiagnosticPosition pos, Type found, Type expected)
           
(package private)  void checkAllDefined(JCDiagnostic.DiagnosticPosition pos, Symbol.ClassSymbol c)
          Check that all abstract members of given class have definitions.
(package private)  void checkAnnotationResType(JCDiagnostic.DiagnosticPosition pos, Type type)
           
 void checkCanonical(JCTree tree)
          Check that a qualified name is in canonical form (for import decls).
private  void checkCapture(JCTree.JCTypeApply tree)
          Check that a type is within some bounds.
(package private)  Type checkCastable(JCDiagnostic.DiagnosticPosition pos, Type found, Type req)
          Check that a given type can be cast to a given target type.
(package private)  void checkClassBounds(JCDiagnostic.DiagnosticPosition pos, java.util.Map<Symbol.TypeSymbol,Type> seensofar, Type type)
          Enter all interfaces of type `type' into the hash table `seensofar' with their class symbol as key and their type as value.
(package private)  void checkClassBounds(JCDiagnostic.DiagnosticPosition pos, Type type)
          Check that class c does not implement directly or indirectly the same parameterized interface with two different argument lists.
(package private)  Type checkClassType(JCDiagnostic.DiagnosticPosition pos, Type t)
          Check that type is a class or interface type.
(package private)  Type checkClassType(JCDiagnostic.DiagnosticPosition pos, Type t, boolean noBounds)
          Check that type is a class or interface type.
(package private)  boolean checkCommonOverriderIn(Symbol s1, Symbol s2, Type site)
           
 boolean checkCompatibleAbstracts(JCDiagnostic.DiagnosticPosition pos, Type t1, Type t2)
          Check that classes (or interfaces) do not each define an abstract method with same name and arguments but incompatible return types.
 boolean checkCompatibleAbstracts(JCDiagnostic.DiagnosticPosition pos, Type t1, Type t2, Type site)
           
 void checkCompatibleConcretes(JCDiagnostic.DiagnosticPosition pos, Type site)
          Check that a class does not inherit two concrete methods with the same signature.
(package private)  void checkCompatibleSupertypes(JCDiagnostic.DiagnosticPosition pos, Type c)
          Check that all abstract methods implemented by a class are mutually compatible.
private  void checkCyclicConstructor(JCTree.JCClassDecl tree, Symbol ctor, java.util.Map<Symbol,Symbol> callMap)
          Look in the map to see if the given constructor is part of a call cycle.
(package private)  void checkCyclicConstructors(JCTree.JCClassDecl tree)
          Check for cycles in the graph of constructors calling other constructors.
(package private)  void checkDeprecatedAnnotation(JCDiagnostic.DiagnosticPosition pos, Symbol s)
           
(package private)  boolean checkDisjoint(JCDiagnostic.DiagnosticPosition pos, long flags, long set1, long set2)
          Check that flag set does not contain elements of two conflicting sets.
(package private)  void checkDivZero(JCDiagnostic.DiagnosticPosition pos, Symbol operator, Type operand)
          Check for division by integer constant zero
(package private)  void checkEmptyIf(JCTree.JCIf tree)
          Check for empty statements after if
private  void checkExtends(JCDiagnostic.DiagnosticPosition pos, Type a, Type.TypeVar bs)
          Check that a type is within some bounds.
(package private)  long checkFlags(JCDiagnostic.DiagnosticPosition pos, long flags, Symbol sym, JCTree tree)
          Check that given modifiers are legal for given symbol and return modifiers together with any implicit modififiers for that symbol.
(package private)  void checkImplementations(JCTree.JCClassDecl tree)
          Check that all methods which implement some method conform to the method they implement.
(package private)  void checkImplementations(JCTree.JCClassDecl tree, Symbol.ClassSymbol ic)
          Check that all methods which implement some method in `ic' conform to the method they implement.
(package private)  void checkNonCyclic(JCDiagnostic.DiagnosticPosition pos, Type.TypeVar t)
           
(package private)  void checkNonCyclic(JCDiagnostic.DiagnosticPosition pos, Type t)
          Check for cyclic references.
private  void checkNonCyclic1(JCDiagnostic.DiagnosticPosition pos, Type t, java.util.Set<Type.TypeVar> seen)
           
(package private)  void checkNonCyclicElements(JCTree.JCClassDecl tree)
          Check for cycles in the graph of annotation elements.
(package private)  void checkNonCyclicElementsInternal(JCDiagnostic.DiagnosticPosition pos, Symbol.TypeSymbol tsym)
           
private  boolean checkNonCyclicInternal(JCDiagnostic.DiagnosticPosition pos, Type t)
          Check for cyclic references.
(package private)  Type checkNonVoid(JCDiagnostic.DiagnosticPosition pos, Type t)
          Check that type is different from 'void'.
(package private)  void checkNotRepeated(JCDiagnostic.DiagnosticPosition pos, Type it, java.util.Set<Type> its)
          Enter interface into into set.
(package private)  Type checkNullOrRefType(JCDiagnostic.DiagnosticPosition pos, Type t)
          Check that type is a null or reference type.
(package private)  int checkOperator(JCDiagnostic.DiagnosticPosition pos, Symbol.OperatorSymbol operator, int tag, Type left, Type right)
          Return the opcode of the operator but emit an error if it is an error.
(package private)  void checkOverride(JCTree tree, Symbol.MethodSymbol m)
          Check that a given method conforms with any method it overrides.
(package private)  void checkOverride(JCTree tree, Symbol.MethodSymbol m, Symbol.MethodSymbol other, Symbol.ClassSymbol origin)
          Check that this method conforms with overridden method 'other'.
(package private)  void checkRaw(JCTree tree, Env<AttrContext> env)
           
(package private)  Type checkRefType(JCDiagnostic.DiagnosticPosition pos, Type t)
          Check that type is a reference type, i.e.
(package private)  Type checkReifiableReferenceType(JCDiagnostic.DiagnosticPosition pos, Type t)
          Check that type is a reifiable class, interface or array type.
(package private)  void checkTransparentClass(JCDiagnostic.DiagnosticPosition pos, Symbol.ClassSymbol c, Scope s)
          Check that a class or interface does not hide a class or interface with same name in immediately enclosing local scope.
(package private)  void checkTransparentVar(JCDiagnostic.DiagnosticPosition pos, Symbol.VarSymbol v, Scope s)
          Check that variable does not hide variable with same name in immediately enclosing local scope.
(package private)  Type checkType(JCDiagnostic.DiagnosticPosition pos, Type found, Type req)
          Check that a given type is assignable to a given proto-type.
(package private)  boolean checkUnique(JCDiagnostic.DiagnosticPosition pos, Symbol sym, Scope s)
          Check that symbol is unique in given scope.
(package private)  boolean checkUniqueClassName(JCDiagnostic.DiagnosticPosition pos, Name name, Scope s)
          Check that class does not have the same name as one of its enclosing classes, or as a class defined in its enclosing scope.
(package private)  boolean checkUniqueImport(JCDiagnostic.DiagnosticPosition pos, Symbol sym, Scope s)
          Check that single-type import is not already imported or top-level defined, but make an exception for two single-type imports which denote the same type.
private  boolean checkUniqueImport(JCDiagnostic.DiagnosticPosition pos, Symbol sym, Scope s, boolean staticImport)
          Check that single-type import is not already imported or top-level defined, but make an exception for two single-type imports which denote the same type.
(package private)  boolean checkUniqueStaticImport(JCDiagnostic.DiagnosticPosition pos, Symbol sym, Scope s)
          Check that static single-type import is not already imported or top-level defined, but make an exception for two single-type imports which denote the same type.
private  void closure(Type t, java.util.Map<Symbol.TypeSymbol,Type> typeMap)
          Compute all the supertypes of t, indexed by type symbol.
private  void closure(Type t, java.util.Map<Symbol.TypeSymbol,Type> typesSkip, java.util.Map<Symbol.TypeSymbol,Type> typeMap)
          Compute all the supertypes of t, indexed by type symbol (except thise in typesSkip).
 Type completionError(JCDiagnostic.DiagnosticPosition pos, Symbol.CompletionFailure ex)
          Report a failure to complete a class.
 Warner convertWarner(JCDiagnostic.DiagnosticPosition pos, Type found, Type expected)
           
(package private)  List<Type> diff(List<Type> ts1, List<Type> ts2)
          Form the difference of two type lists.
(package private)  void duplicateError(JCDiagnostic.DiagnosticPosition pos, Symbol sym)
          Report duplicate declaration error.
(package private)  void earlyRefError(JCDiagnostic.DiagnosticPosition pos, Symbol sym)
          Report an error that symbol cannot be referenced before super has been called.
(package private)  List<Type> excl(Type t, List<Type> ts)
          Remove type set from type set list.
private  Symbol firstDirectIncompatibility(Type t1, Type t2, Type site)
          Return the first method in t2 that conflicts with a method from t1.
private  Symbol firstIncompatibility(Type t1, Type t2, Type site)
          Return the first method which is defined with same args but different return types in two given interfaces, or null if none exists.
private  Symbol.MethodSymbol firstUndef(Symbol.ClassSymbol impl, Symbol.ClassSymbol c)
          Return first abstract member of class `c' that is not defined in `impl', null if there is none.
private  long implicitEnumFinalFlag(JCTree tree)
          Determine if this enum should be implicitly final.
(package private)  List<Type> incl(Type t, List<Type> ts)
          Add type set to given type list, unless it is a subclass of some class in the list.
static Check instance(Context context)
           
(package private)  Type instantiatePoly(JCDiagnostic.DiagnosticPosition pos, Type.ForAll t, Type pt, Warner warn)
          Instantiate polymorphic type to some prototype, unless prototype is `anyPoly' in which case polymorphic type is returned unchanged.
 List<Type> intersect(List<Type> ts1, List<Type> ts2)
          Form the intersection of two type lists.
(package private)  boolean intersects(Type t, List<Type> ts)
          Is given type a subtype or supertype of some of the types in given list?
private  boolean isCanonical(JCTree tree)
           
private  boolean isDeprecatedOverrideIgnorable(Symbol.MethodSymbol m, Symbol.ClassSymbol origin)
           
(package private)  boolean isHandled(Type exc, List<Type> handled)
          Is exc handled by given exception list?
(package private)  boolean isOverrider(Symbol s)
          Is s a method symbol that overrides a method in a superclass?
(package private)  boolean isTypeVar(Type t)
          Is type a type variable, or a (possibly multi-dimensional) array of type variables?
(package private)  boolean isUnchecked(JCDiagnostic.DiagnosticPosition pos, Type exc)
          Same, but handling completion failures.
(package private)  boolean isUnchecked(Symbol.ClassSymbol exc)
          Is exc an exception symbol that need not be declared?
(package private)  boolean isUnchecked(Type exc)
          Is exc an exception type that need not be declared?
(package private)  Name localClassName(Symbol.ClassSymbol c)
          Return name of local class.
private  void noteCyclic(JCDiagnostic.DiagnosticPosition pos, Symbol.ClassSymbol c)
          Note that we found an inheritance cycle.
(package private) static int protection(long flags)
          The level of access protection given by a flag set, where PRIVATE is highest and PUBLIC is lowest.
 void reportDeferredDiagnostics()
          Report any deferred diagnostics.
(package private)  Lint setLint(Lint newLint)
           
(package private)  boolean subset(Type t, List<Type> ts)
          Is given type a subtype of some of the types in given list?
(package private)  Type typeError(JCDiagnostic.DiagnosticPosition pos, java.lang.Object problem, Type found, Type req)
          Report a type error.
(package private)  Type typeError(JCDiagnostic.DiagnosticPosition pos, java.lang.String problem, Type found, Type req, java.lang.Object explanation)
           
(package private)  Type typeTagError(JCDiagnostic.DiagnosticPosition pos, java.lang.Object required, java.lang.Object found)
          Report an error that wrong type tag was found.
(package private)  java.lang.Object uncheckedOverrides(Symbol.MethodSymbol m, Symbol.MethodSymbol other)
          A customized "override" warning message.
(package private)  List<Type> unHandled(List<Type> thrown, List<Type> handled)
          Return all exceptions in thrown list that are not in handled list.
(package private)  List<Type> union(List<Type> ts1, List<Type> ts2)
          Form the union of two type set lists.
(package private)  void validate(JCTree tree, Env<AttrContext> env)
          Visitor method: Validate a type expression, if it is not null, catching and reporting any completion failures.
(package private)  void validate(List<? extends JCTree> trees, Env<AttrContext> env)
          Visitor method: Validate a list of type expressions.
 void validateAnnotation(JCTree.JCAnnotation a)
          Check an annotation value.
 void validateAnnotation(JCTree.JCAnnotation a, Symbol s)
          Check an annotation of a symbol.
(package private)  void validateAnnotationMethod(JCDiagnostic.DiagnosticPosition pos, Symbol.MethodSymbol m)
          "It is also a compile-time error if any method declared in an annotation type has a signature that is override-equivalent to that of any public or protected method declared in class Object or in the interface annotation.Annotation."
 void validateAnnotations(List<JCTree.JCAnnotation> annotations, Symbol s)
          Check the annotations of a symbol.
(package private)  void validateAnnotationType(JCDiagnostic.DiagnosticPosition pos, Type type)
           
(package private)  void validateAnnotationType(JCTree restype)
          Annotation types are restricted to primitives, String, an enum, an annotation, Class, Class, Class, arrays of the preceding.
(package private)  void varargsDuplicateError(JCDiagnostic.DiagnosticPosition pos, Symbol sym1, Symbol sym2)
          Report array/varargs duplicate declaration
(package private)  java.lang.Object varargsOverrides(Symbol.MethodSymbol m, Symbol.MethodSymbol other)
          A customized "override" warning message.
(package private)  void warnDeprecated(JCDiagnostic.DiagnosticPosition pos, Symbol sym)
          Warn about deprecated symbol.
 void warnUnchecked(JCDiagnostic.DiagnosticPosition pos, java.lang.String msg, java.lang.Object... args)
          Warn about unchecked operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

checkKey

protected static final Context.Key<Check> checkKey

names

private final Names names

log

private final Log log

syms

private final Symtab syms

infer

private final Infer infer

target

private final Target target

source

private final Source source

types

private final Types types

diags

private final JCDiagnostic.Factory diags

skipAnnotations

private final boolean skipAnnotations

treeinfo

private final TreeInfo treeinfo

lint

private Lint lint

allowGenerics

boolean allowGenerics
Switch: generics enabled?


allowAnnotations

boolean allowAnnotations
Switch: annotations enabled?


complexInference

boolean complexInference
Switch: -complexinference option set?


compiled

public java.util.Map<Name,Symbol.ClassSymbol> compiled
A table mapping flat names of all compiled classes in this run to their symbols; maintained from outside.


deprecationHandler

private MandatoryWarningHandler deprecationHandler
A handler for messages about deprecated usage.


uncheckedHandler

private MandatoryWarningHandler uncheckedHandler
A handler for messages about unchecked or unsafe usage.


validator

private Check.Validator validator
Validate a type expression. That is, check that all type arguments of a parametric type are within their bounds. This must be done in a second phase after type attributon since a class might have a subclass as type parameter bound. E.g: class B { ... } class C extends B { ... } and we can't make sure that the bound is already attributed because of possible cycles.


overrideWarner

Warner overrideWarner
Constructor Detail

Check

protected Check(Context context)
Method Detail

instance

public static Check instance(Context context)

setLint

Lint setLint(Lint newLint)

warnDeprecated

void warnDeprecated(JCDiagnostic.DiagnosticPosition pos,
                    Symbol sym)
Warn about deprecated symbol.

Parameters:
pos - Position to be used for error reporting.
sym - The deprecated symbol.

warnUnchecked

public void warnUnchecked(JCDiagnostic.DiagnosticPosition pos,
                          java.lang.String msg,
                          java.lang.Object... args)
Warn about unchecked operation.

Parameters:
pos - Position to be used for error reporting.
msg - A string describing the problem.

reportDeferredDiagnostics

public void reportDeferredDiagnostics()
Report any deferred diagnostics.


completionError

public Type completionError(JCDiagnostic.DiagnosticPosition pos,
                            Symbol.CompletionFailure ex)
Report a failure to complete a class.

Parameters:
pos - Position to be used for error reporting.
ex - The failure to report.

typeError

Type typeError(JCDiagnostic.DiagnosticPosition pos,
               java.lang.Object problem,
               Type found,
               Type req)
Report a type error.

Parameters:
pos - Position to be used for error reporting.
problem - A string describing the error.
found - The type that was found.
req - The type that was required.

typeError

Type typeError(JCDiagnostic.DiagnosticPosition pos,
               java.lang.String problem,
               Type found,
               Type req,
               java.lang.Object explanation)

typeTagError

Type typeTagError(JCDiagnostic.DiagnosticPosition pos,
                  java.lang.Object required,
                  java.lang.Object found)
Report an error that wrong type tag was found.

Parameters:
pos - Position to be used for error reporting.
required - An internationalized string describing the type tag required.
found - The type that was found.

earlyRefError

void earlyRefError(JCDiagnostic.DiagnosticPosition pos,
                   Symbol sym)
Report an error that symbol cannot be referenced before super has been called.

Parameters:
pos - Position to be used for error reporting.
sym - The referenced symbol.

duplicateError

void duplicateError(JCDiagnostic.DiagnosticPosition pos,
                    Symbol sym)
Report duplicate declaration error.


varargsDuplicateError

void varargsDuplicateError(JCDiagnostic.DiagnosticPosition pos,
                           Symbol sym1,
                           Symbol sym2)
Report array/varargs duplicate declaration


checkTransparentVar

void checkTransparentVar(JCDiagnostic.DiagnosticPosition pos,
                         Symbol.VarSymbol v,
                         Scope s)
Check that variable does not hide variable with same name in immediately enclosing local scope.

Parameters:
pos - Position for error reporting.
v - The symbol.
s - The scope.

checkTransparentClass

void checkTransparentClass(JCDiagnostic.DiagnosticPosition pos,
                           Symbol.ClassSymbol c,
                           Scope s)
Check that a class or interface does not hide a class or interface with same name in immediately enclosing local scope.

Parameters:
pos - Position for error reporting.
c - The symbol.
s - The scope.

checkUniqueClassName

boolean checkUniqueClassName(JCDiagnostic.DiagnosticPosition pos,
                             Name name,
                             Scope s)
Check that class does not have the same name as one of its enclosing classes, or as a class defined in its enclosing scope. return true if class is unique in its enclosing scope.

Parameters:
pos - Position for error reporting.
name - The class name.
s - The enclosing scope.

localClassName

Name localClassName(Symbol.ClassSymbol c)
Return name of local class. This is of the form $ n where enclClass is the flat name of the enclosing class, classname is the simple name of the local class


checkType

Type checkType(JCDiagnostic.DiagnosticPosition pos,
               Type found,
               Type req)
Check that a given type is assignable to a given proto-type. If it is, return the type, otherwise return errType.

Parameters:
pos - Position to be used for error reporting.
found - The type that was found.
req - The type that was required.

instantiatePoly

Type instantiatePoly(JCDiagnostic.DiagnosticPosition pos,
                     Type.ForAll t,
                     Type pt,
                     Warner warn)
Instantiate polymorphic type to some prototype, unless prototype is `anyPoly' in which case polymorphic type is returned unchanged.


checkCastable

Type checkCastable(JCDiagnostic.DiagnosticPosition pos,
                   Type found,
                   Type req)
Check that a given type can be cast to a given target type. Return the result of the cast.

Parameters:
pos - Position to be used for error reporting.
found - The type that is being cast.
req - The target type of the cast.

isTypeVar

boolean isTypeVar(Type t)
Is type a type variable, or a (possibly multi-dimensional) array of type variables?


checkExtends

private void checkExtends(JCDiagnostic.DiagnosticPosition pos,
                          Type a,
                          Type.TypeVar bs)
Check that a type is within some bounds. Used in TypeApply to verify that, e.g., X in V is a valid type argument.

Parameters:
pos - Position to be used for error reporting.
a - The type that should be bounded by bs.
bs - The bound.

checkCapture

private void checkCapture(JCTree.JCTypeApply tree)
Check that a type is within some bounds. Used in TypeApply to verify that, e.g., X in V is a valid type argument.

Parameters:
pos - Position to be used for error reporting.
a - The type that should be bounded by bs.
bs - The bound.

checkNonVoid

Type checkNonVoid(JCDiagnostic.DiagnosticPosition pos,
                  Type t)
Check that type is different from 'void'.

Parameters:
pos - Position to be used for error reporting.
t - The type to be checked.

checkClassType

Type checkClassType(JCDiagnostic.DiagnosticPosition pos,
                    Type t)
Check that type is a class or interface type.

Parameters:
pos - Position to be used for error reporting.
t - The type to be checked.

checkClassType

Type checkClassType(JCDiagnostic.DiagnosticPosition pos,
                    Type t,
                    boolean noBounds)
Check that type is a class or interface type.

Parameters:
pos - Position to be used for error reporting.
t - The type to be checked.
noBounds - True if type bounds are illegal here.

checkReifiableReferenceType

Type checkReifiableReferenceType(JCDiagnostic.DiagnosticPosition pos,
                                 Type t)
Check that type is a reifiable class, interface or array type.

Parameters:
pos - Position to be used for error reporting.
t - The type to be checked.

checkRefType

Type checkRefType(JCDiagnostic.DiagnosticPosition pos,
                  Type t)
Check that type is a reference type, i.e. a class, interface or array type or a type variable.

Parameters:
pos - Position to be used for error reporting.
t - The type to be checked.

checkNullOrRefType

Type checkNullOrRefType(JCDiagnostic.DiagnosticPosition pos,
                        Type t)
Check that type is a null or reference type.

Parameters:
pos - Position to be used for error reporting.
t - The type to be checked.

checkDisjoint

boolean checkDisjoint(JCDiagnostic.DiagnosticPosition pos,
                      long flags,
                      long set1,
                      long set2)
Check that flag set does not contain elements of two conflicting sets. s Return true if it doesn't.

Parameters:
pos - Position to be used for error reporting.
flags - The set of flags to be checked.
set1 - Conflicting flags set #1.
set2 - Conflicting flags set #2.

checkFlags

long checkFlags(JCDiagnostic.DiagnosticPosition pos,
                long flags,
                Symbol sym,
                JCTree tree)
Check that given modifiers are legal for given symbol and return modifiers together with any implicit modififiers for that symbol. Warning: we can't use flags() here since this method is called during class enter, when flags() would cause a premature completion.

Parameters:
pos - Position to be used for error reporting.
flags - The set of modifiers given in a definition.
sym - The defined symbol.

implicitEnumFinalFlag

private long implicitEnumFinalFlag(JCTree tree)
Determine if this enum should be implicitly final. If the enum has no specialized enum contants, it is final. If the enum does have specialized enum contants, it is not final.


validate

void validate(JCTree tree,
              Env<AttrContext> env)
Visitor method: Validate a type expression, if it is not null, catching and reporting any completion failures.


checkRaw

void checkRaw(JCTree tree,
              Env<AttrContext> env)

validate

void validate(List<? extends JCTree> trees,
              Env<AttrContext> env)
Visitor method: Validate a list of type expressions.


subset

boolean subset(Type t,
               List<Type> ts)
Is given type a subtype of some of the types in given list?


intersects

boolean intersects(Type t,
                   List<Type> ts)
Is given type a subtype or supertype of some of the types in given list?


incl

List<Type> incl(Type t,
                List<Type> ts)
Add type set to given type list, unless it is a subclass of some class in the list.


excl

List<Type> excl(Type t,
                List<Type> ts)
Remove type set from type set list.


union

List<Type> union(List<Type> ts1,
                 List<Type> ts2)
Form the union of two type set lists.


diff

List<Type> diff(List<Type> ts1,
                List<Type> ts2)
Form the difference of two type lists.


intersect

public List<Type> intersect(List<Type> ts1,
                            List<Type> ts2)
Form the intersection of two type lists.


isUnchecked

boolean isUnchecked(Symbol.ClassSymbol exc)
Is exc an exception symbol that need not be declared?


isUnchecked

boolean isUnchecked(Type exc)
Is exc an exception type that need not be declared?


isUnchecked

boolean isUnchecked(JCDiagnostic.DiagnosticPosition pos,
                    Type exc)
Same, but handling completion failures.


isHandled

boolean isHandled(Type exc,
                  List<Type> handled)
Is exc handled by given exception list?


unHandled

List<Type> unHandled(List<Type> thrown,
                     List<Type> handled)
Return all exceptions in thrown list that are not in handled list.

Parameters:
thrown - The list of thrown exceptions.
handled - The list of handled exceptions.

protection

static int protection(long flags)
The level of access protection given by a flag set, where PRIVATE is highest and PUBLIC is lowest.


cannotOverride

java.lang.Object cannotOverride(Symbol.MethodSymbol m,
                                Symbol.MethodSymbol other)
A customized "cannot override" error message.

Parameters:
m - The overriding method.
other - The overridden method.
Returns:
An internationalized string.

uncheckedOverrides

java.lang.Object uncheckedOverrides(Symbol.MethodSymbol m,
                                    Symbol.MethodSymbol other)
A customized "override" warning message.

Parameters:
m - The overriding method.
other - The overridden method.
Returns:
An internationalized string.

varargsOverrides

java.lang.Object varargsOverrides(Symbol.MethodSymbol m,
                                  Symbol.MethodSymbol other)
A customized "override" warning message.

Parameters:
m - The overriding method.
other - The overridden method.
Returns:
An internationalized string.

checkOverride

void checkOverride(JCTree tree,
                   Symbol.MethodSymbol m,
                   Symbol.MethodSymbol other,
                   Symbol.ClassSymbol origin)
Check that this method conforms with overridden method 'other'. where `origin' is the class where checking started. Complications: (1) Do not check overriding of synthetic methods (reason: they might be final). todo: check whether this is still necessary. (2) Admit the case where an interface proxy throws fewer exceptions than the method it implements. Augment the proxy methods with the undeclared exceptions in this case. (3) When generics are enabled, admit the case where an interface proxy has a result type extended by the result type of the method it implements. Change the proxies result type to the smaller type in this case.

Parameters:
tree - The tree from which positions are extracted for errors.
m - The overriding method.
other - The overridden method.
origin - The class of which the overriding method is a member.

isDeprecatedOverrideIgnorable

private boolean isDeprecatedOverrideIgnorable(Symbol.MethodSymbol m,
                                              Symbol.ClassSymbol origin)

checkCompatibleConcretes

public void checkCompatibleConcretes(JCDiagnostic.DiagnosticPosition pos,
                                     Type site)
Check that a class does not inherit two concrete methods with the same signature.

Parameters:
pos - Position to be used for error reporting.
site - The class type to be checked.

checkCompatibleAbstracts

public boolean checkCompatibleAbstracts(JCDiagnostic.DiagnosticPosition pos,
                                        Type t1,
                                        Type t2)
Check that classes (or interfaces) do not each define an abstract method with same name and arguments but incompatible return types.

Parameters:
pos - Position to be used for error reporting.
t1 - The first argument type.
t2 - The second argument type.

checkCompatibleAbstracts

public boolean checkCompatibleAbstracts(JCDiagnostic.DiagnosticPosition pos,
                                        Type t1,
                                        Type t2,
                                        Type site)

firstIncompatibility

private Symbol firstIncompatibility(Type t1,
                                    Type t2,
                                    Type site)
Return the first method which is defined with same args but different return types in two given interfaces, or null if none exists.

Parameters:
t1 - The first type.
t2 - The second type.
site - The most derived type.

closure

private void closure(Type t,
                     java.util.Map<Symbol.TypeSymbol,Type> typeMap)
Compute all the supertypes of t, indexed by type symbol.


closure

private void closure(Type t,
                     java.util.Map<Symbol.TypeSymbol,Type> typesSkip,
                     java.util.Map<Symbol.TypeSymbol,Type> typeMap)
Compute all the supertypes of t, indexed by type symbol (except thise in typesSkip).


firstDirectIncompatibility

private Symbol firstDirectIncompatibility(Type t1,
                                          Type t2,
                                          Type site)
Return the first method in t2 that conflicts with a method from t1.


checkCommonOverriderIn

boolean checkCommonOverriderIn(Symbol s1,
                               Symbol s2,
                               Type site)

checkOverride

void checkOverride(JCTree tree,
                   Symbol.MethodSymbol m)
Check that a given method conforms with any method it overrides.

Parameters:
tree - The tree from which positions are extracted for errors.
m - The overriding method.

checkAllDefined

void checkAllDefined(JCDiagnostic.DiagnosticPosition pos,
                     Symbol.ClassSymbol c)
Check that all abstract members of given class have definitions.

Parameters:
pos - Position to be used for error reporting.
c - The class.

firstUndef

private Symbol.MethodSymbol firstUndef(Symbol.ClassSymbol impl,
                                       Symbol.ClassSymbol c)
Return first abstract member of class `c' that is not defined in `impl', null if there is none.


checkNonCyclic

void checkNonCyclic(JCDiagnostic.DiagnosticPosition pos,
                    Type t)
Check for cyclic references. Issue an error if the symbol of the type referred to has a LOCKED flag set.

Parameters:
pos - Position to be used for error reporting.
t - The type referred to.

checkNonCyclic

void checkNonCyclic(JCDiagnostic.DiagnosticPosition pos,
                    Type.TypeVar t)

checkNonCyclic1

private void checkNonCyclic1(JCDiagnostic.DiagnosticPosition pos,
                             Type t,
                             java.util.Set<Type.TypeVar> seen)

checkNonCyclicInternal

private boolean checkNonCyclicInternal(JCDiagnostic.DiagnosticPosition pos,
                                       Type t)
Check for cyclic references. Issue an error if the symbol of the type referred to has a LOCKED flag set.

Parameters:
pos - Position to be used for error reporting.
t - The type referred to.

noteCyclic

private void noteCyclic(JCDiagnostic.DiagnosticPosition pos,
                        Symbol.ClassSymbol c)
Note that we found an inheritance cycle.


checkImplementations

void checkImplementations(JCTree.JCClassDecl tree)
Check that all methods which implement some method conform to the method they implement.

Parameters:
tree - The class definition whose members are checked.

checkImplementations

void checkImplementations(JCTree.JCClassDecl tree,
                          Symbol.ClassSymbol ic)
Check that all methods which implement some method in `ic' conform to the method they implement.


checkCompatibleSupertypes

void checkCompatibleSupertypes(JCDiagnostic.DiagnosticPosition pos,
                               Type c)
Check that all abstract methods implemented by a class are mutually compatible.

Parameters:
pos - Position to be used for error reporting.
c - The class whose interfaces are checked.

checkClassBounds

void checkClassBounds(JCDiagnostic.DiagnosticPosition pos,
                      Type type)
Check that class c does not implement directly or indirectly the same parameterized interface with two different argument lists.

Parameters:
pos - Position to be used for error reporting.
type - The type whose interfaces are checked.

checkClassBounds

void checkClassBounds(JCDiagnostic.DiagnosticPosition pos,
                      java.util.Map<Symbol.TypeSymbol,Type> seensofar,
                      Type type)
Enter all interfaces of type `type' into the hash table `seensofar' with their class symbol as key and their type as value. Make sure no class is entered with two different types.


checkNotRepeated

void checkNotRepeated(JCDiagnostic.DiagnosticPosition pos,
                      Type it,
                      java.util.Set<Type> its)
Enter interface into into set. If it existed already, issue a "repeated interface" error.


validateAnnotationType

void validateAnnotationType(JCTree restype)
Annotation types are restricted to primitives, String, an enum, an annotation, Class, Class, Class, arrays of the preceding.


validateAnnotationType

void validateAnnotationType(JCDiagnostic.DiagnosticPosition pos,
                            Type type)

validateAnnotationMethod

void validateAnnotationMethod(JCDiagnostic.DiagnosticPosition pos,
                              Symbol.MethodSymbol m)
"It is also a compile-time error if any method declared in an annotation type has a signature that is override-equivalent to that of any public or protected method declared in class Object or in the interface annotation.Annotation."


validateAnnotations

public void validateAnnotations(List<JCTree.JCAnnotation> annotations,
                                Symbol s)
Check the annotations of a symbol.


validateAnnotation

public void validateAnnotation(JCTree.JCAnnotation a,
                               Symbol s)
Check an annotation of a symbol.


isOverrider

boolean isOverrider(Symbol s)
Is s a method symbol that overrides a method in a superclass?


annotationApplicable

boolean annotationApplicable(JCTree.JCAnnotation a,
                             Symbol s)
Is the annotation applicable to the symbol?


validateAnnotation

public void validateAnnotation(JCTree.JCAnnotation a)
Check an annotation value.


checkDeprecatedAnnotation

void checkDeprecatedAnnotation(JCDiagnostic.DiagnosticPosition pos,
                               Symbol s)

checkNonCyclicElements

void checkNonCyclicElements(JCTree.JCClassDecl tree)
Check for cycles in the graph of annotation elements.


checkNonCyclicElementsInternal

void checkNonCyclicElementsInternal(JCDiagnostic.DiagnosticPosition pos,
                                    Symbol.TypeSymbol tsym)

checkAnnotationResType

void checkAnnotationResType(JCDiagnostic.DiagnosticPosition pos,
                            Type type)

checkCyclicConstructors

void checkCyclicConstructors(JCTree.JCClassDecl tree)
Check for cycles in the graph of constructors calling other constructors.


checkCyclicConstructor

private void checkCyclicConstructor(JCTree.JCClassDecl tree,
                                    Symbol ctor,
                                    java.util.Map<Symbol,Symbol> callMap)
Look in the map to see if the given constructor is part of a call cycle.


checkOperator

int checkOperator(JCDiagnostic.DiagnosticPosition pos,
                  Symbol.OperatorSymbol operator,
                  int tag,
                  Type left,
                  Type right)
Return the opcode of the operator but emit an error if it is an error.

Parameters:
pos - position for error reporting.
operator - an operator
tag - a tree tag
left - type of left hand side
right - type of right hand side

checkDivZero

void checkDivZero(JCDiagnostic.DiagnosticPosition pos,
                  Symbol operator,
                  Type operand)
Check for division by integer constant zero

Parameters:
pos - Position for error reporting.
operator - The operator for the expression
operand - The right hand operand for the expression

checkEmptyIf

void checkEmptyIf(JCTree.JCIf tree)
Check for empty statements after if


checkUnique

boolean checkUnique(JCDiagnostic.DiagnosticPosition pos,
                    Symbol sym,
                    Scope s)
Check that symbol is unique in given scope.

Parameters:
pos - Position for error reporting.
sym - The symbol.
s - The scope.

checkUniqueImport

boolean checkUniqueImport(JCDiagnostic.DiagnosticPosition pos,
                          Symbol sym,
                          Scope s)
Check that single-type import is not already imported or top-level defined, but make an exception for two single-type imports which denote the same type.

Parameters:
pos - Position for error reporting.
sym - The symbol.
s - The scope

checkUniqueStaticImport

boolean checkUniqueStaticImport(JCDiagnostic.DiagnosticPosition pos,
                                Symbol sym,
                                Scope s)
Check that static single-type import is not already imported or top-level defined, but make an exception for two single-type imports which denote the same type.

Parameters:
pos - Position for error reporting.
sym - The symbol.
s - The scope
staticImport - Whether or not this was a static import

checkUniqueImport

private boolean checkUniqueImport(JCDiagnostic.DiagnosticPosition pos,
                                  Symbol sym,
                                  Scope s,
                                  boolean staticImport)
Check that single-type import is not already imported or top-level defined, but make an exception for two single-type imports which denote the same type.

Parameters:
pos - Position for error reporting.
sym - The symbol.
s - The scope.
staticImport - Whether or not this was a static import

checkCanonical

public void checkCanonical(JCTree tree)
Check that a qualified name is in canonical form (for import decls).


isCanonical

private boolean isCanonical(JCTree tree)

castWarner

public Warner castWarner(JCDiagnostic.DiagnosticPosition pos,
                         Type found,
                         Type expected)

convertWarner

public Warner convertWarner(JCDiagnostic.DiagnosticPosition pos,
                            Type found,
                            Type expected)