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

public Class Lower

extends TreeTranslator
Class Inheritance
Imports
java.util.*, java.util.stream.Collectors, com.sun.source.tree.LambdaExpressionTree.BodyKind, com.sun.tools.javac.code.*, .Kinds.KindSelector, .Scope.WriteableScope, com.sun.tools.javac.code.Symbol.*, .Symbol.OperatorSymbol.AccessCode, com.sun.tools.javac.code.Type.*, .Source.Feature, com.sun.tools.javac.jvm.*, .PoolConstant.LoadableConstant, .Target, com.sun.tools.javac.main.Option.PkgInfo, com.sun.tools.javac.resources.CompilerProperties.Fragments, .CompilerProperties.Errors, com.sun.tools.javac.tree.*, com.sun.tools.javac.tree.JCTree.*, .JCTree.JCBreak, .JCTree.JCCase, .JCTree.JCExpression, .JCTree.JCExpressionStatement, .JCTree.JCSwitchExpression, com.sun.tools.javac.util.*, .JCDiagnostic.DiagnosticPosition, .List

This pass translates away some syntactic sugar: inner classes, class literals, assertions, foreach loops, etc.

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
pack-priv class
Lower.ClassMap

A navigator class for assembling a mapping from local class symbols to class definition trees.

pack-priv class
Lower.CompileTimeEnumMapping

EnumMapping using compile-time constants.

pack-priv static interface
Lower.EnumMapping

Generates a test value and corresponding cases for a switch on an enum type.

pack-priv class
Lower.FreeVarCollector

A navigator class for collecting the free variables accessed from a local class.

private class
Lower.LowerSignatureGenerator

Signature Generation

pack-priv class
Lower.RuntimeEnumMapping

EnumMapping using run-time ordinal lookup.

pack-priv static interface
pack-priv static record

Field Summary

Modifier and TypeField and Description
private Map<Symbol, Symbol.MethodSymbol>
accessConstrs

A mapping from (constructor) symbols to access constructor symbols.

private List<Symbol.ClassSymbol>
accessConstrTags

A list of all class symbols used for access constructor tags.

private ListBuffer<Symbol>
accessed

A queue for all accessed symbols.

private Map<Symbol, Integer>
accessNums

A mapping from symbols to their access numbers.

private Map<Symbol, Symbol.MethodSymbol[]>
accessSyms

A mapping from symbols to an array of access symbols, indexed by access code.

pack-priv Map<Symbol, Symbol>
actualSymbols

A hash table mapping virtual accessed symbols in outer subclasses to the actually referred symbol in superclasses.

private Symbol.ClassSymbol
private final Attr
pack-priv Env<AttrContext>
attrEnv

Environment for symbol lookup, set by translateTopLevelClass.

private final ConstFold
private final Check
pack-priv Map<Symbol.ClassSymbol, JCTree.JCClassDecl>
classdefs

A hash table mapping local classes to their definitions.

pack-priv Lower.ClassMap
pack-priv JCTree.Visitor
pack-priv Symbol.ClassSymbol
currentClass

The currently enclosing class.

pack-priv JCTree.JCMethodDecl
currentMethodDef

The current method definition.

pack-priv Symbol.MethodSymbol
currentMethodSym

The current method symbol.

pack-priv Type
currentRestype

The current expected return type.

private final boolean
private final boolean
private final Name
private JCTree.JCExpression
enclOp

Visitor argument: enclosing operator node.

pack-priv Map<Symbol.TypeSymbol, Lower.EnumMapping>
pack-priv Map<Symbol.ClassSymbol, List<Symbol.VarSymbol>>
freevarCache

A hash table mapping class symbols to lists of free variables.

private final Log
protected static final Context.Key<Lower>
private TreeMaker
private JCDiagnostic.DiagnosticPosition
private final Names
private final boolean
private final Operators
private final boolean
pack-priv JCTree.JCClassDecl
outermostClassDef

The currently enclosing outermost class definition.

pack-priv JCTree
outermostMemberDef

The currently enclosing outermost member definition.

pack-priv List<Symbol.VarSymbol>
outerThisStack

A stack containing the this$n field of the currently translated classes (if needed) in innermost first order.

private final Option.PkgInfo
pack-priv Map<Symbol, Symbol>
proxies

A map which allows to retrieve the translated proxy variable for any given symbol of an enclosing scope that is accessed (the accessed symbol could be the synthetic 'this$n' symbol).

public Map<Symbol.ClassSymbol, List<JCTree>>
prunedTree

A hash table mapping local classes to a list of pruned trees.

private final Resolve
private final Symtab
private Symbol.MethodSymbol
private final Target
pack-priv ListBuffer<JCTree>
translated

A queue of all translated classes.

private final TransTypes
pack-priv Scope.WriteableScope
twrVars

A scope containing all unnamed resource variables/saved exception variables for translated TWR blocks

private final TypeEnvs
private final HashMap<Lower.TypePairs, String>
private final Types
private final boolean
private int
Inherited from com.sun.tools.javac.tree.TreeTranslator:
result

Constructor Summary

AccessConstructor and Description
protected
Lower(Context context)

Method Summary

Modifier and TypeMethod and Description
pack-priv JCTree.JCExpression
pack-priv JCTree.JCExpression
abstractRval(JCTree.JCExpression rval, Type type, Lower.TreeBuilder builder)

Construct an expression using the builder, with the given rval expression as an argument to the builder.

pack-priv JCTree.JCExpression
pack-priv JCTree.JCExpression
access(Symbol
The accessed symbol.
sym
,
JCTree.JCExpression
The tree referring to the symbol.
tree
,
JCTree.JCExpression
The closest enclosing operation node of tree, null if tree is not a subtree of an operation.
enclOp
,
boolean
Is access via a (qualified) C.super?
refSuper
)

Ensure that identifier is accessible, return tree accessing the identifier.

pack-priv JCTree.JCExpression
access(JCTree.JCExpression
The identifier tree.
tree
)

Ensure that identifier is accessible, return tree accessing the identifier.

pack-priv JCTree.JCExpression
accessBase(JCDiagnostic.DiagnosticPosition pos, Symbol
The accessed symbol.
sym
)

The qualifier to be used for accessing a symbol in an outer class.

pack-priv Symbol.ClassSymbol
accessClass(Symbol
The access symbol
sym
,
boolean
Is access to a protected symbol in another package?
protAccess
,
JCTree tree)

The class in which an access method for given symbol goes.

private static int
accessCode(JCTree
The tree representing the identifier use.
tree
,
JCTree
The closest enclosing operation node of tree, null if tree is not a subtree of an operation.
enclOp
)

return access code for identifier,

pack-priv Symbol
accessConstructor(JCDiagnostic.DiagnosticPosition
The position to report diagnostics, if any.
pos
,
Symbol
The private constructor.
constr
)

Return access constructor for a private constructor, or the constructor itself, if no access constructor is needed.

pack-priv JCTree
accessConstructorDef(int
The source code position of the definition.
pos
,
Symbol
The private constructor.
constr
,
Symbol.MethodSymbol
The access method for the constructor.
accessor
)

Construct definition of an access constructor.

pack-priv Symbol.ClassSymbol
accessConstructorTag()

Return an anonymous class nested in this toplevel class.

pack-priv JCTree
accessDef(int
The source code position of the definition.
pos
,
Symbol
The private or protected symbol.
vsym
,
Symbol.MethodSymbol
The access method for the symbol.
accessor
,
int
The access code.
acode
)

Construct definition of an access method.

pack-priv Name
accessName(int anum, int acode)

The name of the access method with number `anum' and access code `acode'.

pack-priv Symbol.MethodSymbol
accessSymbol(Symbol
The accessed private symbol.
sym
,
JCTree
The accessing tree.
tree
,
JCTree
The closest enclosing operation node of tree, null if tree is not a subtree of an operation.
enclOp
,
boolean
Is access to a protected symbol in another package?
protAccess
,
boolean
Is access via a (qualified) C.super?
refSuper
)

Return access symbol for a private or protected symbol from an inner class.

private List<JCTree.JCCase>
addDefaultIfNeeded(boolean patternSwitch, boolean wasEnumSelector, List<JCTree.JCCase> cases)

private void
private String
argsTypeSig(List<Type> typeList)

private JCTree.JCExpression
private Symbol.ClassSymbol
assertionsDisabledClass()

Used to create an auxiliary class to hold $assertionsDisabled for interfaces.

private Symbol.OperatorSymbol
binaryAccessOperator(int acode, JCTree.Tag tag)

Return binary operator that corresponds to given access code.

pack-priv List<JCTree.JCExpression>
boxArgs(List<Type> parameters, List<JCTree.JCExpression> _args, Type varargsElement)

pack-priv <T extends JCTree.JCExpression> T
boxIfNeeded(T tree, Type type)

Expand a boxing or unboxing conversion if needed.

pack-priv JCTree.JCExpression
boxPrimitive(JCTree.JCExpression tree)

Box up a single primitive expression.

pack-priv JCTree.JCExpression
boxPrimitive(JCTree.JCExpression tree, Type box)

Box up a single primitive expression.

private void
checkAccessConstructorTags()

Anon inner classes are used as access constructor tags.

pack-priv void
checkConflicts(List<JCTree>
lowered class trees
translatedTrees
)

Check whether synthetic symbols generated during lowering conflict with user-defined symbols.

pack-priv JCTree.JCClassDecl
classDef(Symbol.ClassSymbol
The class symbol of which we want to determine the definition.
c
)

Map a class symbol to its definition.

private JCTree.JCExpression
classOf(JCTree
The tree identifying type T.
clazz
)

The tree simulating a T.class expression.

private JCTree.JCExpression
private JCTree.JCExpression
private void
private void
enterSynthetic(JCDiagnostic.DiagnosticPosition
Position for error reporting.
pos
,
Symbol
The symbol.
sym
,
Scope.WriteableScope
The scope.
s
)

Enter a synthetic symbol in a given scope, but complain if there was already one there.

pack-priv List<Name>
enumNamesFor(Symbol.ClassSymbol c)

Get the enum constants for the given enum class symbol, if known.

private Boolean
private Boolean
expValueIsNull(boolean eq, JCTree t)

pack-priv List<JCTree.JCVariableDecl>
freevarDefs(int
The source code position of the definition.
pos
,
List<Symbol.VarSymbol>
The free variables.
freevars
,
Symbol
The class in which the definitions go.
owner
)

Proxy definitions for all free variables in given list, in reverse order.

pack-priv List<JCTree.JCVariableDecl>
freevarDefs(int pos, List<Symbol.VarSymbol> freevars, Symbol owner, long additionalFlags)

pack-priv List<Symbol.VarSymbol>
freevars(Symbol.ClassSymbol c)

Return the variables accessed from within a local class, which are declared in the local class' owner.

pack-priv List<JCTree>
pack-priv JCTree
private JCTree.JCExpression
private void
pack-priv JCTree.JCStatement
initField(int pos, Symbol rhs, Symbol lhs)

Return tree simulating the assignment this.name = name, where name is the name of a free variable.

pack-priv JCTree.JCStatement
initOuterThis(int pos, Symbol.VarSymbol rhs, boolean stores)

Return tree simulating null checking outer this and/or assigning.

public static Lower
instance(Context context)

private boolean
private boolean
private boolean
pack-priv JCTree.JCExpression
pack-priv List<JCTree.JCExpression>
loadFreevars(JCDiagnostic.DiagnosticPosition
The source code position to be used for the trees.
pos
,
List<Symbol.VarSymbol>
The list of free variables.
freevars
)

Return a list of trees that load the free variables in given list, in reverse order.

private Symbol.MethodSymbol
lookupMethod(JCDiagnostic.DiagnosticPosition pos, Name name, Type qual, List<Type> args)

Look up a method in a given scope.

private Symbol
lookupSynthetic(Name
The name.
name
,
Scope
The scope.
s
)

Look up a synthetic name in a given scope.

pack-priv JCTree.JCExpression
lowerBoxedPostop(final JCTree.JCUnary tree)

Lower a tree of the form e++ or e-- where e is an object type

pack-priv TreeMaker
make_at(JCDiagnostic.DiagnosticPosition pos)

Equivalent to make.at(pos.getStartPosition()) with side effect of caching pos as make_pos, for use in diagnostics.

pack-priv void
makeAccessible(Symbol
The symbol.
sym
)

Add all required access methods for a private symbol to enclosing class.

pack-priv JCTree.JCAssignOp
makeAssignop(JCTree.Tag
The operators tree tag.
optag
,
JCTree
The operator's left argument.
lhs
,
JCTree
The operator's right argument.
rhs
)

Make an attributed assignop expression.

pack-priv JCTree.JCBinary
makeBinary(JCTree.Tag
The operators tree tag.
optag
,
JCTree.JCExpression
The operator's left argument.
lhs
,
JCTree.JCExpression
The operator's right argument.
rhs
)

Make an attributed binary expression.

private JCTree.JCMethodInvocation
makeCall(JCTree.JCExpression left, Name name, List<JCTree.JCExpression> args)

Create an attributed tree of the form left.name().

pack-priv JCTree.JCExpression
makeComma(final JCTree.JCExpression expr1, final JCTree.JCExpression expr2)

pack-priv JCTree.JCClassDecl
makeEmptyClass(long
The class symbol's flags
flags
,
Symbol.ClassSymbol
The class symbol's owner
owner
)

Create an empty anonymous class definition and enter and complete its symbol.

pack-priv JCTree.JCClassDecl
makeEmptyClass(long flags, Symbol.ClassSymbol owner, Name flatname, boolean addToDefs)

pack-priv JCTree.JCFieldAccess

Returns:

a field access tree
makeIndyQualifier
(Type
the site
site
,
JCTree.JCClassDecl
a class declaration tree
tree
,
Symbol.MethodSymbol
the method symbol
msym
,
List<Type>
the static argument types
staticArgTypes
,
PoolConstant.LoadableConstant[]
the static argument values
staticArgValues
,
Name
the bootstrap name to look for
bootstrapName
,
Name
normally bootstraps receives a method name as second argument, if you want that name to be different to that of the bootstrap name pass a different name here
argName
,
boolean
is it static or not
isStatic
)

Creates an indy qualifier, helpful to be part of an indy invocation

pack-priv JCTree.JCExpression
makeLit(Type
The literal's type.
type
,
Object
The literal's value.
value
)

Make an attributed tree representing a literal.

pack-priv JCTree.JCNewClass
makeNewClass(Type
The class type.
ctype
,
List<JCTree.JCExpression>
The constructor arguments.
args
)

Make an attributed class instance creation expression.

private JCTree.JCExpression
pack-priv JCTree.JCExpression
makeNull()

Make an attributed tree representing null.

pack-priv JCTree.JCExpression
makeOuterThis(JCDiagnostic.DiagnosticPosition
The source code position to be used for the tree.
pos
,
Symbol.TypeSymbol
The qualifier class.
c
)

Construct a tree that represents the outer instance C.this.

private JCTree.JCVariableDecl
private Symbol.VarSymbol
makeOuterThisVarSymbol(Symbol owner, long flags)

pack-priv JCTree.JCExpression
makeOwnerThis(JCDiagnostic.DiagnosticPosition
The source code position to be used for the tree.
pos
,
Symbol
The accessed symbol.
sym
,
boolean
should we accept a type that is a subtype of sym's owner, even if it doesn't contain sym due to hiding, overriding, or non-inheritance due to protection?
preciseMatch
)

Construct a tree that represents the closest outer instance C.this such that the given symbol is a member of C.

pack-priv JCTree.JCExpression
makeOwnerThisN(JCDiagnostic.DiagnosticPosition pos, Symbol sym, boolean preciseMatch)

Similar to makeOwnerThis but will never pick "this".

private JCTree.JCStatement
pack-priv JCTree.JCExpression
makeString(JCTree.JCExpression tree)

Convert tree into string object, unless it has already a reference type..

private Name

Returns:

fresh synthetic name
makeSyntheticName
(Name
base name
name
,
Scope
scope in which the name has to be unique
s
)

Create a fresh synthetic name within a given scope - the unique name is obtained by appending '$' chars at the end of the name until no match is found.

pack-priv JCTree.JCExpression
makeThis(JCDiagnostic.DiagnosticPosition
The source code position to be used for the tree.
pos
,
Symbol.TypeSymbol
The qualifier class.
c
)

Construct a tree simulating the expression C.this.

private JCTree.JCBlock
makeTwrBlock(List<JCTree> resources, JCTree.JCBlock block, int depth)

pack-priv JCTree

Returns:

a desugared try-with-resources tree, or the original try block if there are no resources to manage.
makeTwrTry
(JCTree.JCTry
The try statement to inspect.
tree
)

Optionally replace a try statement with the desugaring of a try-with-resources statement.

pack-priv JCTree.JCUnary
makeUnary(JCTree.Tag
The operators tree tag.
optag
,
JCTree.JCExpression
The operator's argument.
arg
)

Make an attributed unary expression.

pack-priv Lower.EnumMapping
private boolean
pack-priv boolean
needsPrivateAccess(Symbol sym)

Do we need an access method to reference private symbol?

pack-priv boolean
needsProtectedAccess(Symbol sym, JCTree tree)

Do we need an access method to reference symbol in other package?

private boolean
private Symbol.ClassSymbol
outerCacheClass()

Return the symbol of a class to contain a cache of compiler-generated statics such as class$ and the $assertionsDisabled flag.

pack-priv JCTree.JCVariableDecl
outerThisDef(int
The source code position of the definition.
pos
,
Symbol.MethodSymbol
The method in which the definition goes.
owner
)

Definition for this$n field.

pack-priv JCTree.JCVariableDecl
outerThisDef(int
The source code position of the definition.
pos
,
Symbol.ClassSymbol
The class in which the definition goes.
owner
)

Definition for this$n field.

pack-priv Name
outerThisName(Type
The class referenced by the this$n field
type
,
Symbol owner)

The name of a this$n field

private void
patchTargets(JCTree body, final JCTree src, final JCTree dest)

Patch up break and continue targets.

pack-priv Name
proxyName(Name name, int index)

The name of a free variable proxy.

private List<Symbol.VarSymbol>
private boolean
pack-priv void
private Name
public <T extends JCTree> T
translate(T tree)

Overrides com.sun.tools.javac.tree.TreeTranslator.translate.

Visitor method: Translate a single node.

public <T extends JCTree.JCExpression> T
translate(T tree, Type type)

Visitor method: Translate a single node, boxing or unboxing if needed.

public <T extends JCTree> T
translate(T tree, JCTree.JCExpression enclOp)

Visitor method: Translate tree.

public <T extends JCTree.JCExpression> List<T>
translate(List<T> trees, Type type)

Visitor method: Translate list of trees.

public JCTree.JCMethodDecl
public List<JCTree>
translateTopLevelClass(Env<AttrContext>
The attribution environment current at the class definition. We need this for resolving some additional symbols.
env
,
JCTree
The tree representing the class definition.
cdef
,
TreeMaker make)

Translate a toplevel class and return a list consisting of the translated class and translated versions of all inner classes.

private static JCTree.Tag
treeTag(Symbol.OperatorSymbol operator)

Return tree tag for assignment operation corresponding to given binary operator.

pack-priv JCTree.JCExpression
unbox(JCTree.JCExpression tree, Type primitive)

Unbox an object to a primitive value.

private boolean
public void
public void
private void
visitArrayForeachLoop(JCTree.JCEnhancedForLoop tree)

A statement of the form

    for ( T v : arrayexpr ) stmt;
public void
visitAssert(JCTree.JCAssert tree)

Overrides com.sun.tools.javac.tree.TreeTranslator.visitAssert.

Visitor method for assert statements.

public void
public void
public void
public void
private JCTree
public void
public void
public void
visitConditional(JCTree.JCConditional tree)

Overrides com.sun.tools.javac.tree.TreeTranslator.visitConditional.

Visitor method for conditional expressions.

public void
private void
visitEnumConstantDef(JCTree.JCVariableDecl var, int ordinal)

Translate an enumeration constant and its initializer.

private void
visitEnumDef(JCTree.JCClassDecl tree)

Translate an enum class.

public JCTree
public void
public void
public void
public void
visitIf(JCTree.JCIf tree)

Overrides com.sun.tools.javac.tree.TreeTranslator.visitIf.

Visitor method for if statements.

public void
private void
visitIterableForeachLoop(JCTree.JCEnhancedForLoop tree)

A statement of the form

    for ( T v : coll ) stmt ;
public void
public void
public void
private void
public void
public void
public void
public void
public void
visitParens(JCTree.JCParens tree)

Overrides com.sun.tools.javac.tree.TreeTranslator.visitParens.

Visitor method for parenthesized expressions.

private void
visitRecordDef(JCTree.JCClassDecl tree)

Translate a record.

public void
public void
public JCTree
public void
public void
public void
public void
public void
visitTypeTest(JCTree.JCInstanceOf tree)

Overrides com.sun.tools.javac.tree.TreeTranslator.visitTypeTest.

All the exactness checks between primitive types that require a run-time check are in java.lang.runtime.ExactConversionsSupport.

public void
public void
public void
public void
Inherited from com.sun.tools.javac.tree.TreeTranslator:
translatetranslateAnnotationstranslateCasestranslateCatcherstranslateTypeParamstranslateVarDefsvisitAnnotatedTypevisitAnyPatternvisitBindingPatternvisitCasevisitCatchvisitConstantCaseLabelvisitContinuevisitDefaultCaseLabelvisitErroneousvisitExecvisitImportvisitLabelledvisitLiteralvisitModifiersvisitModuleImportvisitPatternCaseLabelvisitRecordPatternvisitReferencevisitSkipvisitSynchronizedvisitThrowvisitTopLevelvisitTreevisitTypeApplyvisitTypeArrayvisitTypeBoundKindvisitTypeIdentvisitTypeIntersectionvisitTypeParametervisitTypeUnionvisitVarTypevisitWildcard