APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.tools.javac.comp

public Class Enter

extends Visitor
Class Inheritance
Imports
java.util.Map, .Optional, javax.tools.JavaFileObject, .JavaFileManager, com.sun.tools.javac.code.*, .Kinds.KindName, .Kinds.KindSelector, com.sun.tools.javac.code.Scope.*, com.sun.tools.javac.code.Symbol.*, com.sun.tools.javac.code.Type.*, com.sun.tools.javac.main.Option.PkgInfo, com.sun.tools.javac.resources.CompilerProperties.Errors, .CompilerProperties.Warnings, com.sun.tools.javac.tree.*, com.sun.tools.javac.tree.JCTree.*, com.sun.tools.javac.util.*, .JCDiagnostic.DiagnosticPosition, .List

This class enters symbols for all encountered definitions into the symbol table. The pass consists of high-level two phases, organized as follows:

In the first phase, all class symbols are entered into their enclosing scope, descending recursively down the tree for classes which are members of other classes. The class symbols are given a TypeEnter object as completer.

In the second phase classes are completed using TypeEnter.complete(). Completion might occur on demand, but any classes that are not completed that way will be eventually completed by processing the `uncompleted' queue. Completion entails determination of a class's parameters, supertype and interfaces, as well as entering all symbols defined in the class into its scope, with the exception of class symbols which have been entered in phase 1.

Whereas the first phase is organized as a sweep through all compiled syntax trees, the second phase is on-demand. Members of a class are entered when the contents of a class are first accessed. This is accomplished by installing completer objects in class symbols for compiled classes which invoke the type-enter phase for the corresponding class tree.

Classes migrate from one phase to the next via queues:

class enter -> (Enter.uncompleted)         --> type enter
            -> (Todo)                      --> attribute
                                            (only for toplevel classes)

This is NOT part of any supported API. 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 and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class

Field Summary

Modifier and TypeField and Description
pack-priv Annotate
pack-priv Check
pack-priv JCDiagnostic.Factory
protected static final Context.Key<Enter>
protected Env<AttrContext>
env

Visitor argument: the current environment.

pack-priv JavaFileManager
pack-priv Lint
pack-priv Log
pack-priv TreeMaker
pack-priv Modules
pack-priv Names
pack-priv List<Symbol.ClassSymbol>
pendingCompleter

The queue of classes that should have typeEnter completer installed after all the classes are discovered.

pack-priv Option.PkgInfo
private JCTree.JCClassDecl
predefClassDef

A dummy class to serve as enclClass for toplevel environments.

pack-priv Type
result

Visitor result: the computed type.

private final TreeScanner
pack-priv Symtab
private final Todo
pack-priv TypeEnter
pack-priv TypeEnvs
pack-priv Types
pack-priv ListBuffer<Symbol.ClassSymbol>
uncompleted

The queue of all classes that might still need to be completed; saved and initialized by main().

pack-priv ListBuffer<JCTree.JCCompilationUnit>
unfinishedModules

The queue of modules whose imports still need to be checked.

Constructor Summary

AccessConstructor and Description
protected
Enter(Context context)

Method Summary

Modifier and TypeMethod and Description
pack-priv Type
classEnter(JCTree
The tree to be visited.
tree
,
Env<AttrContext>
The environment visitor argument.
env
)

Visitor method: enter all classes in given tree, catching any completion failure exceptions.

pack-priv <T extends JCTree> List<Type>
classEnter(List<T> trees, Env<AttrContext> env)

Visitor method: enter classes of a list of trees, returning a list of types.

public Env<AttrContext>
classEnv(JCTree.JCClassDecl
The class definition.
tree
,
Env<AttrContext>
The environment current outside of the class definition.
env
)

Create a fresh environment for class bodies.

private static boolean
classNameMatchesFileName(Symbol.ClassSymbol c, Env<AttrContext> env)

Does class have the same name as the file it appears in?

public void
complete(List<JCTree.JCCompilationUnit>
The list of trees to be processed.
trees
,
Symbol.ClassSymbol
The class symbol to be processed or null to process all.
c
)

Main method: enter classes from the list of toplevel trees, possibly skipping TypeEnter for all but 'c' by placing them on the uncompleted list.

protected void
duplicateClass(JCDiagnostic.DiagnosticPosition pos, Symbol.ClassSymbol c)

Complain about a duplicate class.

pack-priv Scope.WriteableScope
enterScope(Env<AttrContext> env)

The scope in which a member definition in environment env is to be entered This is usually the environment's scope, except for class environments, where the local scope is for type variables, and the this and super symbol only, and members go into the class member scope.

public Env<AttrContext>
public Env<AttrContext>
getEnv(Symbol.TypeSymbol sym)

Accessor for typeEnvs

public Iterable<Env<AttrContext>>
public Env<AttrContext>
public static Enter
instance(Context context)

public void
main(List<JCTree.JCCompilationUnit>
The list of trees to be processed.
trees
)

Main method: enter all classes in a list of toplevel trees.

public Env<AttrContext>
moduleEnv(JCTree.JCModuleDecl
The module definition.
tree
,
Env<AttrContext>
The environment current outside of the module definition.
env
)

Create a fresh environment for modules.

public void
pack-priv Env<AttrContext>
topLevelEnv(JCTree.JCCompilationUnit
The toplevel tree.
tree
)

Create a fresh environment for toplevels.

public void
public void
public void
public void
public void
visitTree(JCTree tree)

Overrides com.sun.tools.javac.tree.JCTree.Visitor.visitTree.

Default class enter visitor method: do nothing.

public void
visitTypeParameter(JCTree.JCTypeParameter tree)

Overrides com.sun.tools.javac.tree.JCTree.Visitor.visitTypeParameter.

Class enter visitor method for type parameters.

Inherited from com.sun.tools.javac.tree.JCTree.Visitor:
visitAnnotatedTypevisitAnnotationvisitAnyPatternvisitApplyvisitAssertvisitAssignvisitAssignopvisitBinaryvisitBindingPatternvisitBlockvisitBreakvisitCasevisitCatchvisitConditionalvisitConstantCaseLabelvisitContinuevisitDefaultCaseLabelvisitDoLoopvisitErroneousvisitExecvisitExportsvisitForeachLoopvisitForLoopvisitIdentvisitIfvisitImportvisitIndexedvisitLabelledvisitLambdavisitLetExprvisitLiteralvisitMethodDefvisitModifiersvisitModuleImportvisitNewArrayvisitNewClassvisitOpensvisitPackageDefvisitParensvisitPatternCaseLabelvisitProvidesvisitRecordPatternvisitReferencevisitRequiresvisitReturnvisitSelectvisitSkipvisitSwitchvisitSwitchExpressionvisitSynchronizedvisitThrowvisitTryvisitTypeApplyvisitTypeArrayvisitTypeBoundKindvisitTypeCastvisitTypeIdentvisitTypeIntersectionvisitTypeTestvisitTypeUnionvisitUnaryvisitUsesvisitVarDefvisitVarTypevisitWhileLoopvisitWildcardvisitYield

Field Detail

annotateback to summary
pack-priv Annotate annotate
chkback to summary
pack-priv Check chk
diagsback to summary
pack-priv JCDiagnostic.Factory diags
enterKeyback to summary
protected static final Context.Key<Enter> enterKey
envback to summary
protected Env<AttrContext> env

Visitor argument: the current environment.

fileManagerback to summary
pack-priv JavaFileManager fileManager
lintback to summary
pack-priv Lint lint
logback to summary
pack-priv Log log
makeback to summary
pack-priv TreeMaker make
modulesback to summary
pack-priv Modules modules
namesback to summary
pack-priv Names names
pendingCompleterback to summary
pack-priv List<Symbol.ClassSymbol> pendingCompleter

The queue of classes that should have typeEnter completer installed after all the classes are discovered.

pkginfoOptback to summary
pack-priv Option.PkgInfo pkginfoOpt
predefClassDefback to summary
private JCTree.JCClassDecl predefClassDef

A dummy class to serve as enclClass for toplevel environments.

resultback to summary
pack-priv Type result

Visitor result: the computed type.

setPackageSymbolsback to summary
private final TreeScanner setPackageSymbols
symsback to summary
pack-priv Symtab syms
todoback to summary
private final Todo todo
typeEnterback to summary
pack-priv TypeEnter typeEnter
typeEnvsback to summary
pack-priv TypeEnvs typeEnvs
typesback to summary
pack-priv Types types
uncompletedback to summary
pack-priv ListBuffer<Symbol.ClassSymbol> uncompleted

The queue of all classes that might still need to be completed; saved and initialized by main().

unfinishedModulesback to summary
pack-priv ListBuffer<JCTree.JCCompilationUnit> unfinishedModules

The queue of modules whose imports still need to be checked.

Constructor Detail

Enterback to summary
protected Enter(Context context)
Annotations
@SuppressWarnings:this-escape

Method Detail

classEnterback to summary
pack-priv Type classEnter(JCTree tree, Env<AttrContext> env)

Visitor method: enter all classes in given tree, catching any completion failure exceptions. Return the tree's type.

Parameters
tree:JCTree

The tree to be visited.

env:Env<AttrContext>

The environment visitor argument.

classEnterback to summary
pack-priv <T extends JCTree> List<Type> classEnter(List<T> trees, Env<AttrContext> env)

Visitor method: enter classes of a list of trees, returning a list of types.

classEnvback to summary
public Env<AttrContext> classEnv(JCTree.JCClassDecl tree, Env<AttrContext> env)

Create a fresh environment for class bodies. This will create a fresh scope for local symbols of a class, referred to by the environments info.scope field. This scope will contain - symbols for this and super - symbols for any type parameters In addition, it serves as an anchor for scopes of methods and initializers which are nested in this scope via Scope.dup(). This scope should not be confused with the members scope of a class.

Parameters
tree:JCTree.JCClassDecl

The class definition.

env:Env<AttrContext>

The environment current outside of the class definition.

classNameMatchesFileNameback to summary
private static boolean classNameMatchesFileName(Symbol.ClassSymbol c, Env<AttrContext> env)

Does class have the same name as the file it appears in?

completeback to summary
public void complete(List<JCTree.JCCompilationUnit> trees, Symbol.ClassSymbol c)

Main method: enter classes from the list of toplevel trees, possibly skipping TypeEnter for all but 'c' by placing them on the uncompleted list.

Parameters
trees:List<JCTree.JCCompilationUnit>

The list of trees to be processed.

c:Symbol.ClassSymbol

The class symbol to be processed or null to process all.

duplicateClassback to summary
protected void duplicateClass(JCDiagnostic.DiagnosticPosition pos, Symbol.ClassSymbol c)

Complain about a duplicate class.

enterScopeback to summary
pack-priv Scope.WriteableScope enterScope(Env<AttrContext> env)

The scope in which a member definition in environment env is to be entered This is usually the environment's scope, except for class environments, where the local scope is for type variables, and the this and super symbol only, and members go into the class member scope.

getClassEnvback to summary
public Env<AttrContext> getClassEnv(Symbol.TypeSymbol sym)
getEnvback to summary
public Env<AttrContext> getEnv(Symbol.TypeSymbol sym)

Accessor for typeEnvs

getEnvsback to summary
public Iterable<Env<AttrContext>> getEnvs()
getTopLevelEnvback to summary
public Env<AttrContext> getTopLevelEnv(JCTree.JCCompilationUnit tree)
instanceback to summary
public static Enter instance(Context context)
mainback to summary
public void main(List<JCTree.JCCompilationUnit> trees)

Main method: enter all classes in a list of toplevel trees.

Parameters
trees:List<JCTree.JCCompilationUnit>

The list of trees to be processed.

moduleEnvback to summary
public Env<AttrContext> moduleEnv(JCTree.JCModuleDecl tree, Env<AttrContext> env)

Create a fresh environment for modules.

Parameters
tree:JCTree.JCModuleDecl

The module definition.

env:Env<AttrContext>

The environment current outside of the module definition.

newRoundback to summary
public void newRound()
topLevelEnvback to summary
pack-priv Env<AttrContext> topLevelEnv(JCTree.JCCompilationUnit tree)

Create a fresh environment for toplevels.

Parameters
tree:JCTree.JCCompilationUnit

The toplevel tree.

unenterback to summary
public void unenter(JCTree.JCCompilationUnit topLevel, JCTree tree)
visitClassDefback to summary
public void visitClassDef(JCTree.JCClassDecl tree)

Overrides com.sun.tools.javac.tree.JCTree.Visitor.visitClassDef.

Annotations
@Override
visitModuleDefback to summary
public void visitModuleDef(JCTree.JCModuleDecl tree)

Overrides com.sun.tools.javac.tree.JCTree.Visitor.visitModuleDef.

Annotations
@Override
visitTopLevelback to summary
public void visitTopLevel(JCTree.JCCompilationUnit tree)

Overrides com.sun.tools.javac.tree.JCTree.Visitor.visitTopLevel.

Annotations
@Override
visitTreeback to summary
public void visitTree(JCTree tree)

Overrides com.sun.tools.javac.tree.JCTree.Visitor.visitTree.

Default class enter visitor method: do nothing.

Annotations
@Override
visitTypeParameterback to summary
public void visitTypeParameter(JCTree.JCTypeParameter tree)

Overrides com.sun.tools.javac.tree.JCTree.Visitor.visitTypeParameter.

Class enter visitor method for type parameters. Enter a symbol for type parameter in local scope, after checking that it is unique.

Annotations
@Override
com.sun.tools.javac.comp back to summary

pack-priv Class Enter.UnenterScanner

extends TreeScanner
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Symbol.ModuleSymbol

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
Inherited from com.sun.tools.javac.tree.TreeScanner:
scanscanvisitAnnotatedTypevisitAnnotationvisitAnyPatternvisitApplyvisitAssertvisitAssignvisitAssignopvisitBinaryvisitBindingPatternvisitBlockvisitBreakvisitCasevisitCatchvisitConditionalvisitConstantCaseLabelvisitContinuevisitDefaultCaseLabelvisitDoLoopvisitErroneousvisitExecvisitExportsvisitForeachLoopvisitForLoopvisitIdentvisitIfvisitImportvisitIndexedvisitLabelledvisitLambdavisitLetExprvisitLiteralvisitMethodDefvisitModifiersvisitModuleDefvisitModuleImportvisitNewArrayvisitNewClassvisitOpensvisitPackageDefvisitParensvisitPatternCaseLabelvisitProvidesvisitRecordPatternvisitReferencevisitRequiresvisitReturnvisitSelectvisitSkipvisitSwitchvisitSwitchExpressionvisitSynchronizedvisitThrowvisitTopLevelvisitTreevisitTryvisitTypeApplyvisitTypeArrayvisitTypeBoundKindvisitTypeCastvisitTypeIdentvisitTypeIntersectionvisitTypeParametervisitTypeTestvisitTypeUnionvisitUnaryvisitUsesvisitVarDefvisitVarTypevisitWhileLoopvisitWildcardvisitYield

Field Detail

msymback to summary
private final Symbol.ModuleSymbol msym

Constructor Detail

UnenterScannerback to summary
public UnenterScanner(Symbol.ModuleSymbol msym)

Method Detail

visitClassDefback to summary
public void visitClassDef(JCTree.JCClassDecl tree)

Overrides com.sun.tools.javac.tree.TreeScanner.visitClassDef.

Annotations
@Override