# HG changeset patch # User asaha # Date 1397071644 25200 # Node ID a0d9c18a1041c4217db9cda1817f0e348f1be885 # Parent 6ebf1ccca9fa0fbc59a93488a8d7fe988e91e001# Parent 07b40f788204ed68c7cf1d5ba27ce8934ef7af44 Merge diff -r 6ebf1ccca9fa -r a0d9c18a1041 .hgtags --- a/.hgtags Wed Apr 02 10:03:21 2014 -0700 +++ b/.hgtags Wed Apr 09 12:27:24 2014 -0700 @@ -279,3 +279,4 @@ c6d0108aca9f8f45b9cddeb6e483d464509e0127 jdk8u20-b06 1a57c569cb811a897691e42049eca33da8f8d761 jdk8u20-b07 0f821eb7e92b242c878dca68ef63f9626643ee8f jdk8u20-b08 +aa0cb3af23d376e012a142b0531c4f42032fdacf jdk8u20-b09 diff -r 6ebf1ccca9fa -r a0d9c18a1041 src/share/classes/com/sun/tools/javac/code/Symbol.java --- a/src/share/classes/com/sun/tools/javac/code/Symbol.java Wed Apr 02 10:03:21 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java Wed Apr 09 12:27:24 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, 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 @@ -467,11 +467,24 @@ private boolean hiddenIn(ClassSymbol clazz, Types types) { Symbol sym = hiddenInInternal(clazz, types); - return sym != null && sym != this; + Assert.check(sym != null, "the result of hiddenInInternal() can't be null"); + /* If we find the current symbol then there is no symbol hiding it + */ + return sym != this; } - private Symbol hiddenInInternal(ClassSymbol c, Types types) { - Scope.Entry e = c.members().lookup(name); + /** This method looks in the supertypes graph that has the current class as the + * initial node, till it finds the current symbol or another symbol that hides it. + * If the current class has more than one supertype (extends one class and + * implements one or more interfaces) then null can be returned, meaning that + * a wrong path in the supertypes graph was selected. Null can only be returned + * as a temporary value, as a result of the recursive call. + */ + private Symbol hiddenInInternal(ClassSymbol currentClass, Types types) { + if (currentClass == owner) { + return this; + } + Scope.Entry e = currentClass.members().lookup(name); while (e.scope != null) { if (e.sym.kind == kind && (kind != MTH || @@ -481,18 +494,19 @@ } e = e.next(); } - List hiddenSyms = List.nil(); - for (Type st : types.interfaces(c.type).prepend(types.supertype(c.type))) { + Symbol hiddenSym = null; + for (Type st : types.interfaces(currentClass.type) + .prepend(types.supertype(currentClass.type))) { if (st != null && (st.hasTag(CLASS))) { Symbol sym = hiddenInInternal((ClassSymbol)st.tsym, types); - if (sym != null) { - hiddenSyms = hiddenSyms.prepend(hiddenInInternal((ClassSymbol)st.tsym, types)); + if (sym == this) { + return this; + } else if (sym != null) { + hiddenSym = sym; } } } - return hiddenSyms.contains(this) ? - this : - (hiddenSyms.isEmpty() ? null : hiddenSyms.head); + return hiddenSym; } /** Is this symbol inherited into a given class? diff -r 6ebf1ccca9fa -r a0d9c18a1041 src/share/classes/com/sun/tools/javac/code/Type.java --- a/src/share/classes/com/sun/tools/javac/code/Type.java Wed Apr 02 10:03:21 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java Wed Apr 09 12:27:24 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, 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 @@ -1481,8 +1481,21 @@ } public String toString() { - if (inst != null) return inst.toString(); - else return qtype + "?"; + return (inst == null) ? qtype + "?" : inst.toString(); + } + + public String debugString() { + String result = "inference var = " + qtype + "\n"; + if (inst != null) { + result += "inst = " + inst + '\n'; + } + for (InferenceBound bound: InferenceBound.values()) { + List aboundList = bounds.get(bound); + if (aboundList.size() > 0) { + result += bound + " = " + aboundList + '\n'; + } + } + return result; } @Override @@ -1492,8 +1505,7 @@ @Override public Type baseType() { - if (inst != null) return inst.baseType(); - else return this; + return (inst == null) ? this : inst.baseType(); } /** get all bounds of a given kind */ diff -r 6ebf1ccca9fa -r a0d9c18a1041 src/share/classes/com/sun/tools/javac/comp/Infer.java --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java Wed Apr 02 10:03:21 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Wed Apr 09 12:27:24 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, 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 @@ -2119,6 +2119,12 @@ //back-door to infer return Infer.this; } + + @Override + public String toString() { + return "Inference vars: " + inferencevars + '\n' + + "Undet vars: " + undetvars; + } } final InferenceContext emptyContext = new InferenceContext(List.nil()); diff -r 6ebf1ccca9fa -r a0d9c18a1041 src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java --- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Wed Apr 02 10:03:21 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Wed Apr 09 12:27:24 2014 -0700 @@ -1038,7 +1038,7 @@ } databuf.appendChar(pool.get(inner)); databuf.appendChar( - inner.owner.kind == TYP ? pool.get(inner.owner) : 0); + inner.owner.kind == TYP && !inner.name.isEmpty() ? pool.get(inner.owner) : 0); databuf.appendChar( !inner.name.isEmpty() ? pool.get(inner.name) : 0); databuf.appendChar(flags); diff -r 6ebf1ccca9fa -r a0d9c18a1041 src/share/classes/com/sun/tools/javac/jvm/Code.java --- a/src/share/classes/com/sun/tools/javac/jvm/Code.java Wed Apr 02 10:03:21 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java Wed Apr 09 12:27:24 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, 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 @@ -2189,9 +2189,9 @@ // Keep local variables if // 1) we need them for debug information // 2) it is an exception type and it contains type annotations - if (!varDebugInfo && - (!var.sym.isExceptionParameter() || - var.sym.hasTypeAnnotations())) return; + boolean keepLocalVariables = varDebugInfo || + (var.sym.isExceptionParameter() && var.sym.hasTypeAnnotations()); + if (!keepLocalVariables) return; if ((var.sym.flags() & Flags.SYNTHETIC) != 0) return; if (varBuffer == null) varBuffer = new LocalVar[20]; diff -r 6ebf1ccca9fa -r a0d9c18a1041 src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java --- a/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Wed Apr 02 10:03:21 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Wed Apr 09 12:27:24 2014 -0700 @@ -762,14 +762,14 @@ public Set visitType(TypeElement e, Set p) { // Type parameters are not considered to be enclosed by a type scan(e.getTypeParameters(), p); - return scan(e.getEnclosedElements(), p); + return super.visitType(e, p); } @Override public Set visitExecutable(ExecutableElement e, Set p) { // Type parameters are not considered to be enclosed by an executable scan(e.getTypeParameters(), p); - return scan(e.getEnclosedElements(), p); + return super.visitExecutable(e, p); } void addAnnotations(Element e, Set p) { diff -r 6ebf1ccca9fa -r a0d9c18a1041 src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java --- a/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java Wed Apr 02 10:03:21 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java Wed Apr 09 12:27:24 2014 -0700 @@ -137,14 +137,14 @@ public Set visitType(TypeElement e, TypeElement p) { // Type parameters are not considered to be enclosed by a type scan(e.getTypeParameters(), p); - return scan(e.getEnclosedElements(), p); + return super.visitType(e, p); } @Override public Set visitExecutable(ExecutableElement e, TypeElement p) { // Type parameters are not considered to be enclosed by an executable scan(e.getTypeParameters(), p); - return scan(e.getEnclosedElements(), p); + return super.visitExecutable(e, p); } @Override diff -r 6ebf1ccca9fa -r a0d9c18a1041 src/share/classes/com/sun/tools/javap/ClassWriter.java --- a/src/share/classes/com/sun/tools/javap/ClassWriter.java Wed Apr 02 10:03:21 2014 -0700 +++ b/src/share/classes/com/sun/tools/javap/ClassWriter.java Wed Apr 09 12:27:24 2014 -0700 @@ -202,7 +202,6 @@ if (options.verbose) { println(); indent(+1); - attrWriter.write(cf, cf.attributes, constant_pool); println("minor version: " + cf.minor_version); println("major version: " + cf.major_version); writeList("flags: ", flags.getClassFlags(), "\n"); @@ -218,6 +217,10 @@ writeMethods(); indent(-1); println("}"); + + if (options.verbose) { + attrWriter.write(cf, cf.attributes, constant_pool); + } } // where class JavaTypePrinter implements Type.Visitor { diff -r 6ebf1ccca9fa -r a0d9c18a1041 test/tools/javac/IncorrectInheritance/IncorrectInheritanceTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/IncorrectInheritance/IncorrectInheritanceTest.java Wed Apr 09 12:27:24 2014 -0700 @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2014, 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 8034924 + * @summary Incorrect inheritance of inaccessible static method + * @library /tools/javac/lib + * @build ToolBox + * @run main IncorrectInheritanceTest + */ + +public class IncorrectInheritanceTest { + private static final String ASrc = + "package pkg;\n" + + "\n" + + "public class A {\n" + + " static void foo(Object o) {}\n" + + " private static void bar(Object o) {}\n" + + "}"; + + private static final String BSrc = + "import pkg.A;\n" + + "class B extends A {\n" + + " public void foo(Object o) {}\n" + + " public void bar(Object o) {}\n" + + "}"; + + private static final String CSrc = + "class C extends B {\n" + + " public void m(Object o) {\n" + + " foo(o);\n" + + " bar(o);\n" + + " }\n" + + "}"; + + public static void main(String[] args) throws Exception { + new IncorrectInheritanceTest().test(); + } + + public void test() throws Exception { + ToolBox.JavaToolArgs javacParams = + new ToolBox.JavaToolArgs() + .setSources(ASrc, BSrc, CSrc); + ToolBox.javac(javacParams); + } + +} diff -r 6ebf1ccca9fa -r a0d9c18a1041 test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java --- a/test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java Wed Apr 02 10:03:21 2014 -0700 +++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java Wed Apr 09 12:27:24 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, 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 @@ -30,6 +30,7 @@ import java.lang.annotation.*; import java.lang.reflect.*; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -51,6 +52,11 @@ new Driver().runDriver(clazz.newInstance()); } + String[][] extraParamsCombinations = new String[][] { + new String[] { }, + new String[] { "-g" }, + }; + protected void runDriver(Object object) throws Exception { int passed = 0, failed = 0; Class clazz = object.getClass(); @@ -65,18 +71,20 @@ throw new IllegalArgumentException("Test method needs to return a string: " + method); String testClass = testClassOf(method); - try { - String compact = (String)method.invoke(object); - String fullFile = wrap(compact); - ClassFile cf = compileAndReturn(fullFile, testClass); - List actual = ReferenceInfoUtil.extendedAnnotationsOf(cf); - ReferenceInfoUtil.compare(expected, actual, cf); - out.println("PASSED: " + method.getName()); - ++passed; - } catch (Throwable e) { - out.println("FAILED: " + method.getName()); - out.println(" " + e.toString()); - ++failed; + for (String[] extraParams : extraParamsCombinations) { + try { + String compact = (String)method.invoke(object); + String fullFile = wrap(compact); + ClassFile cf = compileAndReturn(fullFile, testClass, extraParams); + List actual = ReferenceInfoUtil.extendedAnnotationsOf(cf); + ReferenceInfoUtil.compare(expected, actual, cf); + out.println("PASSED: " + method.getName()); + ++passed; + } catch (Throwable e) { + out.println("FAILED: " + method.getName()); + out.println(" " + e.toString()); + ++failed; + } } } @@ -156,7 +164,7 @@ } } - private ClassFile compileAndReturn(String fullFile, String testClass) throws Exception { + private ClassFile compileAndReturn(String fullFile, String testClass, String... extraParams) throws Exception { File source = writeTestFile(fullFile); File clazzFile = compileTestFile(source, testClass); return ClassFile.read(clazzFile); @@ -170,8 +178,12 @@ return f; } - protected File compileTestFile(File f, String testClass) { - int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.8", "-g", f.getPath() }); + protected File compileTestFile(File f, String testClass, String... extraParams) { + List options = new ArrayList<>(); + options.addAll(Arrays.asList("-source", "1.8")); + options.addAll(Arrays.asList(extraParams)); + options.add(f.getPath()); + int rc = com.sun.tools.javac.Main.compile(options.toArray(new String[options.size()])); if (rc != 0) throw new Error("compilation failed. rc=" + rc); String path; diff -r 6ebf1ccca9fa -r a0d9c18a1041 test/tools/javac/annotations/typeAnnotations/referenceinfos/ExceptionParameters.java --- a/test/tools/javac/annotations/typeAnnotations/referenceinfos/ExceptionParameters.java Wed Apr 02 10:03:21 2014 -0700 +++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/ExceptionParameters.java Wed Apr 09 12:27:24 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, 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 @@ -25,6 +25,7 @@ /* * @test + * @bug 8028576 * @summary Test population of reference info for exception parameters * @author Werner Dietl * @compile -g Driver.java ReferenceInfoUtil.java ExceptionParameters.java diff -r 6ebf1ccca9fa -r a0d9c18a1041 test/tools/javac/classfiles/InnerClasses/SyntheticClasses.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/classfiles/InnerClasses/SyntheticClasses.java Wed Apr 09 12:27:24 2014 -0700 @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2014, 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 8034854 + * @summary Verify that the InnerClasses attribute has outer_class_info_index zero if it has + * inner_name_index zero (for synthetic classes) + * @compile SyntheticClasses.java + * @run main SyntheticClasses + */ + +import java.io.*; +import java.util.*; +import com.sun.tools.classfile.*; + +public class SyntheticClasses { + + public static void main(String[] args) throws IOException, ConstantPoolException { + new SyntheticClasses().run(); + } + + private void run() throws IOException, ConstantPoolException { + File testClasses = new File(System.getProperty("test.classes")); + for (File classFile : testClasses.listFiles()) { + ClassFile cf = ClassFile.read(classFile); + if (cf.getName().matches(".*\\$[0-9]+")) { + EnclosingMethod_attribute encl = + (EnclosingMethod_attribute) cf.getAttribute(Attribute.EnclosingMethod); + if (encl != null) { + if (encl.method_index != 0) + throw new IllegalStateException("Invalid EnclosingMethod.method_index: " + + encl.method_index + "."); + } + } + InnerClasses_attribute attr = + (InnerClasses_attribute) cf.getAttribute(Attribute.InnerClasses); + if (attr != null) { + for (InnerClasses_attribute.Info info : attr.classes) { + if (cf.major_version < 51) + throw new IllegalStateException(); + if (info.inner_name_index == 0 && info.outer_class_info_index != 0) + throw new IllegalStateException("Invalid outer_class_info_index=" + + info.outer_class_info_index + + "; inner_name_index=" + + info.inner_name_index + "."); + } + } + } + } +} + +class SyntheticConstructorAccessTag { + + private static class A { + private A(){} + } + + public void test() { + new A(); + } +} + +class SyntheticEnumMapping { + private int convert(E e) { + switch (e) { + case A: return 0; + default: return -1; + } + } + enum E { A } +} + +interface SyntheticAssertionsDisabled { + public default void test() { + assert false; + } +} diff -r 6ebf1ccca9fa -r a0d9c18a1041 test/tools/javac/processing/environment/ProcessingEnvAnnoDiscovery.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/processing/environment/ProcessingEnvAnnoDiscovery.java Wed Apr 09 12:27:24 2014 -0700 @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2014, 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 8038080 + * @summary make sure that all declaration annotations are discovered + * by the processing environment + * @library /tools/javac/lib + * @build JavacTestingAbstractProcessor ProcessingEnvAnnoDiscovery + * @compile/process -processor ProcessingEnvAnnoDiscovery ProcessingEnvAnnoDiscovery.java + */ + +import java.lang.annotation.*; +import java.util.Set; +import javax.annotation.processing.*; +import javax.lang.model.element.*; + +import com.sun.tools.javac.util.*; + +@ProcessingEnvAnnoDiscovery.Anno1 +public class ProcessingEnvAnnoDiscovery<@ProcessingEnvAnnoDiscovery.Anno4 T> + extends JavacTestingAbstractProcessor { + private int round = 0; + + public boolean process(Set annos, RoundEnvironment rEnv) { + if (round++ == 0) { + System.out.println(annos); + Assert.check(annos.contains(eltUtils.getTypeElement("java.lang.annotation.Target"))); + Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno1"))); + Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno2"))); + Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno3"))); + Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno4"))); + Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno5"))); + Assert.check(annos.size() == 6, "Found extra annotations"); //Anno1-5 + @Target + } + + return true; + } + + @Anno2 + public <@Anno5 K> K m(@Anno3 long foo) { + return null; + } + + @interface Anno1 {} + + @interface Anno2 {} + + @interface Anno3 {} + + @Target(ElementType.TYPE_PARAMETER) + @interface Anno4 {} + + @Target(ElementType.TYPE_PARAMETER) + @interface Anno5 {} + +} diff -r 6ebf1ccca9fa -r a0d9c18a1041 test/tools/javac/processing/environment/round/Anno.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/processing/environment/round/Anno.java Wed Apr 09 12:27:24 2014 -0700 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2014, 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. + */ + +import java.lang.annotation.*; +import static java.lang.annotation.RetentionPolicy.*; + +@Retention(RUNTIME) +public @interface Anno {} diff -r 6ebf1ccca9fa -r a0d9c18a1041 test/tools/javac/processing/environment/round/ParameterAnnotations.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/processing/environment/round/ParameterAnnotations.java Wed Apr 09 12:27:24 2014 -0700 @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2014, 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. + */ + +/** + * Class to hold annotations for ElementsAnnotatedWithTest. + */ + +@AnnotatedElementInfo(annotationName="Anno", + expectedSize=1, + names={"annotatedParameter"}) +public class ParameterAnnotations { + private void foo(@Anno Object annotatedParameter) {} +} diff -r 6ebf1ccca9fa -r a0d9c18a1041 test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java --- a/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java Wed Apr 02 10:03:21 2014 -0700 +++ b/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java Wed Apr 09 12:27:24 2014 -0700 @@ -23,7 +23,7 @@ /* * @test - * @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854 8030049 + * @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854 8030049 8038080 * @summary Tests that getElementsAnnotatedWith works properly. * @author Joseph D. Darcy * @library /tools/javac/lib @@ -31,12 +31,14 @@ * @compile TestElementsAnnotatedWith.java * @compile InheritedAnnotation.java * @compile TpAnno.java + * @compile Anno.java * @compile -processor TestElementsAnnotatedWith -proc:only SurfaceAnnotations.java * @compile -processor TestElementsAnnotatedWith -proc:only BuriedAnnotations.java * @compile -processor TestElementsAnnotatedWith -proc:only Part1.java Part2.java * @compile -processor TestElementsAnnotatedWith -proc:only C2.java * @compile -processor TestElementsAnnotatedWith -proc:only Foo.java * @compile -processor TestElementsAnnotatedWith -proc:only TypeParameterAnnotations.java + * @compile -processor TestElementsAnnotatedWith -proc:only ParameterAnnotations.java * @compile/fail/ref=ErroneousAnnotations.out -processor TestElementsAnnotatedWith -proc:only -XDrawDiagnostics ErroneousAnnotations.java * @compile Foo.java * @compile/process -processor TestElementsAnnotatedWith -proc:only Foo diff -r 6ebf1ccca9fa -r a0d9c18a1041 test/tools/javap/T4975569.java --- a/test/tools/javap/T4975569.java Wed Apr 02 10:03:21 2014 -0700 +++ b/test/tools/javap/T4975569.java Wed Apr 09 12:27:24 2014 -0700 @@ -40,10 +40,10 @@ verify("T4975569$Anno", "flags: ACC_INTERFACE, ACC_ABSTRACT, ACC_ANNOTATION"); verify("T4975569$E", "flags: ACC_FINAL, ACC_SUPER, ACC_ENUM"); verify("T4975569$S", "flags: ACC_BRIDGE, ACC_SYNTHETIC", - "InnerClasses:\n static"); + "InnerClasses:\n static"); verify("T4975569$V", "void m(java.lang.String...)", "flags: ACC_VARARGS"); - verify("T4975569$Prot", "InnerClasses:\n protected"); + verify("T4975569$Prot", "InnerClasses:\n protected"); //verify("T4975569$Priv", "InnerClasses"); if (errors > 0) throw new Error(errors + " found."); diff -r 6ebf1ccca9fa -r a0d9c18a1041 test/tools/javap/T8035104.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javap/T8035104.java Wed Apr 09 12:27:24 2014 -0700 @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2014, 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 8035104 + * @summary reorder class file attributes in javap listing + */ + +import java.io.*; + +public class T8035104 { + public static void main(String[] args) throws Exception { + new T8035104().run(); + } + + public void run() throws Exception { + String[] lines = javap("-v", T8035104.class.getName()).split("[\r\n]+"); + int minor = -1; + int SourceFile = -1; + for (int i = 0; i < lines.length; i++) { + String line = lines[i]; + if (line.matches(" *minor version: [0-9.]+")) + minor = i; + if (line.matches(" *SourceFile: .+")) + SourceFile = i; + } + if (minor == -1) + throw new Exception("minor version not found"); + if (SourceFile == -1) + throw new Exception("SourceFile not found"); + if (SourceFile < minor) + throw new Exception("unexpected order of output"); + + System.out.println("output OK"); + } + + String javap(String... args) { + StringWriter sw = new StringWriter(); + PrintWriter out = new PrintWriter(sw); + int rc = com.sun.tools.javap.Main.run(args, out); + out.close(); + System.out.println(sw.toString()); + System.out.println("javap exited, rc=" + rc); + return sw.toString(); + } +}