changeset 1837:31e1151ef3cc

Merge
author chegar
date Mon, 17 Jun 2013 11:27:46 +0100
parents cc89c8333127 1eb09dba594a
children db6bf740a578
files
diffstat 26 files changed, 550 insertions(+), 71 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Tue Jun 11 09:25:57 2013 +0100
+++ b/.hgtags	Mon Jun 17 11:27:46 2013 +0100
@@ -214,3 +214,5 @@
 e19283cd30a43fca94d8f7639c73ef66db493b1e jdk8-b90
 997c0fae2b12108959387862be54b78ca0ae3fca jdk8-b91
 149890642a0ed5138a4f16fe08ddbfeb8f8a1cb4 jdk8-b92
+2c5a568ee36eb2d9471483b7a310c49ed545db55 jdk8-b93
+48c6e6ab7c815fd41d747f0218f8041c22f3a460 jdk8-b94
--- a/src/share/classes/com/sun/tools/javac/code/Flags.java	Tue Jun 11 09:25:57 2013 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Flags.java	Mon Jun 17 11:27:46 2013 +0100
@@ -278,6 +278,11 @@
      */
     public static final long BAD_OVERRIDE = 1L<<45;
 
+    /**
+     * Flag that indicates a signature polymorphic method (292).
+     */
+    public static final long SIGNATURE_POLYMORPHIC = 1L<<46;
+
     /** Modifier masks.
      */
     public static final int
--- a/src/share/classes/com/sun/tools/javac/code/Symbol.java	Tue Jun 11 09:25:57 2013 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java	Mon Jun 17 11:27:46 2013 +0100
@@ -1537,25 +1537,6 @@
                     getKind() == ElementKind.INSTANCE_INIT;
         }
 
-        /**
-         * A polymorphic signature method (JLS SE 7, 8.4.1) is a method that
-         * (i) is declared in the java.lang.invoke.MethodHandle class, (ii) takes
-         * a single variable arity parameter (iii) whose declared type is Object[],
-         * (iv) has a return type of Object and (v) is native.
-         */
-        public boolean isSignaturePolymorphic(Types types) {
-            List<Type> argtypes = type.getParameterTypes();
-            Type firstElemType = argtypes.nonEmpty() ?
-                    types.elemtype(argtypes.head) :
-                    null;
-            return owner == types.syms.methodHandleType.tsym &&
-                    argtypes.length() == 1 &&
-                    firstElemType != null &&
-                    types.isSameType(firstElemType, types.syms.objectType) &&
-                    types.isSameType(type.getReturnType(), types.syms.objectType) &&
-                    (flags() & NATIVE) != 0;
-        }
-
         public Attribute getDefaultValue() {
             return defaultValue;
         }
--- a/src/share/classes/com/sun/tools/javac/code/Types.java	Tue Jun 11 09:25:57 2013 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Mon Jun 17 11:27:46 2013 +0100
@@ -951,6 +951,22 @@
     }
 
     /**
+    * A polymorphic signature method (JLS SE 7, 8.4.1) is a method that
+    * (i) is declared in the java.lang.invoke.MethodHandle class, (ii) takes
+    * a single variable arity parameter (iii) whose declared type is Object[],
+    * (iv) has a return type of Object and (v) is native.
+    */
+   public boolean isSignaturePolymorphic(MethodSymbol msym) {
+       List<Type> argtypes = msym.type.getParameterTypes();
+       return (msym.flags_field & NATIVE) != 0 &&
+               msym.owner == syms.methodHandleType.tsym &&
+               argtypes.tail.tail == null &&
+               argtypes.head.hasTag(TypeTag.ARRAY) &&
+               msym.type.getReturnType().tsym == syms.objectType.tsym &&
+               ((ArrayType)argtypes.head).elemtype.tsym == syms.objectType.tsym;
+   }
+
+    /**
      * Is t the same type as s?
      */
     public boolean isSameType(Type t, Type s) {
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Jun 11 09:25:57 2013 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Jun 17 11:27:46 2013 +0100
@@ -3405,7 +3405,7 @@
                      Env<AttrContext> env,
                      ResultInfo resultInfo) {
             boolean isPolymorhicSignature =
-                sym.kind == MTH && ((MethodSymbol)sym.baseSymbol()).isSignaturePolymorphic(types);
+                (sym.baseSymbol().flags() & SIGNATURE_POLYMORPHIC) != 0;
             return isPolymorhicSignature ?
                     checkSigPolyMethodId(tree, site, sym, env, resultInfo) :
                     checkMethodIdInternal(tree, site, sym, env, resultInfo);
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Tue Jun 11 09:25:57 2013 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Mon Jun 17 11:27:46 2013 +0100
@@ -909,7 +909,7 @@
                                   "unchecked.generic.array.creation",
                                   argtype);
             }
-            if (!((MethodSymbol)sym.baseSymbol()).isSignaturePolymorphic(types)) {
+            if ((sym.baseSymbol().flags() & SIGNATURE_POLYMORPHIC) == 0) {
                 TreeInfo.setVarargsElement(env.tree, types.elemtype(argtype));
             }
          }
--- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Tue Jun 11 09:25:57 2013 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Mon Jun 17 11:27:46 2013 +0100
@@ -68,6 +68,8 @@
  */
 public class LambdaToMethod extends TreeTranslator {
 
+    private JCDiagnostic.Factory diags;
+    private Log log;
     private Lower lower;
     private Names names;
     private Symtab syms;
@@ -89,6 +91,9 @@
     /** info about the current class being processed */
     private KlassInfo kInfo;
 
+    /** dump statistics about lambda code generation */
+    private boolean dumpLambdaToMethodStats;
+
     /** Flag for alternate metafactories indicating the lambda object is intended to be serializable */
     public static final int FLAG_SERIALIZABLE = 1 << 0;
 
@@ -146,6 +151,8 @@
     }
 
     private LambdaToMethod(Context context) {
+        diags = JCDiagnostic.Factory.instance(context);
+        log = Log.instance(context);
         lower = Lower.instance(context);
         names = Names.instance(context);
         syms = Symtab.instance(context);
@@ -154,6 +161,8 @@
         types = Types.instance(context);
         transTypes = TransTypes.instance(context);
         analyzer = new LambdaAnalyzerPreprocessor();
+        Options options = Options.instance(context);
+        dumpLambdaToMethodStats = options.isSet("dumpLambdaToMethodStats");
     }
     // </editor-fold>
 
@@ -1101,7 +1110,9 @@
             Map<String, Integer> prevSerializableLambdaCount =
                     serializableLambdaCounts;
             Map<ClassSymbol, Symbol> prevClinits = clinits;
+            DiagnosticSource prevSource = log.currentSource();
             try {
+                log.useSource(tree.sym.sourcefile);
                 serializableLambdaCounts = new HashMap<String, Integer>();
                 prevClinits = new HashMap<ClassSymbol, Symbol>();
                 if (tree.sym.owner.kind == MTH) {
@@ -1126,6 +1137,7 @@
                 super.visitClassDef(tree);
             }
             finally {
+                log.useSource(prevSource.getFile());
                 frameStack = prevStack;
                 serializableLambdaCounts = prevSerializableLambdaCount;
                 clinits = prevClinits;
@@ -1685,6 +1697,9 @@
                 }
                 Name name = isSerializable() ? serializedLambdaName(owner) : lambdaName();
                 this.translatedSym = makeSyntheticMethod(0, name, null, owner.enclClass());
+                if (dumpLambdaToMethodStats) {
+                    log.note(tree, "lambda.stat", needsAltMetafactory(), translatedSym);
+                }
             }
 
             /**
@@ -1841,6 +1856,11 @@
                                               lambdaName().append(names.fromString("$bridge")), null,
                                               owner.enclClass())
                         : null;
+                if (dumpLambdaToMethodStats) {
+                    String key = bridgeSym == null ?
+                            "mref.stat" : "mref.stat.1";
+                    log.note(tree, key, needsAltMetafactory(), bridgeSym);
+                }
             }
 
             /**
--- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Tue Jun 11 09:25:57 2013 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Mon Jun 17 11:27:46 2013 +0100
@@ -560,6 +560,10 @@
             chk.setDeferredLintHandler(prevLintHandler);
         }
 
+        if (types.isSignaturePolymorphic(m)) {
+            m.flags_field |= SIGNATURE_POLYMORPHIC;
+        }
+
         // Set m.params
         ListBuffer<VarSymbol> params = new ListBuffer<VarSymbol>();
         JCVariableDecl lastParam = null;
--- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Tue Jun 11 09:25:57 2013 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Mon Jun 17 11:27:46 2013 +0100
@@ -2267,7 +2267,7 @@
                     sym = super.access(env, pos, location, sym);
                 } else if (allowMethodHandles) {
                     MethodSymbol msym = (MethodSymbol)sym;
-                    if (msym.isSignaturePolymorphic(types)) {
+                    if ((msym.flags() & SIGNATURE_POLYMORPHIC) != 0) {
                         return findPolymorphicSignatureInstance(env, sym, argtypes);
                     }
                 }
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Tue Jun 11 09:25:57 2013 +0100
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Mon Jun 17 11:27:46 2013 +0100
@@ -1985,6 +1985,9 @@
                                       syms.methodClass);
         }
         MethodSymbol m = new MethodSymbol(flags, name, type, currentOwner);
+        if (types.isSignaturePolymorphic(m)) {
+            m.flags_field |= SIGNATURE_POLYMORPHIC;
+        }
         if (saveParameterNames)
             initParameterNames(m);
         Symbol prevOwner = currentOwner;
--- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Tue Jun 11 09:25:57 2013 +0100
+++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Jun 17 11:27:46 2013 +0100
@@ -1163,6 +1163,23 @@
 compiler.note.potential.lambda.found=\
     This anonymous inner class creation can be turned into a lambda expression.
 
+# 0: boolean, 1: symbol
+compiler.note.lambda.stat=\
+    Translating lambda expression\n\
+    alternate metafactory = {0}\n\
+    synthetic method = {1}
+
+# 0: boolean, 1: unused
+compiler.note.mref.stat=\
+    Translating method reference\n\
+    alternate metafactory = {0}\n\
+
+# 0: boolean, 1: symbol
+compiler.note.mref.stat.1=\
+    Translating method reference\n\
+    alternate metafactory = {0}\n\
+    bridge method = {1}
+
 compiler.note.note=\
     Note:\u0020
 
@@ -2187,7 +2204,7 @@
 
 compiler.warn.underscore.as.identifier=\
     ''_'' used as an identifier\n\
-    (use of ''_'' as an identifier might not be supported in future releases)
+    (use of ''_'' as an identifier might not be supported in releases after Java SE 8)
 
 compiler.err.enum.as.identifier=\
     as of release 5, ''enum'' is a keyword, and may not be used as an identifier\n\
--- a/src/share/classes/com/sun/tools/javap/JavapTask.java	Tue Jun 11 09:25:57 2013 +0100
+++ b/src/share/classes/com/sun/tools/javap/JavapTask.java	Mon Jun 17 11:27:46 2013 +0100
@@ -452,8 +452,7 @@
             }
 
             try {
-                boolean ok = run();
-                return ok ? EXIT_OK : EXIT_ERROR;
+                return run();
             } finally {
                 if (defaultFileManager != null) {
                     try {
@@ -569,12 +568,13 @@
     }
 
     public Boolean call() {
-        return run();
+        return run() == 0;
     }
 
-    public boolean run() {
-        if (classes == null || classes.size() == 0)
-            return false;
+    public int run() {
+        if (classes == null || classes.isEmpty()) {
+            return EXIT_ERROR;
+        }
 
         context.put(PrintWriter.class, log);
         ClassWriter classWriter = ClassWriter.instance(context);
@@ -583,54 +583,55 @@
 
         attributeFactory.setCompat(options.compat);
 
-        boolean ok = true;
+        int result = EXIT_OK;
 
         for (String className: classes) {
-            JavaFileObject fo;
             try {
-                writeClass(classWriter, className);
+                result = writeClass(classWriter, className);
             } catch (ConstantPoolException e) {
                 reportError("err.bad.constant.pool", className, e.getLocalizedMessage());
-                ok = false;
+                result = EXIT_ERROR;
             } catch (EOFException e) {
                 reportError("err.end.of.file", className);
-                ok = false;
+                result = EXIT_ERROR;
             } catch (FileNotFoundException e) {
                 reportError("err.file.not.found", e.getLocalizedMessage());
-                ok = false;
+                result = EXIT_ERROR;
             } catch (IOException e) {
                 //e.printStackTrace();
                 Object msg = e.getLocalizedMessage();
-                if (msg == null)
+                if (msg == null) {
                     msg = e;
+                }
                 reportError("err.ioerror", className, msg);
-                ok = false;
+                result = EXIT_ERROR;
             } catch (Throwable t) {
                 StringWriter sw = new StringWriter();
                 PrintWriter pw = new PrintWriter(sw);
                 t.printStackTrace(pw);
                 pw.close();
                 reportError("err.crash", t.toString(), sw.toString());
-                ok = false;
+                result = EXIT_ABNORMAL;
             }
         }
 
-        return ok;
+        return result;
     }
 
-    protected boolean writeClass(ClassWriter classWriter, String className)
+    protected int writeClass(ClassWriter classWriter, String className)
             throws IOException, ConstantPoolException {
         JavaFileObject fo = open(className);
         if (fo == null) {
             reportError("err.class.not.found", className);
-            return false;
+            return EXIT_ERROR;
         }
 
         ClassFileInfo cfInfo = read(fo);
         if (!className.endsWith(".class")) {
             String cfName = cfInfo.cf.getName();
-            if (!cfName.replaceAll("[/$]", ".").equals(className.replaceAll("[/$]", ".")))
+            if (!cfName.replaceAll("[/$]", ".").equals(className.replaceAll("[/$]", "."))) {
                 reportWarning("warn.unexpected.class", className, cfName.replace('/', '.'));
+            }
         }
         write(cfInfo);
 
@@ -640,7 +641,7 @@
             if (a instanceof InnerClasses_attribute) {
                 InnerClasses_attribute inners = (InnerClasses_attribute) a;
                 try {
-                    boolean ok = true;
+                    int result = EXIT_OK;
                     for (int i = 0; i < inners.classes.length; i++) {
                         int outerIndex = inners.classes[i].outer_class_info_index;
                         ConstantPool.CONSTANT_Class_info outerClassInfo = cf.constant_pool.getClassInfo(outerIndex);
@@ -651,21 +652,22 @@
                             String innerClassName = innerClassInfo.getName();
                             classWriter.println("// inner class " + innerClassName.replaceAll("[/$]", "."));
                             classWriter.println();
-                            ok = ok & writeClass(classWriter, innerClassName);
+                            result = writeClass(classWriter, innerClassName);
+                            if (result != EXIT_OK) return result;
                         }
                     }
-                    return ok;
+                    return result;
                 } catch (ConstantPoolException e) {
                     reportError("err.bad.innerclasses.attribute", className);
-                    return false;
+                    return EXIT_ERROR;
                 }
             } else if (a != null) {
                 reportError("err.bad.innerclasses.attribute", className);
-                return false;
+                return EXIT_ERROR;
             }
         }
 
-        return true;
+        return EXIT_OK;
     }
 
     protected JavaFileObject open(String className) throws IOException {
--- a/test/tools/javac/VersionOpt.java	Tue Jun 11 09:25:57 2013 +0100
+++ b/test/tools/javac/VersionOpt.java	Mon Jun 17 11:27:46 2013 +0100
@@ -1,6 +1,6 @@
 
 /*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -61,7 +61,7 @@
             javaHome = javaHome.getParentFile();
         File toolsJar = new File(new File(javaHome, "lib"), "tools.jar");
 
-        if (!javacHome.equals(toolsJar.toURI().toString())){
+        if (!javacHome.equalsIgnoreCase(toolsJar.toURI().toString())) {
             System.err.println("javac not found in tools.jar: " + javacHome);
             System.err.println("rest of test skipped");
             return;
--- a/test/tools/javac/api/6437999/Utf8.java	Tue Jun 11 09:25:57 2013 +0100
+++ b/test/tools/javac/api/6437999/Utf8.java	Mon Jun 17 11:27:46 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,6 +22,6 @@
  */
 
 /**
- * @author Peter von der Ahé
+ * @author Peter von der Ah\u00e9
  */
 class Utf8 {}
--- a/test/tools/javac/api/T6306137.java	Tue Jun 11 09:25:57 2013 +0100
+++ b/test/tools/javac/api/T6306137.java	Mon Jun 17 11:27:46 2013 +0100
@@ -27,7 +27,7 @@
  * @summary JSR 199: encoding option doesn't affect standard file manager
  * @compile -encoding utf-8 T6306137.java
  * @run main T6306137
- * @author  Peter von der Ahé
+ * @author  Peter von der Ah\u00e9
  */
 
 import java.io.File;
--- a/test/tools/javac/constDebug/ConstDebugTest.java	Tue Jun 11 09:25:57 2013 +0100
+++ b/test/tools/javac/constDebug/ConstDebugTest.java	Mon Jun 17 11:27:46 2013 +0100
@@ -25,26 +25,25 @@
  * @test
  * @bug 4645152 4785453
  * @summary javac compiler incorrectly inserts <clinit> when -g is specified
- * @library /tools/javac/lib
- * @build ToolBox
  * @run compile -g ConstDebugTest.java
  * @run main ConstDebugTest
  */
+import java.nio.file.Paths;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.Method;
 
-//original test: test/tools/javac/constDebug/ConstDebug.sh
 public class ConstDebugTest {
 
     public static final long l = 12;
 
     public static void main(String args[]) throws Exception {
-//        "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -g -d . -classpath .${PS}${TESTSRC} $1.java 2> ${TMP1}
-//        if "${TESTJAVA}${FS}bin${FS}javap" $1.class | grep clinit; then fail
-        ToolBox.JavaToolArgs javapArgs =
-                new ToolBox.JavaToolArgs().setAllArgs("-v",
-                "-classpath", System.getProperty("test.classes"), "ConstDebugTest.class");
-        if (ToolBox.javap(javapArgs).contains("clinit")) {
-            throw new AssertionError(
-                "javac should not create a <clinit> method for ConstDebugTest class");
+        ClassFile classFile = ClassFile.read(Paths.get(System.getProperty("test.classes"),
+                ConstDebugTest.class.getSimpleName() + ".class"));
+        for (Method method: classFile.methods) {
+            if (method.getName(classFile.constant_pool).equals("<clinit>")) {
+                throw new AssertionError(
+                    "javac should not create a <clinit> method for ConstDebugTest class");
+            }
         }
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/LambdaStat.java	Mon Jun 17 11:27:46 2013 +0100
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.note.lambda.stat
+// options: -XDdumpLambdaToMethodStats
+
+class LambdaStat {
+    Runnable r = ()->{};
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/MrefStat.java	Mon Jun 17 11:27:46 2013 +0100
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.note.mref.stat
+// options: -XDdumpLambdaToMethodStats
+
+class MrefStat {
+    Runnable r = MrefStat::m;
+
+    static void m() { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/MrefStat.java.rej	Mon Jun 17 11:27:46 2013 +0100
@@ -0,0 +1,34 @@
+--- MrefStat.java
++++ MrefStat.java
+@@ -0,0 +1,31 @@
++/*
++ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++// key: compiler.note.mref.stat
++// options: -XDdumpLambdaToMethodStats
++
++class MrefStat {
++    Runnable r = MrefStat::m;
++    
++    static void m() { }
++}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/MrefStat1.java	Mon Jun 17 11:27:46 2013 +0100
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.note.mref.stat.1
+// options: -XDdumpLambdaToMethodStats
+
+class MrefStat1 {
+
+    void m() { }
+
+    static class Sub extends MrefStat1 {
+        Runnable r = super::m;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/MrefStat1.java.rej	Mon Jun 17 11:27:46 2013 +0100
@@ -0,0 +1,37 @@
+--- MrefStat1.java
++++ MrefStat1.java
+@@ -0,0 +1,34 @@
++/*
++ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++// key: compiler.note.mref.stat.1
++// options: -XDdumpLambdaToMethodStats
++
++class MrefStat1 {    
++    
++    void m() { }
++    
++    static class Sub extends MrefStat1 {
++        Runnable r = super::m;
++    }
++}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/TestLambdaToMethodStats.java	Mon Jun 17 11:27:46 2013 +0100
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8013576
+ * @summary Add stat support to LambdaToMethod
+ * @library ../lib
+ * @build JavacTestingAbstractThreadedTest
+ * @run main/othervm TestLambdaToMethodStats
+ */
+
+// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
+// see JDK-8006746
+
+import java.net.URI;
+import java.util.Arrays;
+
+import javax.tools.Diagnostic;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.ClientCodeWrapper;
+import com.sun.tools.javac.util.JCDiagnostic;
+
+public class TestLambdaToMethodStats
+    extends JavacTestingAbstractThreadedTest
+    implements Runnable {
+
+    enum ExprKind {
+        LAMBDA("()->null"),
+        MREF1("this::g"),
+        MREF2("this::h");
+
+        String exprStr;
+
+        ExprKind(String exprStr) {
+            this.exprStr = exprStr;
+        }
+    }
+
+    enum TargetKind {
+        IMPLICIT(""),
+        SERIALIZABLE("(A & java.io.Serializable)");
+
+        String targetStr;
+
+        TargetKind(String targetStr) {
+            this.targetStr = targetStr;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        for (ExprKind ek : ExprKind.values()) {
+            for (TargetKind tk : TargetKind.values()) {
+                pool.execute(new TestLambdaToMethodStats(ek, tk));
+            }
+        }
+
+        checkAfterExec(true);
+    }
+
+    ExprKind ek;
+    TargetKind tk;
+    JavaSource source;
+    DiagnosticChecker diagChecker;
+
+
+    TestLambdaToMethodStats(ExprKind ek, TargetKind tk) {
+        this.ek = ek;
+        this.tk = tk;
+        this.source = new JavaSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String template = "interface A {\n" +
+                          "   Object o();\n" +
+                          "}\n" +
+                          "class Test {\n" +
+                          "   A a = #C#E;\n" +
+                          "   Object g() { return null; }\n" +
+                          "   Object h(Object... o) { return null; }\n" +
+                          "}";
+
+        String source;
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = template.replaceAll("#E", ek.exprStr)
+                    .replaceAll("#C", tk.targetStr);
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    public void run() {
+        JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker,
+                Arrays.asList("-XDdumpLambdaToMethodStats"),
+                null, Arrays.asList(source));
+        try {
+            ct.generate();
+        } catch (Throwable ex) {
+            throw new
+                AssertionError("Error thron when analyzing the following source:\n" +
+                    source.getCharContent(true));
+        }
+        check();
+    }
+
+    void check() {
+        checkCount.incrementAndGet();
+
+        boolean error = diagChecker.lambda !=
+                (ek == ExprKind.LAMBDA);
+
+        error |= diagChecker.bridge !=
+                (ek == ExprKind.MREF2);
+
+        error |= diagChecker.altMetafactory !=
+                (tk == TargetKind.SERIALIZABLE);
+
+        if (error) {
+            throw new AssertionError("Bad stat diagnostic found for source\n" +
+                    "lambda = " + diagChecker.lambda + "\n" +
+                    "bridge = " + diagChecker.bridge + "\n" +
+                    "altMF = " + diagChecker.altMetafactory + "\n" +
+                    source.source);
+        }
+    }
+
+    static class DiagnosticChecker
+        implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean altMetafactory;
+        boolean bridge;
+        boolean lambda;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            try {
+                if (diagnostic.getKind() == Diagnostic.Kind.NOTE) {
+                    switch (diagnostic.getCode()) {
+                        case "compiler.note.lambda.stat":
+                            lambda = true;
+                            break;
+                        case "compiler.note.mref.stat":
+                            lambda = false;
+                            bridge = false;
+                            break;
+                        case "compiler.note.mref.stat.1":
+                            lambda = false;
+                            bridge = true;
+                            break;
+                        default:
+                            throw new AssertionError("unexpected note: " + diagnostic.getCode());
+                    }
+                    ClientCodeWrapper.DiagnosticSourceUnwrapper dsu =
+                        (ClientCodeWrapper.DiagnosticSourceUnwrapper)diagnostic;
+                    altMetafactory = (Boolean)dsu.d.getArgs()[0];
+                }
+            } catch (RuntimeException t) {
+                t.printStackTrace();
+                throw t;
+            }
+        }
+    }
+}
--- a/test/tools/javap/8006334/JavapTaskCtorFailWithNPE.java	Tue Jun 11 09:25:57 2013 +0100
+++ b/test/tools/javap/8006334/JavapTaskCtorFailWithNPE.java	Mon Jun 17 11:27:46 2013 +0100
@@ -66,8 +66,7 @@
         JavaFileManager fm = JavapFileManager.create(dc, pw);
         JavapTask t = new JavapTask(pw, fm, dc, null,
                 Arrays.asList(classToCheck.getPath()));
-        boolean ok = t.run();
-        if (!ok)
+        if (t.run() != 0)
             throw new Error("javap failed unexpectedly");
 
         List<Diagnostic<? extends JavaFileObject>> diags = dc.getDiagnostics();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javap/8007907/JavapReturns0AfterClassNotFoundTest.java	Mon Jun 17 11:27:46 2013 +0100
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8007907
+ * @summary javap, method com.sun.tools.javap.Main.run returns 0 even in case
+ * of class not found error
+ */
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+public class JavapReturns0AfterClassNotFoundTest {
+
+    static final String fileNotFoundErrorMsg =
+            "Error:  class not found: Unexisting.class";
+    static final String exitCodeClassNotFoundAssertionMsg =
+            "Javap's exit code for class not found should be 1";
+    static final String classNotFoundMsgAssertionMsg =
+            "Javap's error message for class not found is incorrect";
+
+    public static void main(String args[]) throws Exception {
+        new JavapReturns0AfterClassNotFoundTest().run();
+    }
+
+    void run() throws IOException {
+        check(exitCodeClassNotFoundAssertionMsg, classNotFoundMsgAssertionMsg,
+                fileNotFoundErrorMsg, "-v", "Unexisting.class");
+    }
+
+    void check(String exitCodeAssertionMsg, String errMsgAssertionMsg,
+            String expectedErrMsg, String... params) {
+        int result;
+        StringWriter s;
+        String out;
+        try (PrintWriter pw = new PrintWriter(s = new StringWriter())) {
+            result = com.sun.tools.javap.Main.run(params, pw);
+            //no line separator, no problem
+            out = s.toString().trim();
+        }
+        if (result != 1) {
+            System.out.println("actual exit code " + result);
+            throw new AssertionError(exitCodeAssertionMsg);
+        }
+
+        if (!out.equals(expectedErrMsg)) {
+            System.out.println("actual " + out);
+            System.out.println("expected " + expectedErrMsg);
+            throw new AssertionError(errMsgAssertionMsg);
+        }
+    }
+
+}
--- a/test/tools/javap/T4777949.java	Tue Jun 11 09:25:57 2013 +0100
+++ b/test/tools/javap/T4777949.java	Mon Jun 17 11:27:46 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -87,11 +87,11 @@
         PrintWriter pw = new PrintWriter(sw);
         JavaFileManager fm = JavapFileManager.create(dc, pw);
         JavapTask t = new JavapTask(pw, fm, dc, args, classes);
-        boolean ok = t.run();
+        int ok = t.run();
 
         List<Diagnostic<? extends JavaFileObject>> diags = dc.getDiagnostics();
 
-        if (!ok)
+        if (ok != 0)
             error("javap failed unexpectedly");
 
         System.err.println("args=" + args + " classes=" + classes + "\n"
--- a/test/tools/javap/T7190862.java	Tue Jun 11 09:25:57 2013 +0100
+++ b/test/tools/javap/T7190862.java	Mon Jun 17 11:27:46 2013 +0100
@@ -96,8 +96,7 @@
         PrintWriter pw = new PrintWriter(sw);
         JavaFileManager fm = JavapFileManager.create(dc, pw);
         JavapTask t = new JavapTask(pw, fm, dc, args, classes);
-        boolean ok = t.run();
-        if (!ok)
+        if (t.run() != 0)
             throw new Error("javap failed unexpectedly");
 
         List<Diagnostic<? extends JavaFileObject>> diags = dc.getDiagnostics();