Merge jdk8u20-b10

Wed, 09 Apr 2014 12:27:24 -0700

author
asaha
date
Wed, 09 Apr 2014 12:27:24 -0700
changeset 2350
a0d9c18a1041
parent 2349
6ebf1ccca9fa
parent 2310
07b40f788204
child 2351
bbacee92a170

Merge

.hgtags file | annotate | diff | comparison | revisions
     1.1 --- a/.hgtags	Wed Apr 02 10:03:21 2014 -0700
     1.2 +++ b/.hgtags	Wed Apr 09 12:27:24 2014 -0700
     1.3 @@ -279,3 +279,4 @@
     1.4  c6d0108aca9f8f45b9cddeb6e483d464509e0127 jdk8u20-b06
     1.5  1a57c569cb811a897691e42049eca33da8f8d761 jdk8u20-b07
     1.6  0f821eb7e92b242c878dca68ef63f9626643ee8f jdk8u20-b08
     1.7 +aa0cb3af23d376e012a142b0531c4f42032fdacf jdk8u20-b09
     2.1 --- a/src/share/classes/com/sun/tools/javac/code/Symbol.java	Wed Apr 02 10:03:21 2014 -0700
     2.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java	Wed Apr 09 12:27:24 2014 -0700
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
     2.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
     2.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.8   *
     2.9   * This code is free software; you can redistribute it and/or modify it
    2.10 @@ -467,11 +467,24 @@
    2.11  
    2.12      private boolean hiddenIn(ClassSymbol clazz, Types types) {
    2.13          Symbol sym = hiddenInInternal(clazz, types);
    2.14 -        return sym != null && sym != this;
    2.15 +        Assert.check(sym != null, "the result of hiddenInInternal() can't be null");
    2.16 +        /* If we find the current symbol then there is no symbol hiding it
    2.17 +         */
    2.18 +        return sym != this;
    2.19      }
    2.20  
    2.21 -    private Symbol hiddenInInternal(ClassSymbol c, Types types) {
    2.22 -        Scope.Entry e = c.members().lookup(name);
    2.23 +    /** This method looks in the supertypes graph that has the current class as the
    2.24 +     * initial node, till it finds the current symbol or another symbol that hides it.
    2.25 +     * If the current class has more than one supertype (extends one class and
    2.26 +     * implements one or more interfaces) then null can be returned, meaning that
    2.27 +     * a wrong path in the supertypes graph was selected. Null can only be returned
    2.28 +     * as a temporary value, as a result of the recursive call.
    2.29 +     */
    2.30 +    private Symbol hiddenInInternal(ClassSymbol currentClass, Types types) {
    2.31 +        if (currentClass == owner) {
    2.32 +            return this;
    2.33 +        }
    2.34 +        Scope.Entry e = currentClass.members().lookup(name);
    2.35          while (e.scope != null) {
    2.36              if (e.sym.kind == kind &&
    2.37                      (kind != MTH ||
    2.38 @@ -481,18 +494,19 @@
    2.39              }
    2.40              e = e.next();
    2.41          }
    2.42 -        List<Symbol> hiddenSyms = List.nil();
    2.43 -        for (Type st : types.interfaces(c.type).prepend(types.supertype(c.type))) {
    2.44 +        Symbol hiddenSym = null;
    2.45 +        for (Type st : types.interfaces(currentClass.type)
    2.46 +                .prepend(types.supertype(currentClass.type))) {
    2.47              if (st != null && (st.hasTag(CLASS))) {
    2.48                  Symbol sym = hiddenInInternal((ClassSymbol)st.tsym, types);
    2.49 -                if (sym != null) {
    2.50 -                    hiddenSyms = hiddenSyms.prepend(hiddenInInternal((ClassSymbol)st.tsym, types));
    2.51 +                if (sym == this) {
    2.52 +                    return this;
    2.53 +                } else if (sym != null) {
    2.54 +                    hiddenSym = sym;
    2.55                  }
    2.56              }
    2.57          }
    2.58 -        return hiddenSyms.contains(this) ?
    2.59 -                this :
    2.60 -                (hiddenSyms.isEmpty() ? null : hiddenSyms.head);
    2.61 +        return hiddenSym;
    2.62      }
    2.63  
    2.64      /** Is this symbol inherited into a given class?
     3.1 --- a/src/share/classes/com/sun/tools/javac/code/Type.java	Wed Apr 02 10:03:21 2014 -0700
     3.2 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java	Wed Apr 09 12:27:24 2014 -0700
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
     3.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
     3.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.8   *
     3.9   * This code is free software; you can redistribute it and/or modify it
    3.10 @@ -1481,8 +1481,21 @@
    3.11          }
    3.12  
    3.13          public String toString() {
    3.14 -            if (inst != null) return inst.toString();
    3.15 -            else return qtype + "?";
    3.16 +            return (inst == null) ? qtype + "?" : inst.toString();
    3.17 +        }
    3.18 +
    3.19 +        public String debugString() {
    3.20 +            String result = "inference var = " + qtype + "\n";
    3.21 +            if (inst != null) {
    3.22 +                result += "inst = " + inst + '\n';
    3.23 +            }
    3.24 +            for (InferenceBound bound: InferenceBound.values()) {
    3.25 +                List<Type> aboundList = bounds.get(bound);
    3.26 +                if (aboundList.size() > 0) {
    3.27 +                    result += bound + " = " + aboundList + '\n';
    3.28 +                }
    3.29 +            }
    3.30 +            return result;
    3.31          }
    3.32  
    3.33          @Override
    3.34 @@ -1492,8 +1505,7 @@
    3.35  
    3.36          @Override
    3.37          public Type baseType() {
    3.38 -            if (inst != null) return inst.baseType();
    3.39 -            else return this;
    3.40 +            return (inst == null) ? this : inst.baseType();
    3.41          }
    3.42  
    3.43          /** get all bounds of a given kind */
     4.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Wed Apr 02 10:03:21 2014 -0700
     4.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Wed Apr 09 12:27:24 2014 -0700
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
     4.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.8   *
     4.9   * This code is free software; you can redistribute it and/or modify it
    4.10 @@ -2119,6 +2119,12 @@
    4.11              //back-door to infer
    4.12              return Infer.this;
    4.13          }
    4.14 +
    4.15 +        @Override
    4.16 +        public String toString() {
    4.17 +            return "Inference vars: " + inferencevars + '\n' +
    4.18 +                   "Undet vars: " + undetvars;
    4.19 +        }
    4.20      }
    4.21  
    4.22      final InferenceContext emptyContext = new InferenceContext(List.<Type>nil());
     5.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Wed Apr 02 10:03:21 2014 -0700
     5.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Wed Apr 09 12:27:24 2014 -0700
     5.3 @@ -1038,7 +1038,7 @@
     5.4              }
     5.5              databuf.appendChar(pool.get(inner));
     5.6              databuf.appendChar(
     5.7 -                inner.owner.kind == TYP ? pool.get(inner.owner) : 0);
     5.8 +                inner.owner.kind == TYP && !inner.name.isEmpty() ? pool.get(inner.owner) : 0);
     5.9              databuf.appendChar(
    5.10                  !inner.name.isEmpty() ? pool.get(inner.name) : 0);
    5.11              databuf.appendChar(flags);
     6.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Code.java	Wed Apr 02 10:03:21 2014 -0700
     6.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java	Wed Apr 09 12:27:24 2014 -0700
     6.3 @@ -1,5 +1,5 @@
     6.4  /*
     6.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
     6.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
     6.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.8   *
     6.9   * This code is free software; you can redistribute it and/or modify it
    6.10 @@ -2189,9 +2189,9 @@
    6.11          // Keep local variables if
    6.12          // 1) we need them for debug information
    6.13          // 2) it is an exception type and it contains type annotations
    6.14 -        if (!varDebugInfo &&
    6.15 -                (!var.sym.isExceptionParameter() ||
    6.16 -                var.sym.hasTypeAnnotations())) return;
    6.17 +        boolean keepLocalVariables = varDebugInfo ||
    6.18 +            (var.sym.isExceptionParameter() && var.sym.hasTypeAnnotations());
    6.19 +        if (!keepLocalVariables) return;
    6.20          if ((var.sym.flags() & Flags.SYNTHETIC) != 0) return;
    6.21          if (varBuffer == null)
    6.22              varBuffer = new LocalVar[20];
     7.1 --- a/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Wed Apr 02 10:03:21 2014 -0700
     7.2 +++ b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Wed Apr 09 12:27:24 2014 -0700
     7.3 @@ -762,14 +762,14 @@
     7.4          public Set<TypeElement> visitType(TypeElement e, Set<TypeElement> p) {
     7.5              // Type parameters are not considered to be enclosed by a type
     7.6              scan(e.getTypeParameters(), p);
     7.7 -            return scan(e.getEnclosedElements(), p);
     7.8 +            return super.visitType(e, p);
     7.9          }
    7.10  
    7.11          @Override
    7.12          public Set<TypeElement> visitExecutable(ExecutableElement e, Set<TypeElement> p) {
    7.13              // Type parameters are not considered to be enclosed by an executable
    7.14              scan(e.getTypeParameters(), p);
    7.15 -            return scan(e.getEnclosedElements(), p);
    7.16 +            return super.visitExecutable(e, p);
    7.17          }
    7.18  
    7.19          void addAnnotations(Element e, Set<TypeElement> p) {
     8.1 --- a/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java	Wed Apr 02 10:03:21 2014 -0700
     8.2 +++ b/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java	Wed Apr 09 12:27:24 2014 -0700
     8.3 @@ -137,14 +137,14 @@
     8.4          public Set<Element> visitType(TypeElement e, TypeElement p) {
     8.5              // Type parameters are not considered to be enclosed by a type
     8.6              scan(e.getTypeParameters(), p);
     8.7 -            return scan(e.getEnclosedElements(), p);
     8.8 +            return super.visitType(e, p);
     8.9          }
    8.10  
    8.11          @Override
    8.12          public Set<Element> visitExecutable(ExecutableElement e, TypeElement p) {
    8.13              // Type parameters are not considered to be enclosed by an executable
    8.14              scan(e.getTypeParameters(), p);
    8.15 -            return scan(e.getEnclosedElements(), p);
    8.16 +            return super.visitExecutable(e, p);
    8.17          }
    8.18  
    8.19          @Override
     9.1 --- a/src/share/classes/com/sun/tools/javap/ClassWriter.java	Wed Apr 02 10:03:21 2014 -0700
     9.2 +++ b/src/share/classes/com/sun/tools/javap/ClassWriter.java	Wed Apr 09 12:27:24 2014 -0700
     9.3 @@ -202,7 +202,6 @@
     9.4          if (options.verbose) {
     9.5              println();
     9.6              indent(+1);
     9.7 -            attrWriter.write(cf, cf.attributes, constant_pool);
     9.8              println("minor version: " + cf.minor_version);
     9.9              println("major version: " + cf.major_version);
    9.10              writeList("flags: ", flags.getClassFlags(), "\n");
    9.11 @@ -218,6 +217,10 @@
    9.12          writeMethods();
    9.13          indent(-1);
    9.14          println("}");
    9.15 +
    9.16 +        if (options.verbose) {
    9.17 +            attrWriter.write(cf, cf.attributes, constant_pool);
    9.18 +        }
    9.19      }
    9.20      // where
    9.21          class JavaTypePrinter implements Type.Visitor<StringBuilder,StringBuilder> {
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/test/tools/javac/IncorrectInheritance/IncorrectInheritanceTest.java	Wed Apr 09 12:27:24 2014 -0700
    10.3 @@ -0,0 +1,68 @@
    10.4 +/*
    10.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    10.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    10.7 + *
    10.8 + * This code is free software; you can redistribute it and/or modify it
    10.9 + * under the terms of the GNU General Public License version 2 only, as
   10.10 + * published by the Free Software Foundation.
   10.11 + *
   10.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   10.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   10.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   10.15 + * version 2 for more details (a copy is included in the LICENSE file that
   10.16 + * accompanied this code).
   10.17 + *
   10.18 + * You should have received a copy of the GNU General Public License version
   10.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   10.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   10.21 + *
   10.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   10.23 + * or visit www.oracle.com if you need additional information or have any
   10.24 + * questions.
   10.25 + */
   10.26 +
   10.27 +/*
   10.28 + * @test
   10.29 + * @bug 8034924
   10.30 + * @summary Incorrect inheritance of inaccessible static method
   10.31 + * @library /tools/javac/lib
   10.32 + * @build ToolBox
   10.33 + * @run main IncorrectInheritanceTest
   10.34 + */
   10.35 +
   10.36 +public class IncorrectInheritanceTest {
   10.37 +    private static final String ASrc =
   10.38 +            "package pkg;\n" +
   10.39 +            "\n" +
   10.40 +            "public class A {\n" +
   10.41 +            "    static void foo(Object o) {}\n" +
   10.42 +            "    private static void bar(Object o) {}\n" +
   10.43 +            "}";
   10.44 +
   10.45 +    private static final String BSrc =
   10.46 +            "import pkg.A;\n" +
   10.47 +            "class B extends A {\n" +
   10.48 +            "    public void foo(Object o) {}\n" +
   10.49 +            "    public void bar(Object o) {}\n" +
   10.50 +            "}";
   10.51 +
   10.52 +    private static final String CSrc =
   10.53 +            "class C extends B {\n" +
   10.54 +            "    public void m(Object o) {\n" +
   10.55 +            "        foo(o);\n" +
   10.56 +            "        bar(o);\n" +
   10.57 +            "    }\n" +
   10.58 +            "}";
   10.59 +
   10.60 +    public static void main(String[] args) throws Exception {
   10.61 +        new IncorrectInheritanceTest().test();
   10.62 +    }
   10.63 +
   10.64 +    public void test() throws Exception {
   10.65 +        ToolBox.JavaToolArgs javacParams =
   10.66 +                new ToolBox.JavaToolArgs()
   10.67 +                .setSources(ASrc, BSrc, CSrc);
   10.68 +        ToolBox.javac(javacParams);
   10.69 +    }
   10.70 +
   10.71 +}
    11.1 --- a/test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java	Wed Apr 02 10:03:21 2014 -0700
    11.2 +++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java	Wed Apr 09 12:27:24 2014 -0700
    11.3 @@ -1,5 +1,5 @@
    11.4  /*
    11.5 - * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
    11.6 + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
    11.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    11.8   *
    11.9   * This code is free software; you can redistribute it and/or modify it
   11.10 @@ -30,6 +30,7 @@
   11.11  import java.lang.annotation.*;
   11.12  import java.lang.reflect.*;
   11.13  import java.util.ArrayList;
   11.14 +import java.util.Arrays;
   11.15  import java.util.Collections;
   11.16  import java.util.HashMap;
   11.17  import java.util.List;
   11.18 @@ -51,6 +52,11 @@
   11.19          new Driver().runDriver(clazz.newInstance());
   11.20      }
   11.21  
   11.22 +    String[][] extraParamsCombinations = new String[][] {
   11.23 +        new String[] { },
   11.24 +        new String[] { "-g" },
   11.25 +    };
   11.26 +
   11.27      protected void runDriver(Object object) throws Exception {
   11.28          int passed = 0, failed = 0;
   11.29          Class<?> clazz = object.getClass();
   11.30 @@ -65,18 +71,20 @@
   11.31                  throw new IllegalArgumentException("Test method needs to return a string: " + method);
   11.32              String testClass = testClassOf(method);
   11.33  
   11.34 -            try {
   11.35 -                String compact = (String)method.invoke(object);
   11.36 -                String fullFile = wrap(compact);
   11.37 -                ClassFile cf = compileAndReturn(fullFile, testClass);
   11.38 -                List<TypeAnnotation> actual = ReferenceInfoUtil.extendedAnnotationsOf(cf);
   11.39 -                ReferenceInfoUtil.compare(expected, actual, cf);
   11.40 -                out.println("PASSED:  " + method.getName());
   11.41 -                ++passed;
   11.42 -            } catch (Throwable e) {
   11.43 -                out.println("FAILED:  " + method.getName());
   11.44 -                out.println("    " + e.toString());
   11.45 -                ++failed;
   11.46 +            for (String[] extraParams : extraParamsCombinations) {
   11.47 +                try {
   11.48 +                    String compact = (String)method.invoke(object);
   11.49 +                    String fullFile = wrap(compact);
   11.50 +                    ClassFile cf = compileAndReturn(fullFile, testClass, extraParams);
   11.51 +                    List<TypeAnnotation> actual = ReferenceInfoUtil.extendedAnnotationsOf(cf);
   11.52 +                    ReferenceInfoUtil.compare(expected, actual, cf);
   11.53 +                    out.println("PASSED:  " + method.getName());
   11.54 +                    ++passed;
   11.55 +                } catch (Throwable e) {
   11.56 +                    out.println("FAILED:  " + method.getName());
   11.57 +                    out.println("    " + e.toString());
   11.58 +                    ++failed;
   11.59 +                }
   11.60              }
   11.61          }
   11.62  
   11.63 @@ -156,7 +164,7 @@
   11.64          }
   11.65      }
   11.66  
   11.67 -    private ClassFile compileAndReturn(String fullFile, String testClass) throws Exception {
   11.68 +    private ClassFile compileAndReturn(String fullFile, String testClass, String... extraParams) throws Exception {
   11.69          File source = writeTestFile(fullFile);
   11.70          File clazzFile = compileTestFile(source, testClass);
   11.71          return ClassFile.read(clazzFile);
   11.72 @@ -170,8 +178,12 @@
   11.73          return f;
   11.74      }
   11.75  
   11.76 -    protected File compileTestFile(File f, String testClass) {
   11.77 -        int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.8", "-g", f.getPath() });
   11.78 +    protected File compileTestFile(File f, String testClass, String... extraParams) {
   11.79 +        List<String> options = new ArrayList<>();
   11.80 +        options.addAll(Arrays.asList("-source", "1.8"));
   11.81 +        options.addAll(Arrays.asList(extraParams));
   11.82 +        options.add(f.getPath());
   11.83 +        int rc = com.sun.tools.javac.Main.compile(options.toArray(new String[options.size()]));
   11.84          if (rc != 0)
   11.85              throw new Error("compilation failed. rc=" + rc);
   11.86          String path;
    12.1 --- a/test/tools/javac/annotations/typeAnnotations/referenceinfos/ExceptionParameters.java	Wed Apr 02 10:03:21 2014 -0700
    12.2 +++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/ExceptionParameters.java	Wed Apr 09 12:27:24 2014 -0700
    12.3 @@ -1,5 +1,5 @@
    12.4  /*
    12.5 - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    12.6 + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
    12.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    12.8   *
    12.9   * This code is free software; you can redistribute it and/or modify it
   12.10 @@ -25,6 +25,7 @@
   12.11  
   12.12  /*
   12.13   * @test
   12.14 + * @bug 8028576
   12.15   * @summary Test population of reference info for exception parameters
   12.16   * @author Werner Dietl
   12.17   * @compile -g Driver.java ReferenceInfoUtil.java ExceptionParameters.java
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/test/tools/javac/classfiles/InnerClasses/SyntheticClasses.java	Wed Apr 09 12:27:24 2014 -0700
    13.3 @@ -0,0 +1,97 @@
    13.4 +/*
    13.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    13.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    13.7 + *
    13.8 + * This code is free software; you can redistribute it and/or modify it
    13.9 + * under the terms of the GNU General Public License version 2 only, as
   13.10 + * published by the Free Software Foundation.
   13.11 + *
   13.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   13.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   13.15 + * version 2 for more details (a copy is included in the LICENSE file that
   13.16 + * accompanied this code).
   13.17 + *
   13.18 + * You should have received a copy of the GNU General Public License version
   13.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   13.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   13.21 + *
   13.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   13.23 + * or visit www.oracle.com if you need additional information or have any
   13.24 + * questions.
   13.25 + */
   13.26 +
   13.27 +/** @test
   13.28 + *  @bug 8034854
   13.29 + *  @summary Verify that the InnerClasses attribute has outer_class_info_index zero if it has
   13.30 + *           inner_name_index zero (for synthetic classes)
   13.31 + *  @compile SyntheticClasses.java
   13.32 + *  @run main SyntheticClasses
   13.33 + */
   13.34 +
   13.35 +import java.io.*;
   13.36 +import java.util.*;
   13.37 +import com.sun.tools.classfile.*;
   13.38 +
   13.39 +public class SyntheticClasses {
   13.40 +
   13.41 +    public static void main(String[] args) throws IOException, ConstantPoolException {
   13.42 +        new SyntheticClasses().run();
   13.43 +    }
   13.44 +
   13.45 +    private void run() throws IOException, ConstantPoolException {
   13.46 +        File testClasses = new File(System.getProperty("test.classes"));
   13.47 +        for (File classFile : testClasses.listFiles()) {
   13.48 +            ClassFile cf = ClassFile.read(classFile);
   13.49 +            if (cf.getName().matches(".*\\$[0-9]+")) {
   13.50 +                EnclosingMethod_attribute encl =
   13.51 +                        (EnclosingMethod_attribute) cf.getAttribute(Attribute.EnclosingMethod);
   13.52 +                if (encl != null) {
   13.53 +                    if (encl.method_index != 0)
   13.54 +                        throw new IllegalStateException("Invalid EnclosingMethod.method_index: " +
   13.55 +                                                        encl.method_index + ".");
   13.56 +                }
   13.57 +            }
   13.58 +            InnerClasses_attribute attr =
   13.59 +                    (InnerClasses_attribute) cf.getAttribute(Attribute.InnerClasses);
   13.60 +            if (attr != null) {
   13.61 +                for (InnerClasses_attribute.Info info : attr.classes) {
   13.62 +                    if (cf.major_version < 51)
   13.63 +                        throw new IllegalStateException();
   13.64 +                    if (info.inner_name_index == 0 && info.outer_class_info_index != 0)
   13.65 +                        throw new IllegalStateException("Invalid outer_class_info_index=" +
   13.66 +                                                        info.outer_class_info_index +
   13.67 +                                                        "; inner_name_index=" +
   13.68 +                                                        info.inner_name_index + ".");
   13.69 +                }
   13.70 +            }
   13.71 +        }
   13.72 +    }
   13.73 +}
   13.74 +
   13.75 +class SyntheticConstructorAccessTag {
   13.76 +
   13.77 +    private static class A {
   13.78 +        private A(){}
   13.79 +    }
   13.80 +
   13.81 +    public void test() {
   13.82 +        new A();
   13.83 +    }
   13.84 +}
   13.85 +
   13.86 +class SyntheticEnumMapping {
   13.87 +    private int convert(E e) {
   13.88 +        switch (e) {
   13.89 +            case A: return 0;
   13.90 +            default: return -1;
   13.91 +        }
   13.92 +    }
   13.93 +    enum E { A }
   13.94 +}
   13.95 +
   13.96 +interface SyntheticAssertionsDisabled {
   13.97 +    public default void test() {
   13.98 +        assert false;
   13.99 +    }
  13.100 +}
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/test/tools/javac/processing/environment/ProcessingEnvAnnoDiscovery.java	Wed Apr 09 12:27:24 2014 -0700
    14.3 @@ -0,0 +1,78 @@
    14.4 +/*
    14.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    14.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    14.7 + *
    14.8 + * This code is free software; you can redistribute it and/or modify it
    14.9 + * under the terms of the GNU General Public License version 2 only, as
   14.10 + * published by the Free Software Foundation.
   14.11 + *
   14.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   14.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   14.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14.15 + * version 2 for more details (a copy is included in the LICENSE file that
   14.16 + * accompanied this code).
   14.17 + *
   14.18 + * You should have received a copy of the GNU General Public License version
   14.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   14.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   14.21 + *
   14.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   14.23 + * or visit www.oracle.com if you need additional information or have any
   14.24 + * questions.
   14.25 + */
   14.26 +
   14.27 +/*
   14.28 + * @test
   14.29 + * @bug 8038080
   14.30 + * @summary make sure that all declaration annotations are discovered
   14.31 + *          by the processing environment
   14.32 + * @library /tools/javac/lib
   14.33 + * @build JavacTestingAbstractProcessor ProcessingEnvAnnoDiscovery
   14.34 + * @compile/process -processor ProcessingEnvAnnoDiscovery ProcessingEnvAnnoDiscovery.java
   14.35 + */
   14.36 +
   14.37 +import java.lang.annotation.*;
   14.38 +import java.util.Set;
   14.39 +import javax.annotation.processing.*;
   14.40 +import javax.lang.model.element.*;
   14.41 +
   14.42 +import com.sun.tools.javac.util.*;
   14.43 +
   14.44 +@ProcessingEnvAnnoDiscovery.Anno1
   14.45 +public class ProcessingEnvAnnoDiscovery<@ProcessingEnvAnnoDiscovery.Anno4 T>
   14.46 +        extends JavacTestingAbstractProcessor {
   14.47 +    private int round = 0;
   14.48 +
   14.49 +    public boolean process(Set<? extends TypeElement> annos, RoundEnvironment rEnv) {
   14.50 +        if (round++ == 0) {
   14.51 +            System.out.println(annos);
   14.52 +            Assert.check(annos.contains(eltUtils.getTypeElement("java.lang.annotation.Target")));
   14.53 +            Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno1")));
   14.54 +            Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno2")));
   14.55 +            Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno3")));
   14.56 +            Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno4")));
   14.57 +            Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno5")));
   14.58 +            Assert.check(annos.size() == 6, "Found extra annotations"); //Anno1-5 + @Target
   14.59 +        }
   14.60 +
   14.61 +        return true;
   14.62 +    }
   14.63 +
   14.64 +    @Anno2
   14.65 +    public <@Anno5 K> K m(@Anno3 long foo) {
   14.66 +        return null;
   14.67 +    }
   14.68 +
   14.69 +    @interface Anno1 {}
   14.70 +
   14.71 +    @interface Anno2 {}
   14.72 +
   14.73 +    @interface Anno3 {}
   14.74 +
   14.75 +    @Target(ElementType.TYPE_PARAMETER)
   14.76 +    @interface Anno4 {}
   14.77 +
   14.78 +    @Target(ElementType.TYPE_PARAMETER)
   14.79 +    @interface Anno5 {}
   14.80 +
   14.81 +}
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/test/tools/javac/processing/environment/round/Anno.java	Wed Apr 09 12:27:24 2014 -0700
    15.3 @@ -0,0 +1,28 @@
    15.4 +/*
    15.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    15.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    15.7 + *
    15.8 + * This code is free software; you can redistribute it and/or modify it
    15.9 + * under the terms of the GNU General Public License version 2 only, as
   15.10 + * published by the Free Software Foundation.
   15.11 + *
   15.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   15.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   15.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   15.15 + * version 2 for more details (a copy is included in the LICENSE file that
   15.16 + * accompanied this code).
   15.17 + *
   15.18 + * You should have received a copy of the GNU General Public License version
   15.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   15.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   15.21 + *
   15.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   15.23 + * or visit www.oracle.com if you need additional information or have any
   15.24 + * questions.
   15.25 + */
   15.26 +
   15.27 +import java.lang.annotation.*;
   15.28 +import static java.lang.annotation.RetentionPolicy.*;
   15.29 +
   15.30 +@Retention(RUNTIME)
   15.31 +public @interface Anno {}
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/test/tools/javac/processing/environment/round/ParameterAnnotations.java	Wed Apr 09 12:27:24 2014 -0700
    16.3 @@ -0,0 +1,33 @@
    16.4 +/*
    16.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    16.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    16.7 + *
    16.8 + * This code is free software; you can redistribute it and/or modify it
    16.9 + * under the terms of the GNU General Public License version 2 only, as
   16.10 + * published by the Free Software Foundation.
   16.11 + *
   16.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   16.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   16.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   16.15 + * version 2 for more details (a copy is included in the LICENSE file that
   16.16 + * accompanied this code).
   16.17 + *
   16.18 + * You should have received a copy of the GNU General Public License version
   16.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   16.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   16.21 + *
   16.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   16.23 + * or visit www.oracle.com if you need additional information or have any
   16.24 + * questions.
   16.25 + */
   16.26 +
   16.27 +/**
   16.28 + * Class to hold annotations for ElementsAnnotatedWithTest.
   16.29 + */
   16.30 +
   16.31 +@AnnotatedElementInfo(annotationName="Anno",
   16.32 +                      expectedSize=1,
   16.33 +                      names={"annotatedParameter"})
   16.34 +public class ParameterAnnotations {
   16.35 +    private void foo(@Anno Object annotatedParameter) {}
   16.36 +}
    17.1 --- a/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java	Wed Apr 02 10:03:21 2014 -0700
    17.2 +++ b/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java	Wed Apr 09 12:27:24 2014 -0700
    17.3 @@ -23,7 +23,7 @@
    17.4  
    17.5  /*
    17.6   * @test
    17.7 - * @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854 8030049
    17.8 + * @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854 8030049 8038080
    17.9   * @summary Tests that getElementsAnnotatedWith works properly.
   17.10   * @author  Joseph D. Darcy
   17.11   * @library /tools/javac/lib
   17.12 @@ -31,12 +31,14 @@
   17.13   * @compile TestElementsAnnotatedWith.java
   17.14   * @compile InheritedAnnotation.java
   17.15   * @compile TpAnno.java
   17.16 + * @compile Anno.java
   17.17   * @compile -processor TestElementsAnnotatedWith -proc:only SurfaceAnnotations.java
   17.18   * @compile -processor TestElementsAnnotatedWith -proc:only BuriedAnnotations.java
   17.19   * @compile -processor TestElementsAnnotatedWith -proc:only Part1.java Part2.java
   17.20   * @compile -processor TestElementsAnnotatedWith -proc:only C2.java
   17.21   * @compile -processor TestElementsAnnotatedWith -proc:only Foo.java
   17.22   * @compile -processor TestElementsAnnotatedWith -proc:only TypeParameterAnnotations.java
   17.23 + * @compile -processor TestElementsAnnotatedWith -proc:only ParameterAnnotations.java
   17.24   * @compile/fail/ref=ErroneousAnnotations.out -processor TestElementsAnnotatedWith -proc:only -XDrawDiagnostics ErroneousAnnotations.java
   17.25   * @compile Foo.java
   17.26   * @compile/process -processor TestElementsAnnotatedWith -proc:only Foo
    18.1 --- a/test/tools/javap/T4975569.java	Wed Apr 02 10:03:21 2014 -0700
    18.2 +++ b/test/tools/javap/T4975569.java	Wed Apr 09 12:27:24 2014 -0700
    18.3 @@ -40,10 +40,10 @@
    18.4          verify("T4975569$Anno", "flags: ACC_INTERFACE, ACC_ABSTRACT, ACC_ANNOTATION");
    18.5          verify("T4975569$E",    "flags: ACC_FINAL, ACC_SUPER, ACC_ENUM");
    18.6          verify("T4975569$S",    "flags: ACC_BRIDGE, ACC_SYNTHETIC",
    18.7 -                                "InnerClasses:\n       static");
    18.8 +                                "InnerClasses:\n     static");
    18.9          verify("T4975569$V",    "void m(java.lang.String...)",
   18.10                                  "flags: ACC_VARARGS");
   18.11 -        verify("T4975569$Prot", "InnerClasses:\n       protected");
   18.12 +        verify("T4975569$Prot", "InnerClasses:\n     protected");
   18.13          //verify("T4975569$Priv", "InnerClasses");
   18.14          if (errors > 0)
   18.15              throw new Error(errors + " found.");
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/test/tools/javap/T8035104.java	Wed Apr 09 12:27:24 2014 -0700
    19.3 @@ -0,0 +1,67 @@
    19.4 +/*
    19.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    19.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    19.7 + *
    19.8 + * This code is free software; you can redistribute it and/or modify it
    19.9 + * under the terms of the GNU General Public License version 2 only, as
   19.10 + * published by the Free Software Foundation.
   19.11 + *
   19.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   19.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   19.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   19.15 + * version 2 for more details (a copy is included in the LICENSE file that
   19.16 + * accompanied this code).
   19.17 + *
   19.18 + * You should have received a copy of the GNU General Public License version
   19.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   19.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   19.21 + *
   19.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   19.23 + * or visit www.oracle.com if you need additional information or have any
   19.24 + * questions.
   19.25 + */
   19.26 +
   19.27 +/*
   19.28 + * @test
   19.29 + * @bug 8035104
   19.30 + * @summary reorder class file attributes in javap listing
   19.31 + */
   19.32 +
   19.33 +import java.io.*;
   19.34 +
   19.35 +public class T8035104 {
   19.36 +    public static void main(String[] args) throws Exception {
   19.37 +        new T8035104().run();
   19.38 +    }
   19.39 +
   19.40 +    public void run() throws Exception {
   19.41 +        String[] lines = javap("-v", T8035104.class.getName()).split("[\r\n]+");
   19.42 +        int minor = -1;
   19.43 +        int SourceFile = -1;
   19.44 +        for (int i = 0; i < lines.length; i++) {
   19.45 +            String line = lines[i];
   19.46 +            if (line.matches(" *minor version: [0-9.]+"))
   19.47 +                minor = i;
   19.48 +            if (line.matches(" *SourceFile: .+"))
   19.49 +                SourceFile = i;
   19.50 +        }
   19.51 +        if (minor == -1)
   19.52 +            throw new Exception("minor version not found");
   19.53 +        if (SourceFile == -1)
   19.54 +            throw new Exception("SourceFile not found");
   19.55 +        if (SourceFile < minor)
   19.56 +            throw new Exception("unexpected order of output");
   19.57 +
   19.58 +        System.out.println("output OK");
   19.59 +    }
   19.60 +
   19.61 +    String javap(String... args) {
   19.62 +        StringWriter sw = new StringWriter();
   19.63 +        PrintWriter out = new PrintWriter(sw);
   19.64 +        int rc = com.sun.tools.javap.Main.run(args, out);
   19.65 +        out.close();
   19.66 +        System.out.println(sw.toString());
   19.67 +        System.out.println("javap exited, rc=" + rc);
   19.68 +        return sw.toString();
   19.69 +    }
   19.70 +}

mercurial