diff -r 1f41a5758cf7 -r 969c96b980b7 src/share/classes/com/sun/tools/javac/comp/Lower.java --- a/src/share/classes/com/sun/tools/javac/comp/Lower.java Fri Nov 23 15:13:45 2012 +0000 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java Thu Nov 29 09:41:48 2012 +0000 @@ -138,6 +138,10 @@ */ Map classdefs; + /** A hash table mapping local classes to a list of pruned trees. + */ + public Map> prunedTree = new WeakHashMap>(); + /** A hash table mapping virtual accessed symbols in outer subclasses * to the actually referred symbol in superclasses. */ @@ -1039,6 +1043,12 @@ } } + private void addPrunedInfo(JCTree tree) { + List infoList = prunedTree.get(currentClass); + infoList = (infoList == null) ? List.of(tree) : infoList.prepend(tree); + prunedTree.put(currentClass, infoList); + } + /** Ensure that identifier is accessible, return tree accessing the identifier. * @param sym The accessed symbol. * @param tree The tree referring to the symbol. @@ -1111,7 +1121,10 @@ // Constants are replaced by their constant value. if (sym.kind == VAR) { Object cv = ((VarSymbol)sym).getConstValue(); - if (cv != null) return makeLit(sym.type, cv); + if (cv != null) { + addPrunedInfo(tree); + return makeLit(sym.type, cv); + } } // Private variables and methods are replaced by calls @@ -2746,12 +2759,15 @@ /** Visitor method for conditional expressions. */ + @Override public void visitConditional(JCConditional tree) { JCTree cond = tree.cond = translate(tree.cond, syms.booleanType); if (cond.type.isTrue()) { result = convert(translate(tree.truepart, tree.type), tree.type); + addPrunedInfo(cond); } else if (cond.type.isFalse()) { result = convert(translate(tree.falsepart, tree.type), tree.type); + addPrunedInfo(cond); } else { // Condition is not a compile-time constant. tree.truepart = translate(tree.truepart, tree.type); @@ -2760,14 +2776,14 @@ } } //where - private JCTree convert(JCTree tree, Type pt) { - if (tree.type == pt || tree.type.hasTag(BOT)) - return tree; - JCTree result = make_at(tree.pos()).TypeCast(make.Type(pt), (JCExpression)tree); - result.type = (tree.type.constValue() != null) ? cfolder.coerce(tree.type, pt) - : pt; - return result; - } + private JCTree convert(JCTree tree, Type pt) { + if (tree.type == pt || tree.type.hasTag(BOT)) + return tree; + JCTree result = make_at(tree.pos()).TypeCast(make.Type(pt), (JCExpression)tree); + result.type = (tree.type.constValue() != null) ? cfolder.coerce(tree.type, pt) + : pt; + return result; + } /** Visitor method for if statements. */ @@ -2775,12 +2791,14 @@ JCTree cond = tree.cond = translate(tree.cond, syms.booleanType); if (cond.type.isTrue()) { result = translate(tree.thenpart); + addPrunedInfo(cond); } else if (cond.type.isFalse()) { if (tree.elsepart != null) { result = translate(tree.elsepart); } else { result = make.Skip(); } + addPrunedInfo(cond); } else { // Condition is not a compile-time constant. tree.thenpart = translate(tree.thenpart);