1.1 --- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Mon Jun 10 15:18:47 2013 +0100 1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Mon Jun 10 15:57:32 2013 +0100 1.3 @@ -68,6 +68,8 @@ 1.4 */ 1.5 public class LambdaToMethod extends TreeTranslator { 1.6 1.7 + private JCDiagnostic.Factory diags; 1.8 + private Log log; 1.9 private Lower lower; 1.10 private Names names; 1.11 private Symtab syms; 1.12 @@ -89,6 +91,9 @@ 1.13 /** info about the current class being processed */ 1.14 private KlassInfo kInfo; 1.15 1.16 + /** dump statistics about lambda code generation */ 1.17 + private boolean dumpLambdaToMethodStats; 1.18 + 1.19 /** Flag for alternate metafactories indicating the lambda object is intended to be serializable */ 1.20 public static final int FLAG_SERIALIZABLE = 1 << 0; 1.21 1.22 @@ -146,6 +151,8 @@ 1.23 } 1.24 1.25 private LambdaToMethod(Context context) { 1.26 + diags = JCDiagnostic.Factory.instance(context); 1.27 + log = Log.instance(context); 1.28 lower = Lower.instance(context); 1.29 names = Names.instance(context); 1.30 syms = Symtab.instance(context); 1.31 @@ -154,6 +161,8 @@ 1.32 types = Types.instance(context); 1.33 transTypes = TransTypes.instance(context); 1.34 analyzer = new LambdaAnalyzerPreprocessor(); 1.35 + Options options = Options.instance(context); 1.36 + dumpLambdaToMethodStats = options.isSet("dumpLambdaToMethodStats"); 1.37 } 1.38 // </editor-fold> 1.39 1.40 @@ -1101,7 +1110,9 @@ 1.41 Map<String, Integer> prevSerializableLambdaCount = 1.42 serializableLambdaCounts; 1.43 Map<ClassSymbol, Symbol> prevClinits = clinits; 1.44 + DiagnosticSource prevSource = log.currentSource(); 1.45 try { 1.46 + log.useSource(tree.sym.sourcefile); 1.47 serializableLambdaCounts = new HashMap<String, Integer>(); 1.48 prevClinits = new HashMap<ClassSymbol, Symbol>(); 1.49 if (tree.sym.owner.kind == MTH) { 1.50 @@ -1126,6 +1137,7 @@ 1.51 super.visitClassDef(tree); 1.52 } 1.53 finally { 1.54 + log.useSource(prevSource.getFile()); 1.55 frameStack = prevStack; 1.56 serializableLambdaCounts = prevSerializableLambdaCount; 1.57 clinits = prevClinits; 1.58 @@ -1685,6 +1697,9 @@ 1.59 } 1.60 Name name = isSerializable() ? serializedLambdaName(owner) : lambdaName(); 1.61 this.translatedSym = makeSyntheticMethod(0, name, null, owner.enclClass()); 1.62 + if (dumpLambdaToMethodStats) { 1.63 + log.note(tree, "lambda.stat", needsAltMetafactory(), translatedSym); 1.64 + } 1.65 } 1.66 1.67 /** 1.68 @@ -1841,6 +1856,11 @@ 1.69 lambdaName().append(names.fromString("$bridge")), null, 1.70 owner.enclClass()) 1.71 : null; 1.72 + if (dumpLambdaToMethodStats) { 1.73 + String key = bridgeSym == null ? 1.74 + "mref.stat" : "mref.stat.1"; 1.75 + log.note(tree, key, needsAltMetafactory(), bridgeSym); 1.76 + } 1.77 } 1.78 1.79 /**