src/share/classes/com/sun/tools/javac/comp/Lower.java
Print this page
*** 1426,1453 ****
while (owner.kind == TYP && ((ClassSymbol)owner).members().lookup(result).scope != null)
result = names.fromString(result.toString() + target.syntheticNameChar());
return result;
}
! /** Definition for this$n field.
! * @param pos The source code position of the definition.
! * @param owner The class in which the definition goes.
! */
! JCVariableDecl outerThisDef(int pos, Symbol owner) {
! long flags = FINAL | SYNTHETIC;
if (owner.kind == TYP &&
target.usePrivateSyntheticFields())
flags |= PRIVATE;
Type target = types.erasure(owner.enclClass().type.getEnclosingType());
! VarSymbol outerThis = new VarSymbol(
! flags, outerThisName(target, owner), target, owner);
outerThisStack = outerThisStack.prepend(outerThis);
! JCVariableDecl vd = make.at(pos).VarDef(outerThis, null);
vd.vartype = access(vd.vartype);
return vd;
}
/** Return a list of trees that load the free variables in given list,
* in reverse order.
* @param pos The source code position to be used for the trees.
* @param freevars The list of free variables.
*/
--- 1426,1480 ----
while (owner.kind == TYP && ((ClassSymbol)owner).members().lookup(result).scope != null)
result = names.fromString(result.toString() + target.syntheticNameChar());
return result;
}
! private VarSymbol makeOuterThisVarSymbol(Symbol owner, long flags) {
if (owner.kind == TYP &&
target.usePrivateSyntheticFields())
flags |= PRIVATE;
Type target = types.erasure(owner.enclClass().type.getEnclosingType());
! VarSymbol outerThis =
! new VarSymbol(flags, outerThisName(target, owner), target, owner);
outerThisStack = outerThisStack.prepend(outerThis);
! return outerThis;
! }
!
! private JCVariableDecl makeOuterThisVarDecl(int pos, VarSymbol sym) {
! JCVariableDecl vd = make.at(pos).VarDef(sym, null);
vd.vartype = access(vd.vartype);
return vd;
}
+ /** Definition for this$n field.
+ * @param pos The source code position of the definition.
+ * @param owner The method in which the definition goes.
+ */
+ JCVariableDecl outerThisDef(int pos, MethodSymbol owner) {
+ ClassSymbol c = owner.enclClass();
+ boolean isMandated =
+ // Anonymous constructors
+ (owner.isConstructor() && owner.isAnonymous()) ||
+ // Constructors of non-private inner member classes
+ (owner.isConstructor() && c.isInner() &&
+ !c.isPrivate() && !c.isStatic());
+ long flags =
+ FINAL | (isMandated ? MANDATED : SYNTHETIC);
+ VarSymbol outerThis = makeOuterThisVarSymbol(owner, flags);
+ owner.extraParams = owner.extraParams.prepend(outerThis);
+ return makeOuterThisVarDecl(pos, outerThis);
+ }
+
+ /** Definition for this$n field.
+ * @param pos The source code position of the definition.
+ * @param owner The class in which the definition goes.
+ */
+ JCVariableDecl outerThisDef(int pos, ClassSymbol owner) {
+ VarSymbol outerThis = makeOuterThisVarSymbol(owner, FINAL | SYNTHETIC);
+ return makeOuterThisVarDecl(pos, outerThis);
+ }
+
/** Return a list of trees that load the free variables in given list,
* in reverse order.
* @param pos The source code position to be used for the trees.
* @param freevars The list of free variables.
*/
*** 2549,2569 ****
JCVariableDecl nameParam = make_at(tree.pos()).
Param(names.fromString(target.syntheticNameChar() +
"enum" + target.syntheticNameChar() + "name"),
syms.stringType, tree.sym);
nameParam.mods.flags |= SYNTHETIC; nameParam.sym.flags_field |= SYNTHETIC;
-
JCVariableDecl ordParam = make.
Param(names.fromString(target.syntheticNameChar() +
"enum" + target.syntheticNameChar() +
"ordinal"),
syms.intType, tree.sym);
ordParam.mods.flags |= SYNTHETIC; ordParam.sym.flags_field |= SYNTHETIC;
tree.params = tree.params.prepend(ordParam).prepend(nameParam);
MethodSymbol m = tree.sym;
Type olderasure = m.erasure(types);
m.erasure_field = new MethodType(
olderasure.getParameterTypes().prepend(syms.intType).prepend(syms.stringType),
olderasure.getReturnType(),
olderasure.getThrownTypes(),
--- 2576,2597 ----
JCVariableDecl nameParam = make_at(tree.pos()).
Param(names.fromString(target.syntheticNameChar() +
"enum" + target.syntheticNameChar() + "name"),
syms.stringType, tree.sym);
nameParam.mods.flags |= SYNTHETIC; nameParam.sym.flags_field |= SYNTHETIC;
JCVariableDecl ordParam = make.
Param(names.fromString(target.syntheticNameChar() +
"enum" + target.syntheticNameChar() +
"ordinal"),
syms.intType, tree.sym);
ordParam.mods.flags |= SYNTHETIC; ordParam.sym.flags_field |= SYNTHETIC;
tree.params = tree.params.prepend(ordParam).prepend(nameParam);
MethodSymbol m = tree.sym;
+ m.extraParams = m.extraParams.prepend(ordParam.sym);
+ m.extraParams = m.extraParams.prepend(nameParam.sym);
Type olderasure = m.erasure(types);
m.erasure_field = new MethodType(
olderasure.getParameterTypes().prepend(syms.intType).prepend(syms.stringType),
olderasure.getReturnType(),
olderasure.getThrownTypes(),