1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Lower.java Fri Nov 23 15:13:45 2012 +0000 1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java Thu Nov 29 09:41:48 2012 +0000 1.3 @@ -138,6 +138,10 @@ 1.4 */ 1.5 Map<ClassSymbol, JCClassDecl> classdefs; 1.6 1.7 + /** A hash table mapping local classes to a list of pruned trees. 1.8 + */ 1.9 + public Map<ClassSymbol, List<JCTree>> prunedTree = new WeakHashMap<ClassSymbol, List<JCTree>>(); 1.10 + 1.11 /** A hash table mapping virtual accessed symbols in outer subclasses 1.12 * to the actually referred symbol in superclasses. 1.13 */ 1.14 @@ -1039,6 +1043,12 @@ 1.15 } 1.16 } 1.17 1.18 + private void addPrunedInfo(JCTree tree) { 1.19 + List<JCTree> infoList = prunedTree.get(currentClass); 1.20 + infoList = (infoList == null) ? List.of(tree) : infoList.prepend(tree); 1.21 + prunedTree.put(currentClass, infoList); 1.22 + } 1.23 + 1.24 /** Ensure that identifier is accessible, return tree accessing the identifier. 1.25 * @param sym The accessed symbol. 1.26 * @param tree The tree referring to the symbol. 1.27 @@ -1111,7 +1121,10 @@ 1.28 // Constants are replaced by their constant value. 1.29 if (sym.kind == VAR) { 1.30 Object cv = ((VarSymbol)sym).getConstValue(); 1.31 - if (cv != null) return makeLit(sym.type, cv); 1.32 + if (cv != null) { 1.33 + addPrunedInfo(tree); 1.34 + return makeLit(sym.type, cv); 1.35 + } 1.36 } 1.37 1.38 // Private variables and methods are replaced by calls 1.39 @@ -2746,12 +2759,15 @@ 1.40 1.41 /** Visitor method for conditional expressions. 1.42 */ 1.43 + @Override 1.44 public void visitConditional(JCConditional tree) { 1.45 JCTree cond = tree.cond = translate(tree.cond, syms.booleanType); 1.46 if (cond.type.isTrue()) { 1.47 result = convert(translate(tree.truepart, tree.type), tree.type); 1.48 + addPrunedInfo(cond); 1.49 } else if (cond.type.isFalse()) { 1.50 result = convert(translate(tree.falsepart, tree.type), tree.type); 1.51 + addPrunedInfo(cond); 1.52 } else { 1.53 // Condition is not a compile-time constant. 1.54 tree.truepart = translate(tree.truepart, tree.type); 1.55 @@ -2760,14 +2776,14 @@ 1.56 } 1.57 } 1.58 //where 1.59 - private JCTree convert(JCTree tree, Type pt) { 1.60 - if (tree.type == pt || tree.type.hasTag(BOT)) 1.61 - return tree; 1.62 - JCTree result = make_at(tree.pos()).TypeCast(make.Type(pt), (JCExpression)tree); 1.63 - result.type = (tree.type.constValue() != null) ? cfolder.coerce(tree.type, pt) 1.64 - : pt; 1.65 - return result; 1.66 - } 1.67 + private JCTree convert(JCTree tree, Type pt) { 1.68 + if (tree.type == pt || tree.type.hasTag(BOT)) 1.69 + return tree; 1.70 + JCTree result = make_at(tree.pos()).TypeCast(make.Type(pt), (JCExpression)tree); 1.71 + result.type = (tree.type.constValue() != null) ? cfolder.coerce(tree.type, pt) 1.72 + : pt; 1.73 + return result; 1.74 + } 1.75 1.76 /** Visitor method for if statements. 1.77 */ 1.78 @@ -2775,12 +2791,14 @@ 1.79 JCTree cond = tree.cond = translate(tree.cond, syms.booleanType); 1.80 if (cond.type.isTrue()) { 1.81 result = translate(tree.thenpart); 1.82 + addPrunedInfo(cond); 1.83 } else if (cond.type.isFalse()) { 1.84 if (tree.elsepart != null) { 1.85 result = translate(tree.elsepart); 1.86 } else { 1.87 result = make.Skip(); 1.88 } 1.89 + addPrunedInfo(cond); 1.90 } else { 1.91 // Condition is not a compile-time constant. 1.92 tree.thenpart = translate(tree.thenpart);