Mon, 17 Jun 2013 11:27:46 +0100
Merge
1.1 --- a/.hgtags Tue Jun 11 09:25:57 2013 +0100 1.2 +++ b/.hgtags Mon Jun 17 11:27:46 2013 +0100 1.3 @@ -214,3 +214,5 @@ 1.4 e19283cd30a43fca94d8f7639c73ef66db493b1e jdk8-b90 1.5 997c0fae2b12108959387862be54b78ca0ae3fca jdk8-b91 1.6 149890642a0ed5138a4f16fe08ddbfeb8f8a1cb4 jdk8-b92 1.7 +2c5a568ee36eb2d9471483b7a310c49ed545db55 jdk8-b93 1.8 +48c6e6ab7c815fd41d747f0218f8041c22f3a460 jdk8-b94
2.1 --- a/src/share/classes/com/sun/tools/javac/code/Flags.java Tue Jun 11 09:25:57 2013 +0100 2.2 +++ b/src/share/classes/com/sun/tools/javac/code/Flags.java Mon Jun 17 11:27:46 2013 +0100 2.3 @@ -278,6 +278,11 @@ 2.4 */ 2.5 public static final long BAD_OVERRIDE = 1L<<45; 2.6 2.7 + /** 2.8 + * Flag that indicates a signature polymorphic method (292). 2.9 + */ 2.10 + public static final long SIGNATURE_POLYMORPHIC = 1L<<46; 2.11 + 2.12 /** Modifier masks. 2.13 */ 2.14 public static final int
3.1 --- a/src/share/classes/com/sun/tools/javac/code/Symbol.java Tue Jun 11 09:25:57 2013 +0100 3.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java Mon Jun 17 11:27:46 2013 +0100 3.3 @@ -1537,25 +1537,6 @@ 3.4 getKind() == ElementKind.INSTANCE_INIT; 3.5 } 3.6 3.7 - /** 3.8 - * A polymorphic signature method (JLS SE 7, 8.4.1) is a method that 3.9 - * (i) is declared in the java.lang.invoke.MethodHandle class, (ii) takes 3.10 - * a single variable arity parameter (iii) whose declared type is Object[], 3.11 - * (iv) has a return type of Object and (v) is native. 3.12 - */ 3.13 - public boolean isSignaturePolymorphic(Types types) { 3.14 - List<Type> argtypes = type.getParameterTypes(); 3.15 - Type firstElemType = argtypes.nonEmpty() ? 3.16 - types.elemtype(argtypes.head) : 3.17 - null; 3.18 - return owner == types.syms.methodHandleType.tsym && 3.19 - argtypes.length() == 1 && 3.20 - firstElemType != null && 3.21 - types.isSameType(firstElemType, types.syms.objectType) && 3.22 - types.isSameType(type.getReturnType(), types.syms.objectType) && 3.23 - (flags() & NATIVE) != 0; 3.24 - } 3.25 - 3.26 public Attribute getDefaultValue() { 3.27 return defaultValue; 3.28 }
4.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java Tue Jun 11 09:25:57 2013 +0100 4.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Mon Jun 17 11:27:46 2013 +0100 4.3 @@ -951,6 +951,22 @@ 4.4 } 4.5 4.6 /** 4.7 + * A polymorphic signature method (JLS SE 7, 8.4.1) is a method that 4.8 + * (i) is declared in the java.lang.invoke.MethodHandle class, (ii) takes 4.9 + * a single variable arity parameter (iii) whose declared type is Object[], 4.10 + * (iv) has a return type of Object and (v) is native. 4.11 + */ 4.12 + public boolean isSignaturePolymorphic(MethodSymbol msym) { 4.13 + List<Type> argtypes = msym.type.getParameterTypes(); 4.14 + return (msym.flags_field & NATIVE) != 0 && 4.15 + msym.owner == syms.methodHandleType.tsym && 4.16 + argtypes.tail.tail == null && 4.17 + argtypes.head.hasTag(TypeTag.ARRAY) && 4.18 + msym.type.getReturnType().tsym == syms.objectType.tsym && 4.19 + ((ArrayType)argtypes.head).elemtype.tsym == syms.objectType.tsym; 4.20 + } 4.21 + 4.22 + /** 4.23 * Is t the same type as s? 4.24 */ 4.25 public boolean isSameType(Type t, Type s) {
5.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Jun 11 09:25:57 2013 +0100 5.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Mon Jun 17 11:27:46 2013 +0100 5.3 @@ -3405,7 +3405,7 @@ 5.4 Env<AttrContext> env, 5.5 ResultInfo resultInfo) { 5.6 boolean isPolymorhicSignature = 5.7 - sym.kind == MTH && ((MethodSymbol)sym.baseSymbol()).isSignaturePolymorphic(types); 5.8 + (sym.baseSymbol().flags() & SIGNATURE_POLYMORPHIC) != 0; 5.9 return isPolymorhicSignature ? 5.10 checkSigPolyMethodId(tree, site, sym, env, resultInfo) : 5.11 checkMethodIdInternal(tree, site, sym, env, resultInfo);
6.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Tue Jun 11 09:25:57 2013 +0100 6.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Mon Jun 17 11:27:46 2013 +0100 6.3 @@ -909,7 +909,7 @@ 6.4 "unchecked.generic.array.creation", 6.5 argtype); 6.6 } 6.7 - if (!((MethodSymbol)sym.baseSymbol()).isSignaturePolymorphic(types)) { 6.8 + if ((sym.baseSymbol().flags() & SIGNATURE_POLYMORPHIC) == 0) { 6.9 TreeInfo.setVarargsElement(env.tree, types.elemtype(argtype)); 6.10 } 6.11 }
7.1 --- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Tue Jun 11 09:25:57 2013 +0100 7.2 +++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Mon Jun 17 11:27:46 2013 +0100 7.3 @@ -68,6 +68,8 @@ 7.4 */ 7.5 public class LambdaToMethod extends TreeTranslator { 7.6 7.7 + private JCDiagnostic.Factory diags; 7.8 + private Log log; 7.9 private Lower lower; 7.10 private Names names; 7.11 private Symtab syms; 7.12 @@ -89,6 +91,9 @@ 7.13 /** info about the current class being processed */ 7.14 private KlassInfo kInfo; 7.15 7.16 + /** dump statistics about lambda code generation */ 7.17 + private boolean dumpLambdaToMethodStats; 7.18 + 7.19 /** Flag for alternate metafactories indicating the lambda object is intended to be serializable */ 7.20 public static final int FLAG_SERIALIZABLE = 1 << 0; 7.21 7.22 @@ -146,6 +151,8 @@ 7.23 } 7.24 7.25 private LambdaToMethod(Context context) { 7.26 + diags = JCDiagnostic.Factory.instance(context); 7.27 + log = Log.instance(context); 7.28 lower = Lower.instance(context); 7.29 names = Names.instance(context); 7.30 syms = Symtab.instance(context); 7.31 @@ -154,6 +161,8 @@ 7.32 types = Types.instance(context); 7.33 transTypes = TransTypes.instance(context); 7.34 analyzer = new LambdaAnalyzerPreprocessor(); 7.35 + Options options = Options.instance(context); 7.36 + dumpLambdaToMethodStats = options.isSet("dumpLambdaToMethodStats"); 7.37 } 7.38 // </editor-fold> 7.39 7.40 @@ -1101,7 +1110,9 @@ 7.41 Map<String, Integer> prevSerializableLambdaCount = 7.42 serializableLambdaCounts; 7.43 Map<ClassSymbol, Symbol> prevClinits = clinits; 7.44 + DiagnosticSource prevSource = log.currentSource(); 7.45 try { 7.46 + log.useSource(tree.sym.sourcefile); 7.47 serializableLambdaCounts = new HashMap<String, Integer>(); 7.48 prevClinits = new HashMap<ClassSymbol, Symbol>(); 7.49 if (tree.sym.owner.kind == MTH) { 7.50 @@ -1126,6 +1137,7 @@ 7.51 super.visitClassDef(tree); 7.52 } 7.53 finally { 7.54 + log.useSource(prevSource.getFile()); 7.55 frameStack = prevStack; 7.56 serializableLambdaCounts = prevSerializableLambdaCount; 7.57 clinits = prevClinits; 7.58 @@ -1685,6 +1697,9 @@ 7.59 } 7.60 Name name = isSerializable() ? serializedLambdaName(owner) : lambdaName(); 7.61 this.translatedSym = makeSyntheticMethod(0, name, null, owner.enclClass()); 7.62 + if (dumpLambdaToMethodStats) { 7.63 + log.note(tree, "lambda.stat", needsAltMetafactory(), translatedSym); 7.64 + } 7.65 } 7.66 7.67 /** 7.68 @@ -1841,6 +1856,11 @@ 7.69 lambdaName().append(names.fromString("$bridge")), null, 7.70 owner.enclClass()) 7.71 : null; 7.72 + if (dumpLambdaToMethodStats) { 7.73 + String key = bridgeSym == null ? 7.74 + "mref.stat" : "mref.stat.1"; 7.75 + log.note(tree, key, needsAltMetafactory(), bridgeSym); 7.76 + } 7.77 } 7.78 7.79 /**
8.1 --- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Tue Jun 11 09:25:57 2013 +0100 8.2 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Mon Jun 17 11:27:46 2013 +0100 8.3 @@ -560,6 +560,10 @@ 8.4 chk.setDeferredLintHandler(prevLintHandler); 8.5 } 8.6 8.7 + if (types.isSignaturePolymorphic(m)) { 8.8 + m.flags_field |= SIGNATURE_POLYMORPHIC; 8.9 + } 8.10 + 8.11 // Set m.params 8.12 ListBuffer<VarSymbol> params = new ListBuffer<VarSymbol>(); 8.13 JCVariableDecl lastParam = null;
9.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Tue Jun 11 09:25:57 2013 +0100 9.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Mon Jun 17 11:27:46 2013 +0100 9.3 @@ -2267,7 +2267,7 @@ 9.4 sym = super.access(env, pos, location, sym); 9.5 } else if (allowMethodHandles) { 9.6 MethodSymbol msym = (MethodSymbol)sym; 9.7 - if (msym.isSignaturePolymorphic(types)) { 9.8 + if ((msym.flags() & SIGNATURE_POLYMORPHIC) != 0) { 9.9 return findPolymorphicSignatureInstance(env, sym, argtypes); 9.10 } 9.11 }
10.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Tue Jun 11 09:25:57 2013 +0100 10.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Mon Jun 17 11:27:46 2013 +0100 10.3 @@ -1985,6 +1985,9 @@ 10.4 syms.methodClass); 10.5 } 10.6 MethodSymbol m = new MethodSymbol(flags, name, type, currentOwner); 10.7 + if (types.isSignaturePolymorphic(m)) { 10.8 + m.flags_field |= SIGNATURE_POLYMORPHIC; 10.9 + } 10.10 if (saveParameterNames) 10.11 initParameterNames(m); 10.12 Symbol prevOwner = currentOwner;
11.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Tue Jun 11 09:25:57 2013 +0100 11.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Mon Jun 17 11:27:46 2013 +0100 11.3 @@ -1163,6 +1163,23 @@ 11.4 compiler.note.potential.lambda.found=\ 11.5 This anonymous inner class creation can be turned into a lambda expression. 11.6 11.7 +# 0: boolean, 1: symbol 11.8 +compiler.note.lambda.stat=\ 11.9 + Translating lambda expression\n\ 11.10 + alternate metafactory = {0}\n\ 11.11 + synthetic method = {1} 11.12 + 11.13 +# 0: boolean, 1: unused 11.14 +compiler.note.mref.stat=\ 11.15 + Translating method reference\n\ 11.16 + alternate metafactory = {0}\n\ 11.17 + 11.18 +# 0: boolean, 1: symbol 11.19 +compiler.note.mref.stat.1=\ 11.20 + Translating method reference\n\ 11.21 + alternate metafactory = {0}\n\ 11.22 + bridge method = {1} 11.23 + 11.24 compiler.note.note=\ 11.25 Note:\u0020 11.26 11.27 @@ -2187,7 +2204,7 @@ 11.28 11.29 compiler.warn.underscore.as.identifier=\ 11.30 ''_'' used as an identifier\n\ 11.31 - (use of ''_'' as an identifier might not be supported in future releases) 11.32 + (use of ''_'' as an identifier might not be supported in releases after Java SE 8) 11.33 11.34 compiler.err.enum.as.identifier=\ 11.35 as of release 5, ''enum'' is a keyword, and may not be used as an identifier\n\
12.1 --- a/src/share/classes/com/sun/tools/javap/JavapTask.java Tue Jun 11 09:25:57 2013 +0100 12.2 +++ b/src/share/classes/com/sun/tools/javap/JavapTask.java Mon Jun 17 11:27:46 2013 +0100 12.3 @@ -452,8 +452,7 @@ 12.4 } 12.5 12.6 try { 12.7 - boolean ok = run(); 12.8 - return ok ? EXIT_OK : EXIT_ERROR; 12.9 + return run(); 12.10 } finally { 12.11 if (defaultFileManager != null) { 12.12 try { 12.13 @@ -569,12 +568,13 @@ 12.14 } 12.15 12.16 public Boolean call() { 12.17 - return run(); 12.18 + return run() == 0; 12.19 } 12.20 12.21 - public boolean run() { 12.22 - if (classes == null || classes.size() == 0) 12.23 - return false; 12.24 + public int run() { 12.25 + if (classes == null || classes.isEmpty()) { 12.26 + return EXIT_ERROR; 12.27 + } 12.28 12.29 context.put(PrintWriter.class, log); 12.30 ClassWriter classWriter = ClassWriter.instance(context); 12.31 @@ -583,54 +583,55 @@ 12.32 12.33 attributeFactory.setCompat(options.compat); 12.34 12.35 - boolean ok = true; 12.36 + int result = EXIT_OK; 12.37 12.38 for (String className: classes) { 12.39 - JavaFileObject fo; 12.40 try { 12.41 - writeClass(classWriter, className); 12.42 + result = writeClass(classWriter, className); 12.43 } catch (ConstantPoolException e) { 12.44 reportError("err.bad.constant.pool", className, e.getLocalizedMessage()); 12.45 - ok = false; 12.46 + result = EXIT_ERROR; 12.47 } catch (EOFException e) { 12.48 reportError("err.end.of.file", className); 12.49 - ok = false; 12.50 + result = EXIT_ERROR; 12.51 } catch (FileNotFoundException e) { 12.52 reportError("err.file.not.found", e.getLocalizedMessage()); 12.53 - ok = false; 12.54 + result = EXIT_ERROR; 12.55 } catch (IOException e) { 12.56 //e.printStackTrace(); 12.57 Object msg = e.getLocalizedMessage(); 12.58 - if (msg == null) 12.59 + if (msg == null) { 12.60 msg = e; 12.61 + } 12.62 reportError("err.ioerror", className, msg); 12.63 - ok = false; 12.64 + result = EXIT_ERROR; 12.65 } catch (Throwable t) { 12.66 StringWriter sw = new StringWriter(); 12.67 PrintWriter pw = new PrintWriter(sw); 12.68 t.printStackTrace(pw); 12.69 pw.close(); 12.70 reportError("err.crash", t.toString(), sw.toString()); 12.71 - ok = false; 12.72 + result = EXIT_ABNORMAL; 12.73 } 12.74 } 12.75 12.76 - return ok; 12.77 + return result; 12.78 } 12.79 12.80 - protected boolean writeClass(ClassWriter classWriter, String className) 12.81 + protected int writeClass(ClassWriter classWriter, String className) 12.82 throws IOException, ConstantPoolException { 12.83 JavaFileObject fo = open(className); 12.84 if (fo == null) { 12.85 reportError("err.class.not.found", className); 12.86 - return false; 12.87 + return EXIT_ERROR; 12.88 } 12.89 12.90 ClassFileInfo cfInfo = read(fo); 12.91 if (!className.endsWith(".class")) { 12.92 String cfName = cfInfo.cf.getName(); 12.93 - if (!cfName.replaceAll("[/$]", ".").equals(className.replaceAll("[/$]", "."))) 12.94 + if (!cfName.replaceAll("[/$]", ".").equals(className.replaceAll("[/$]", "."))) { 12.95 reportWarning("warn.unexpected.class", className, cfName.replace('/', '.')); 12.96 + } 12.97 } 12.98 write(cfInfo); 12.99 12.100 @@ -640,7 +641,7 @@ 12.101 if (a instanceof InnerClasses_attribute) { 12.102 InnerClasses_attribute inners = (InnerClasses_attribute) a; 12.103 try { 12.104 - boolean ok = true; 12.105 + int result = EXIT_OK; 12.106 for (int i = 0; i < inners.classes.length; i++) { 12.107 int outerIndex = inners.classes[i].outer_class_info_index; 12.108 ConstantPool.CONSTANT_Class_info outerClassInfo = cf.constant_pool.getClassInfo(outerIndex); 12.109 @@ -651,21 +652,22 @@ 12.110 String innerClassName = innerClassInfo.getName(); 12.111 classWriter.println("// inner class " + innerClassName.replaceAll("[/$]", ".")); 12.112 classWriter.println(); 12.113 - ok = ok & writeClass(classWriter, innerClassName); 12.114 + result = writeClass(classWriter, innerClassName); 12.115 + if (result != EXIT_OK) return result; 12.116 } 12.117 } 12.118 - return ok; 12.119 + return result; 12.120 } catch (ConstantPoolException e) { 12.121 reportError("err.bad.innerclasses.attribute", className); 12.122 - return false; 12.123 + return EXIT_ERROR; 12.124 } 12.125 } else if (a != null) { 12.126 reportError("err.bad.innerclasses.attribute", className); 12.127 - return false; 12.128 + return EXIT_ERROR; 12.129 } 12.130 } 12.131 12.132 - return true; 12.133 + return EXIT_OK; 12.134 } 12.135 12.136 protected JavaFileObject open(String className) throws IOException {
13.1 --- a/test/tools/javac/VersionOpt.java Tue Jun 11 09:25:57 2013 +0100 13.2 +++ b/test/tools/javac/VersionOpt.java Mon Jun 17 11:27:46 2013 +0100 13.3 @@ -1,6 +1,6 @@ 13.4 13.5 /* 13.6 - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. 13.7 + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 13.8 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 13.9 * 13.10 * This code is free software; you can redistribute it and/or modify it 13.11 @@ -61,7 +61,7 @@ 13.12 javaHome = javaHome.getParentFile(); 13.13 File toolsJar = new File(new File(javaHome, "lib"), "tools.jar"); 13.14 13.15 - if (!javacHome.equals(toolsJar.toURI().toString())){ 13.16 + if (!javacHome.equalsIgnoreCase(toolsJar.toURI().toString())) { 13.17 System.err.println("javac not found in tools.jar: " + javacHome); 13.18 System.err.println("rest of test skipped"); 13.19 return;
14.1 --- a/test/tools/javac/api/6437999/Utf8.java Tue Jun 11 09:25:57 2013 +0100 14.2 +++ b/test/tools/javac/api/6437999/Utf8.java Mon Jun 17 11:27:46 2013 +0100 14.3 @@ -1,5 +1,5 @@ 14.4 /* 14.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 14.6 + * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. 14.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 14.8 * 14.9 * This code is free software; you can redistribute it and/or modify it 14.10 @@ -22,6 +22,6 @@ 14.11 */ 14.12 14.13 /** 14.14 - * @author Peter von der Ahé 14.15 + * @author Peter von der Ah\u00e9 14.16 */ 14.17 class Utf8 {}
15.1 --- a/test/tools/javac/api/T6306137.java Tue Jun 11 09:25:57 2013 +0100 15.2 +++ b/test/tools/javac/api/T6306137.java Mon Jun 17 11:27:46 2013 +0100 15.3 @@ -27,7 +27,7 @@ 15.4 * @summary JSR 199: encoding option doesn't affect standard file manager 15.5 * @compile -encoding utf-8 T6306137.java 15.6 * @run main T6306137 15.7 - * @author Peter von der Ahé 15.8 + * @author Peter von der Ah\u00e9 15.9 */ 15.10 15.11 import java.io.File;
16.1 --- a/test/tools/javac/constDebug/ConstDebugTest.java Tue Jun 11 09:25:57 2013 +0100 16.2 +++ b/test/tools/javac/constDebug/ConstDebugTest.java Mon Jun 17 11:27:46 2013 +0100 16.3 @@ -25,26 +25,25 @@ 16.4 * @test 16.5 * @bug 4645152 4785453 16.6 * @summary javac compiler incorrectly inserts <clinit> when -g is specified 16.7 - * @library /tools/javac/lib 16.8 - * @build ToolBox 16.9 * @run compile -g ConstDebugTest.java 16.10 * @run main ConstDebugTest 16.11 */ 16.12 +import java.nio.file.Paths; 16.13 +import com.sun.tools.classfile.ClassFile; 16.14 +import com.sun.tools.classfile.Method; 16.15 16.16 -//original test: test/tools/javac/constDebug/ConstDebug.sh 16.17 public class ConstDebugTest { 16.18 16.19 public static final long l = 12; 16.20 16.21 public static void main(String args[]) throws Exception { 16.22 -// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -g -d . -classpath .${PS}${TESTSRC} $1.java 2> ${TMP1} 16.23 -// if "${TESTJAVA}${FS}bin${FS}javap" $1.class | grep clinit; then fail 16.24 - ToolBox.JavaToolArgs javapArgs = 16.25 - new ToolBox.JavaToolArgs().setAllArgs("-v", 16.26 - "-classpath", System.getProperty("test.classes"), "ConstDebugTest.class"); 16.27 - if (ToolBox.javap(javapArgs).contains("clinit")) { 16.28 - throw new AssertionError( 16.29 - "javac should not create a <clinit> method for ConstDebugTest class"); 16.30 + ClassFile classFile = ClassFile.read(Paths.get(System.getProperty("test.classes"), 16.31 + ConstDebugTest.class.getSimpleName() + ".class")); 16.32 + for (Method method: classFile.methods) { 16.33 + if (method.getName(classFile.constant_pool).equals("<clinit>")) { 16.34 + throw new AssertionError( 16.35 + "javac should not create a <clinit> method for ConstDebugTest class"); 16.36 + } 16.37 } 16.38 } 16.39
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 17.2 +++ b/test/tools/javac/diags/examples/LambdaStat.java Mon Jun 17 11:27:46 2013 +0100 17.3 @@ -0,0 +1,29 @@ 17.4 +/* 17.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 17.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 17.7 + * 17.8 + * This code is free software; you can redistribute it and/or modify it 17.9 + * under the terms of the GNU General Public License version 2 only, as 17.10 + * published by the Free Software Foundation. 17.11 + * 17.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 17.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 17.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17.15 + * version 2 for more details (a copy is included in the LICENSE file that 17.16 + * accompanied this code). 17.17 + * 17.18 + * You should have received a copy of the GNU General Public License version 17.19 + * 2 along with this work; if not, write to the Free Software Foundation, 17.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17.21 + * 17.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 17.23 + * or visit www.oracle.com if you need additional information or have any 17.24 + * questions. 17.25 + */ 17.26 + 17.27 +// key: compiler.note.lambda.stat 17.28 +// options: -XDdumpLambdaToMethodStats 17.29 + 17.30 +class LambdaStat { 17.31 + Runnable r = ()->{}; 17.32 +}
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 18.2 +++ b/test/tools/javac/diags/examples/MrefStat.java Mon Jun 17 11:27:46 2013 +0100 18.3 @@ -0,0 +1,31 @@ 18.4 +/* 18.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 18.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 18.7 + * 18.8 + * This code is free software; you can redistribute it and/or modify it 18.9 + * under the terms of the GNU General Public License version 2 only, as 18.10 + * published by the Free Software Foundation. 18.11 + * 18.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 18.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 18.15 + * version 2 for more details (a copy is included in the LICENSE file that 18.16 + * accompanied this code). 18.17 + * 18.18 + * You should have received a copy of the GNU General Public License version 18.19 + * 2 along with this work; if not, write to the Free Software Foundation, 18.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18.21 + * 18.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 18.23 + * or visit www.oracle.com if you need additional information or have any 18.24 + * questions. 18.25 + */ 18.26 + 18.27 +// key: compiler.note.mref.stat 18.28 +// options: -XDdumpLambdaToMethodStats 18.29 + 18.30 +class MrefStat { 18.31 + Runnable r = MrefStat::m; 18.32 + 18.33 + static void m() { } 18.34 +}
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 19.2 +++ b/test/tools/javac/diags/examples/MrefStat.java.rej Mon Jun 17 11:27:46 2013 +0100 19.3 @@ -0,0 +1,34 @@ 19.4 +--- MrefStat.java 19.5 ++++ MrefStat.java 19.6 +@@ -0,0 +1,31 @@ 19.7 ++/* 19.8 ++ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 19.9 ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 19.10 ++ * 19.11 ++ * This code is free software; you can redistribute it and/or modify it 19.12 ++ * under the terms of the GNU General Public License version 2 only, as 19.13 ++ * published by the Free Software Foundation. 19.14 ++ * 19.15 ++ * This code is distributed in the hope that it will be useful, but WITHOUT 19.16 ++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 19.17 ++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19.18 ++ * version 2 for more details (a copy is included in the LICENSE file that 19.19 ++ * accompanied this code). 19.20 ++ * 19.21 ++ * You should have received a copy of the GNU General Public License version 19.22 ++ * 2 along with this work; if not, write to the Free Software Foundation, 19.23 ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19.24 ++ * 19.25 ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 19.26 ++ * or visit www.oracle.com if you need additional information or have any 19.27 ++ * questions. 19.28 ++ */ 19.29 ++ 19.30 ++// key: compiler.note.mref.stat 19.31 ++// options: -XDdumpLambdaToMethodStats 19.32 ++ 19.33 ++class MrefStat { 19.34 ++ Runnable r = MrefStat::m; 19.35 ++ 19.36 ++ static void m() { } 19.37 ++}
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 20.2 +++ b/test/tools/javac/diags/examples/MrefStat1.java Mon Jun 17 11:27:46 2013 +0100 20.3 @@ -0,0 +1,34 @@ 20.4 +/* 20.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 20.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 20.7 + * 20.8 + * This code is free software; you can redistribute it and/or modify it 20.9 + * under the terms of the GNU General Public License version 2 only, as 20.10 + * published by the Free Software Foundation. 20.11 + * 20.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 20.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20.15 + * version 2 for more details (a copy is included in the LICENSE file that 20.16 + * accompanied this code). 20.17 + * 20.18 + * You should have received a copy of the GNU General Public License version 20.19 + * 2 along with this work; if not, write to the Free Software Foundation, 20.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20.21 + * 20.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20.23 + * or visit www.oracle.com if you need additional information or have any 20.24 + * questions. 20.25 + */ 20.26 + 20.27 +// key: compiler.note.mref.stat.1 20.28 +// options: -XDdumpLambdaToMethodStats 20.29 + 20.30 +class MrefStat1 { 20.31 + 20.32 + void m() { } 20.33 + 20.34 + static class Sub extends MrefStat1 { 20.35 + Runnable r = super::m; 20.36 + } 20.37 +}
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 21.2 +++ b/test/tools/javac/diags/examples/MrefStat1.java.rej Mon Jun 17 11:27:46 2013 +0100 21.3 @@ -0,0 +1,37 @@ 21.4 +--- MrefStat1.java 21.5 ++++ MrefStat1.java 21.6 +@@ -0,0 +1,34 @@ 21.7 ++/* 21.8 ++ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 21.9 ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 21.10 ++ * 21.11 ++ * This code is free software; you can redistribute it and/or modify it 21.12 ++ * under the terms of the GNU General Public License version 2 only, as 21.13 ++ * published by the Free Software Foundation. 21.14 ++ * 21.15 ++ * This code is distributed in the hope that it will be useful, but WITHOUT 21.16 ++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 21.17 ++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 21.18 ++ * version 2 for more details (a copy is included in the LICENSE file that 21.19 ++ * accompanied this code). 21.20 ++ * 21.21 ++ * You should have received a copy of the GNU General Public License version 21.22 ++ * 2 along with this work; if not, write to the Free Software Foundation, 21.23 ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21.24 ++ * 21.25 ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21.26 ++ * or visit www.oracle.com if you need additional information or have any 21.27 ++ * questions. 21.28 ++ */ 21.29 ++ 21.30 ++// key: compiler.note.mref.stat.1 21.31 ++// options: -XDdumpLambdaToMethodStats 21.32 ++ 21.33 ++class MrefStat1 { 21.34 ++ 21.35 ++ void m() { } 21.36 ++ 21.37 ++ static class Sub extends MrefStat1 { 21.38 ++ Runnable r = super::m; 21.39 ++ } 21.40 ++}
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 22.2 +++ b/test/tools/javac/lambda/TestLambdaToMethodStats.java Mon Jun 17 11:27:46 2013 +0100 22.3 @@ -0,0 +1,192 @@ 22.4 +/* 22.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 22.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 22.7 + * 22.8 + * This code is free software; you can redistribute it and/or modify it 22.9 + * under the terms of the GNU General Public License version 2 only, as 22.10 + * published by the Free Software Foundation. 22.11 + * 22.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 22.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 22.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 22.15 + * version 2 for more details (a copy is included in the LICENSE file that 22.16 + * accompanied this code). 22.17 + * 22.18 + * You should have received a copy of the GNU General Public License version 22.19 + * 2 along with this work; if not, write to the Free Software Foundation, 22.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22.21 + * 22.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22.23 + * or visit www.oracle.com if you need additional information or have any 22.24 + * questions. 22.25 + */ 22.26 + 22.27 +/* 22.28 + * @test 22.29 + * @bug 8013576 22.30 + * @summary Add stat support to LambdaToMethod 22.31 + * @library ../lib 22.32 + * @build JavacTestingAbstractThreadedTest 22.33 + * @run main/othervm TestLambdaToMethodStats 22.34 + */ 22.35 + 22.36 +// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047) 22.37 +// see JDK-8006746 22.38 + 22.39 +import java.net.URI; 22.40 +import java.util.Arrays; 22.41 + 22.42 +import javax.tools.Diagnostic; 22.43 +import javax.tools.JavaFileObject; 22.44 +import javax.tools.SimpleJavaFileObject; 22.45 + 22.46 +import com.sun.source.util.JavacTask; 22.47 +import com.sun.tools.javac.api.ClientCodeWrapper; 22.48 +import com.sun.tools.javac.util.JCDiagnostic; 22.49 + 22.50 +public class TestLambdaToMethodStats 22.51 + extends JavacTestingAbstractThreadedTest 22.52 + implements Runnable { 22.53 + 22.54 + enum ExprKind { 22.55 + LAMBDA("()->null"), 22.56 + MREF1("this::g"), 22.57 + MREF2("this::h"); 22.58 + 22.59 + String exprStr; 22.60 + 22.61 + ExprKind(String exprStr) { 22.62 + this.exprStr = exprStr; 22.63 + } 22.64 + } 22.65 + 22.66 + enum TargetKind { 22.67 + IMPLICIT(""), 22.68 + SERIALIZABLE("(A & java.io.Serializable)"); 22.69 + 22.70 + String targetStr; 22.71 + 22.72 + TargetKind(String targetStr) { 22.73 + this.targetStr = targetStr; 22.74 + } 22.75 + } 22.76 + 22.77 + public static void main(String... args) throws Exception { 22.78 + for (ExprKind ek : ExprKind.values()) { 22.79 + for (TargetKind tk : TargetKind.values()) { 22.80 + pool.execute(new TestLambdaToMethodStats(ek, tk)); 22.81 + } 22.82 + } 22.83 + 22.84 + checkAfterExec(true); 22.85 + } 22.86 + 22.87 + ExprKind ek; 22.88 + TargetKind tk; 22.89 + JavaSource source; 22.90 + DiagnosticChecker diagChecker; 22.91 + 22.92 + 22.93 + TestLambdaToMethodStats(ExprKind ek, TargetKind tk) { 22.94 + this.ek = ek; 22.95 + this.tk = tk; 22.96 + this.source = new JavaSource(); 22.97 + this.diagChecker = new DiagnosticChecker(); 22.98 + } 22.99 + 22.100 + class JavaSource extends SimpleJavaFileObject { 22.101 + 22.102 + String template = "interface A {\n" + 22.103 + " Object o();\n" + 22.104 + "}\n" + 22.105 + "class Test {\n" + 22.106 + " A a = #C#E;\n" + 22.107 + " Object g() { return null; }\n" + 22.108 + " Object h(Object... o) { return null; }\n" + 22.109 + "}"; 22.110 + 22.111 + String source; 22.112 + 22.113 + public JavaSource() { 22.114 + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); 22.115 + source = template.replaceAll("#E", ek.exprStr) 22.116 + .replaceAll("#C", tk.targetStr); 22.117 + } 22.118 + 22.119 + @Override 22.120 + public CharSequence getCharContent(boolean ignoreEncodingErrors) { 22.121 + return source; 22.122 + } 22.123 + } 22.124 + 22.125 + public void run() { 22.126 + JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker, 22.127 + Arrays.asList("-XDdumpLambdaToMethodStats"), 22.128 + null, Arrays.asList(source)); 22.129 + try { 22.130 + ct.generate(); 22.131 + } catch (Throwable ex) { 22.132 + throw new 22.133 + AssertionError("Error thron when analyzing the following source:\n" + 22.134 + source.getCharContent(true)); 22.135 + } 22.136 + check(); 22.137 + } 22.138 + 22.139 + void check() { 22.140 + checkCount.incrementAndGet(); 22.141 + 22.142 + boolean error = diagChecker.lambda != 22.143 + (ek == ExprKind.LAMBDA); 22.144 + 22.145 + error |= diagChecker.bridge != 22.146 + (ek == ExprKind.MREF2); 22.147 + 22.148 + error |= diagChecker.altMetafactory != 22.149 + (tk == TargetKind.SERIALIZABLE); 22.150 + 22.151 + if (error) { 22.152 + throw new AssertionError("Bad stat diagnostic found for source\n" + 22.153 + "lambda = " + diagChecker.lambda + "\n" + 22.154 + "bridge = " + diagChecker.bridge + "\n" + 22.155 + "altMF = " + diagChecker.altMetafactory + "\n" + 22.156 + source.source); 22.157 + } 22.158 + } 22.159 + 22.160 + static class DiagnosticChecker 22.161 + implements javax.tools.DiagnosticListener<JavaFileObject> { 22.162 + 22.163 + boolean altMetafactory; 22.164 + boolean bridge; 22.165 + boolean lambda; 22.166 + 22.167 + public void report(Diagnostic<? extends JavaFileObject> diagnostic) { 22.168 + try { 22.169 + if (diagnostic.getKind() == Diagnostic.Kind.NOTE) { 22.170 + switch (diagnostic.getCode()) { 22.171 + case "compiler.note.lambda.stat": 22.172 + lambda = true; 22.173 + break; 22.174 + case "compiler.note.mref.stat": 22.175 + lambda = false; 22.176 + bridge = false; 22.177 + break; 22.178 + case "compiler.note.mref.stat.1": 22.179 + lambda = false; 22.180 + bridge = true; 22.181 + break; 22.182 + default: 22.183 + throw new AssertionError("unexpected note: " + diagnostic.getCode()); 22.184 + } 22.185 + ClientCodeWrapper.DiagnosticSourceUnwrapper dsu = 22.186 + (ClientCodeWrapper.DiagnosticSourceUnwrapper)diagnostic; 22.187 + altMetafactory = (Boolean)dsu.d.getArgs()[0]; 22.188 + } 22.189 + } catch (RuntimeException t) { 22.190 + t.printStackTrace(); 22.191 + throw t; 22.192 + } 22.193 + } 22.194 + } 22.195 +}
23.1 --- a/test/tools/javap/8006334/JavapTaskCtorFailWithNPE.java Tue Jun 11 09:25:57 2013 +0100 23.2 +++ b/test/tools/javap/8006334/JavapTaskCtorFailWithNPE.java Mon Jun 17 11:27:46 2013 +0100 23.3 @@ -66,8 +66,7 @@ 23.4 JavaFileManager fm = JavapFileManager.create(dc, pw); 23.5 JavapTask t = new JavapTask(pw, fm, dc, null, 23.6 Arrays.asList(classToCheck.getPath())); 23.7 - boolean ok = t.run(); 23.8 - if (!ok) 23.9 + if (t.run() != 0) 23.10 throw new Error("javap failed unexpectedly"); 23.11 23.12 List<Diagnostic<? extends JavaFileObject>> diags = dc.getDiagnostics();
24.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 24.2 +++ b/test/tools/javap/8007907/JavapReturns0AfterClassNotFoundTest.java Mon Jun 17 11:27:46 2013 +0100 24.3 @@ -0,0 +1,75 @@ 24.4 +/* 24.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 24.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 24.7 + * 24.8 + * This code is free software; you can redistribute it and/or modify it 24.9 + * under the terms of the GNU General Public License version 2 only, as 24.10 + * published by the Free Software Foundation. 24.11 + * 24.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 24.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 24.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 24.15 + * version 2 for more details (a copy is included in the LICENSE file that 24.16 + * accompanied this code). 24.17 + * 24.18 + * You should have received a copy of the GNU General Public License version 24.19 + * 2 along with this work; if not, write to the Free Software Foundation, 24.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 24.21 + * 24.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 24.23 + * or visit www.oracle.com if you need additional information or have any 24.24 + * questions. 24.25 + */ 24.26 + 24.27 +/* 24.28 + * @test 24.29 + * @bug 8007907 24.30 + * @summary javap, method com.sun.tools.javap.Main.run returns 0 even in case 24.31 + * of class not found error 24.32 + */ 24.33 + 24.34 +import java.io.IOException; 24.35 +import java.io.PrintWriter; 24.36 +import java.io.StringWriter; 24.37 + 24.38 +public class JavapReturns0AfterClassNotFoundTest { 24.39 + 24.40 + static final String fileNotFoundErrorMsg = 24.41 + "Error: class not found: Unexisting.class"; 24.42 + static final String exitCodeClassNotFoundAssertionMsg = 24.43 + "Javap's exit code for class not found should be 1"; 24.44 + static final String classNotFoundMsgAssertionMsg = 24.45 + "Javap's error message for class not found is incorrect"; 24.46 + 24.47 + public static void main(String args[]) throws Exception { 24.48 + new JavapReturns0AfterClassNotFoundTest().run(); 24.49 + } 24.50 + 24.51 + void run() throws IOException { 24.52 + check(exitCodeClassNotFoundAssertionMsg, classNotFoundMsgAssertionMsg, 24.53 + fileNotFoundErrorMsg, "-v", "Unexisting.class"); 24.54 + } 24.55 + 24.56 + void check(String exitCodeAssertionMsg, String errMsgAssertionMsg, 24.57 + String expectedErrMsg, String... params) { 24.58 + int result; 24.59 + StringWriter s; 24.60 + String out; 24.61 + try (PrintWriter pw = new PrintWriter(s = new StringWriter())) { 24.62 + result = com.sun.tools.javap.Main.run(params, pw); 24.63 + //no line separator, no problem 24.64 + out = s.toString().trim(); 24.65 + } 24.66 + if (result != 1) { 24.67 + System.out.println("actual exit code " + result); 24.68 + throw new AssertionError(exitCodeAssertionMsg); 24.69 + } 24.70 + 24.71 + if (!out.equals(expectedErrMsg)) { 24.72 + System.out.println("actual " + out); 24.73 + System.out.println("expected " + expectedErrMsg); 24.74 + throw new AssertionError(errMsgAssertionMsg); 24.75 + } 24.76 + } 24.77 + 24.78 +}
25.1 --- a/test/tools/javap/T4777949.java Tue Jun 11 09:25:57 2013 +0100 25.2 +++ b/test/tools/javap/T4777949.java Mon Jun 17 11:27:46 2013 +0100 25.3 @@ -1,5 +1,5 @@ 25.4 /* 25.5 - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. 25.6 + * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. 25.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 25.8 * 25.9 * This code is free software; you can redistribute it and/or modify it 25.10 @@ -87,11 +87,11 @@ 25.11 PrintWriter pw = new PrintWriter(sw); 25.12 JavaFileManager fm = JavapFileManager.create(dc, pw); 25.13 JavapTask t = new JavapTask(pw, fm, dc, args, classes); 25.14 - boolean ok = t.run(); 25.15 + int ok = t.run(); 25.16 25.17 List<Diagnostic<? extends JavaFileObject>> diags = dc.getDiagnostics(); 25.18 25.19 - if (!ok) 25.20 + if (ok != 0) 25.21 error("javap failed unexpectedly"); 25.22 25.23 System.err.println("args=" + args + " classes=" + classes + "\n"
26.1 --- a/test/tools/javap/T7190862.java Tue Jun 11 09:25:57 2013 +0100 26.2 +++ b/test/tools/javap/T7190862.java Mon Jun 17 11:27:46 2013 +0100 26.3 @@ -96,8 +96,7 @@ 26.4 PrintWriter pw = new PrintWriter(sw); 26.5 JavaFileManager fm = JavapFileManager.create(dc, pw); 26.6 JavapTask t = new JavapTask(pw, fm, dc, args, classes); 26.7 - boolean ok = t.run(); 26.8 - if (!ok) 26.9 + if (t.run() != 0) 26.10 throw new Error("javap failed unexpectedly"); 26.11 26.12 List<Diagnostic<? extends JavaFileObject>> diags = dc.getDiagnostics();