Merge

Tue, 01 Apr 2014 11:44:05 -0700

author
amurillo
date
Tue, 01 Apr 2014 11:44:05 -0700
changeset 2308
ca85c078f545
parent 2299
0f821eb7e92b
parent 2307
a5fdd84e258a
child 2309
aa0cb3af23d3
child 2352
33c9946d2875

Merge

     1.1 --- a/src/share/classes/com/sun/tools/javac/code/Symbol.java	Wed Mar 26 12:01:32 2014 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java	Tue Apr 01 11:44:05 2014 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -467,11 +467,24 @@
    1.11  
    1.12      private boolean hiddenIn(ClassSymbol clazz, Types types) {
    1.13          Symbol sym = hiddenInInternal(clazz, types);
    1.14 -        return sym != null && sym != this;
    1.15 +        Assert.check(sym != null, "the result of hiddenInInternal() can't be null");
    1.16 +        /* If we find the current symbol then there is no symbol hiding it
    1.17 +         */
    1.18 +        return sym != this;
    1.19      }
    1.20  
    1.21 -    private Symbol hiddenInInternal(ClassSymbol c, Types types) {
    1.22 -        Scope.Entry e = c.members().lookup(name);
    1.23 +    /** This method looks in the supertypes graph that has the current class as the
    1.24 +     * initial node, till it finds the current symbol or another symbol that hides it.
    1.25 +     * If the current class has more than one supertype (extends one class and
    1.26 +     * implements one or more interfaces) then null can be returned, meaning that
    1.27 +     * a wrong path in the supertypes graph was selected. Null can only be returned
    1.28 +     * as a temporary value, as a result of the recursive call.
    1.29 +     */
    1.30 +    private Symbol hiddenInInternal(ClassSymbol currentClass, Types types) {
    1.31 +        if (currentClass == owner) {
    1.32 +            return this;
    1.33 +        }
    1.34 +        Scope.Entry e = currentClass.members().lookup(name);
    1.35          while (e.scope != null) {
    1.36              if (e.sym.kind == kind &&
    1.37                      (kind != MTH ||
    1.38 @@ -481,18 +494,19 @@
    1.39              }
    1.40              e = e.next();
    1.41          }
    1.42 -        List<Symbol> hiddenSyms = List.nil();
    1.43 -        for (Type st : types.interfaces(c.type).prepend(types.supertype(c.type))) {
    1.44 +        Symbol hiddenSym = null;
    1.45 +        for (Type st : types.interfaces(currentClass.type)
    1.46 +                .prepend(types.supertype(currentClass.type))) {
    1.47              if (st != null && (st.hasTag(CLASS))) {
    1.48                  Symbol sym = hiddenInInternal((ClassSymbol)st.tsym, types);
    1.49 -                if (sym != null) {
    1.50 -                    hiddenSyms = hiddenSyms.prepend(hiddenInInternal((ClassSymbol)st.tsym, types));
    1.51 +                if (sym == this) {
    1.52 +                    return this;
    1.53 +                } else if (sym != null) {
    1.54 +                    hiddenSym = sym;
    1.55                  }
    1.56              }
    1.57          }
    1.58 -        return hiddenSyms.contains(this) ?
    1.59 -                this :
    1.60 -                (hiddenSyms.isEmpty() ? null : hiddenSyms.head);
    1.61 +        return hiddenSym;
    1.62      }
    1.63  
    1.64      /** Is this symbol inherited into a given class?
     2.1 --- a/src/share/classes/com/sun/tools/javac/code/Type.java	Wed Mar 26 12:01:32 2014 -0700
     2.2 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java	Tue Apr 01 11:44:05 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 @@ -1481,8 +1481,21 @@
    2.11          }
    2.12  
    2.13          public String toString() {
    2.14 -            if (inst != null) return inst.toString();
    2.15 -            else return qtype + "?";
    2.16 +            return (inst == null) ? qtype + "?" : inst.toString();
    2.17 +        }
    2.18 +
    2.19 +        public String debugString() {
    2.20 +            String result = "inference var = " + qtype + "\n";
    2.21 +            if (inst != null) {
    2.22 +                result += "inst = " + inst + '\n';
    2.23 +            }
    2.24 +            for (InferenceBound bound: InferenceBound.values()) {
    2.25 +                List<Type> aboundList = bounds.get(bound);
    2.26 +                if (aboundList.size() > 0) {
    2.27 +                    result += bound + " = " + aboundList + '\n';
    2.28 +                }
    2.29 +            }
    2.30 +            return result;
    2.31          }
    2.32  
    2.33          @Override
    2.34 @@ -1492,8 +1505,7 @@
    2.35  
    2.36          @Override
    2.37          public Type baseType() {
    2.38 -            if (inst != null) return inst.baseType();
    2.39 -            else return this;
    2.40 +            return (inst == null) ? this : inst.baseType();
    2.41          }
    2.42  
    2.43          /** get all bounds of a given kind */
     3.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Wed Mar 26 12:01:32 2014 -0700
     3.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Tue Apr 01 11:44:05 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 @@ -2119,6 +2119,12 @@
    3.11              //back-door to infer
    3.12              return Infer.this;
    3.13          }
    3.14 +
    3.15 +        @Override
    3.16 +        public String toString() {
    3.17 +            return "Inference vars: " + inferencevars + '\n' +
    3.18 +                   "Undet vars: " + undetvars;
    3.19 +        }
    3.20      }
    3.21  
    3.22      final InferenceContext emptyContext = new InferenceContext(List.<Type>nil());
     4.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Wed Mar 26 12:01:32 2014 -0700
     4.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Tue Apr 01 11:44:05 2014 -0700
     4.3 @@ -1038,7 +1038,7 @@
     4.4              }
     4.5              databuf.appendChar(pool.get(inner));
     4.6              databuf.appendChar(
     4.7 -                inner.owner.kind == TYP ? pool.get(inner.owner) : 0);
     4.8 +                inner.owner.kind == TYP && !inner.name.isEmpty() ? pool.get(inner.owner) : 0);
     4.9              databuf.appendChar(
    4.10                  !inner.name.isEmpty() ? pool.get(inner.name) : 0);
    4.11              databuf.appendChar(flags);
     5.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Code.java	Wed Mar 26 12:01:32 2014 -0700
     5.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java	Tue Apr 01 11:44:05 2014 -0700
     5.3 @@ -1,5 +1,5 @@
     5.4  /*
     5.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
     5.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
     5.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.8   *
     5.9   * This code is free software; you can redistribute it and/or modify it
    5.10 @@ -2189,9 +2189,9 @@
    5.11          // Keep local variables if
    5.12          // 1) we need them for debug information
    5.13          // 2) it is an exception type and it contains type annotations
    5.14 -        if (!varDebugInfo &&
    5.15 -                (!var.sym.isExceptionParameter() ||
    5.16 -                var.sym.hasTypeAnnotations())) return;
    5.17 +        boolean keepLocalVariables = varDebugInfo ||
    5.18 +            (var.sym.isExceptionParameter() && var.sym.hasTypeAnnotations());
    5.19 +        if (!keepLocalVariables) return;
    5.20          if ((var.sym.flags() & Flags.SYNTHETIC) != 0) return;
    5.21          if (varBuffer == null)
    5.22              varBuffer = new LocalVar[20];
     6.1 --- a/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Wed Mar 26 12:01:32 2014 -0700
     6.2 +++ b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Tue Apr 01 11:44:05 2014 -0700
     6.3 @@ -762,14 +762,14 @@
     6.4          public Set<TypeElement> visitType(TypeElement e, Set<TypeElement> p) {
     6.5              // Type parameters are not considered to be enclosed by a type
     6.6              scan(e.getTypeParameters(), p);
     6.7 -            return scan(e.getEnclosedElements(), p);
     6.8 +            return super.visitType(e, p);
     6.9          }
    6.10  
    6.11          @Override
    6.12          public Set<TypeElement> visitExecutable(ExecutableElement e, Set<TypeElement> p) {
    6.13              // Type parameters are not considered to be enclosed by an executable
    6.14              scan(e.getTypeParameters(), p);
    6.15 -            return scan(e.getEnclosedElements(), p);
    6.16 +            return super.visitExecutable(e, p);
    6.17          }
    6.18  
    6.19          void addAnnotations(Element e, Set<TypeElement> p) {
     7.1 --- a/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java	Wed Mar 26 12:01:32 2014 -0700
     7.2 +++ b/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java	Tue Apr 01 11:44:05 2014 -0700
     7.3 @@ -137,14 +137,14 @@
     7.4          public Set<Element> visitType(TypeElement e, 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<Element> visitExecutable(ExecutableElement e, 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          @Override
     8.1 --- a/src/share/classes/com/sun/tools/javap/ClassWriter.java	Wed Mar 26 12:01:32 2014 -0700
     8.2 +++ b/src/share/classes/com/sun/tools/javap/ClassWriter.java	Tue Apr 01 11:44:05 2014 -0700
     8.3 @@ -202,7 +202,6 @@
     8.4          if (options.verbose) {
     8.5              println();
     8.6              indent(+1);
     8.7 -            attrWriter.write(cf, cf.attributes, constant_pool);
     8.8              println("minor version: " + cf.minor_version);
     8.9              println("major version: " + cf.major_version);
    8.10              writeList("flags: ", flags.getClassFlags(), "\n");
    8.11 @@ -218,6 +217,10 @@
    8.12          writeMethods();
    8.13          indent(-1);
    8.14          println("}");
    8.15 +
    8.16 +        if (options.verbose) {
    8.17 +            attrWriter.write(cf, cf.attributes, constant_pool);
    8.18 +        }
    8.19      }
    8.20      // where
    8.21          class JavaTypePrinter implements Type.Visitor<StringBuilder,StringBuilder> {
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/test/tools/javac/IncorrectInheritance/IncorrectInheritanceTest.java	Tue Apr 01 11:44:05 2014 -0700
     9.3 @@ -0,0 +1,68 @@
     9.4 +/*
     9.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
     9.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     9.7 + *
     9.8 + * This code is free software; you can redistribute it and/or modify it
     9.9 + * under the terms of the GNU General Public License version 2 only, as
    9.10 + * published by the Free Software Foundation.
    9.11 + *
    9.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    9.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    9.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    9.15 + * version 2 for more details (a copy is included in the LICENSE file that
    9.16 + * accompanied this code).
    9.17 + *
    9.18 + * You should have received a copy of the GNU General Public License version
    9.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    9.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    9.21 + *
    9.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    9.23 + * or visit www.oracle.com if you need additional information or have any
    9.24 + * questions.
    9.25 + */
    9.26 +
    9.27 +/*
    9.28 + * @test
    9.29 + * @bug 8034924
    9.30 + * @summary Incorrect inheritance of inaccessible static method
    9.31 + * @library /tools/javac/lib
    9.32 + * @build ToolBox
    9.33 + * @run main IncorrectInheritanceTest
    9.34 + */
    9.35 +
    9.36 +public class IncorrectInheritanceTest {
    9.37 +    private static final String ASrc =
    9.38 +            "package pkg;\n" +
    9.39 +            "\n" +
    9.40 +            "public class A {\n" +
    9.41 +            "    static void foo(Object o) {}\n" +
    9.42 +            "    private static void bar(Object o) {}\n" +
    9.43 +            "}";
    9.44 +
    9.45 +    private static final String BSrc =
    9.46 +            "import pkg.A;\n" +
    9.47 +            "class B extends A {\n" +
    9.48 +            "    public void foo(Object o) {}\n" +
    9.49 +            "    public void bar(Object o) {}\n" +
    9.50 +            "}";
    9.51 +
    9.52 +    private static final String CSrc =
    9.53 +            "class C extends B {\n" +
    9.54 +            "    public void m(Object o) {\n" +
    9.55 +            "        foo(o);\n" +
    9.56 +            "        bar(o);\n" +
    9.57 +            "    }\n" +
    9.58 +            "}";
    9.59 +
    9.60 +    public static void main(String[] args) throws Exception {
    9.61 +        new IncorrectInheritanceTest().test();
    9.62 +    }
    9.63 +
    9.64 +    public void test() throws Exception {
    9.65 +        ToolBox.JavaToolArgs javacParams =
    9.66 +                new ToolBox.JavaToolArgs()
    9.67 +                .setSources(ASrc, BSrc, CSrc);
    9.68 +        ToolBox.javac(javacParams);
    9.69 +    }
    9.70 +
    9.71 +}
    10.1 --- a/test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java	Wed Mar 26 12:01:32 2014 -0700
    10.2 +++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java	Tue Apr 01 11:44:05 2014 -0700
    10.3 @@ -1,5 +1,5 @@
    10.4  /*
    10.5 - * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
    10.6 + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
    10.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    10.8   *
    10.9   * This code is free software; you can redistribute it and/or modify it
   10.10 @@ -30,6 +30,7 @@
   10.11  import java.lang.annotation.*;
   10.12  import java.lang.reflect.*;
   10.13  import java.util.ArrayList;
   10.14 +import java.util.Arrays;
   10.15  import java.util.Collections;
   10.16  import java.util.HashMap;
   10.17  import java.util.List;
   10.18 @@ -51,6 +52,11 @@
   10.19          new Driver().runDriver(clazz.newInstance());
   10.20      }
   10.21  
   10.22 +    String[][] extraParamsCombinations = new String[][] {
   10.23 +        new String[] { },
   10.24 +        new String[] { "-g" },
   10.25 +    };
   10.26 +
   10.27      protected void runDriver(Object object) throws Exception {
   10.28          int passed = 0, failed = 0;
   10.29          Class<?> clazz = object.getClass();
   10.30 @@ -65,18 +71,20 @@
   10.31                  throw new IllegalArgumentException("Test method needs to return a string: " + method);
   10.32              String testClass = testClassOf(method);
   10.33  
   10.34 -            try {
   10.35 -                String compact = (String)method.invoke(object);
   10.36 -                String fullFile = wrap(compact);
   10.37 -                ClassFile cf = compileAndReturn(fullFile, testClass);
   10.38 -                List<TypeAnnotation> actual = ReferenceInfoUtil.extendedAnnotationsOf(cf);
   10.39 -                ReferenceInfoUtil.compare(expected, actual, cf);
   10.40 -                out.println("PASSED:  " + method.getName());
   10.41 -                ++passed;
   10.42 -            } catch (Throwable e) {
   10.43 -                out.println("FAILED:  " + method.getName());
   10.44 -                out.println("    " + e.toString());
   10.45 -                ++failed;
   10.46 +            for (String[] extraParams : extraParamsCombinations) {
   10.47 +                try {
   10.48 +                    String compact = (String)method.invoke(object);
   10.49 +                    String fullFile = wrap(compact);
   10.50 +                    ClassFile cf = compileAndReturn(fullFile, testClass, extraParams);
   10.51 +                    List<TypeAnnotation> actual = ReferenceInfoUtil.extendedAnnotationsOf(cf);
   10.52 +                    ReferenceInfoUtil.compare(expected, actual, cf);
   10.53 +                    out.println("PASSED:  " + method.getName());
   10.54 +                    ++passed;
   10.55 +                } catch (Throwable e) {
   10.56 +                    out.println("FAILED:  " + method.getName());
   10.57 +                    out.println("    " + e.toString());
   10.58 +                    ++failed;
   10.59 +                }
   10.60              }
   10.61          }
   10.62  
   10.63 @@ -156,7 +164,7 @@
   10.64          }
   10.65      }
   10.66  
   10.67 -    private ClassFile compileAndReturn(String fullFile, String testClass) throws Exception {
   10.68 +    private ClassFile compileAndReturn(String fullFile, String testClass, String... extraParams) throws Exception {
   10.69          File source = writeTestFile(fullFile);
   10.70          File clazzFile = compileTestFile(source, testClass);
   10.71          return ClassFile.read(clazzFile);
   10.72 @@ -170,8 +178,12 @@
   10.73          return f;
   10.74      }
   10.75  
   10.76 -    protected File compileTestFile(File f, String testClass) {
   10.77 -        int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.8", "-g", f.getPath() });
   10.78 +    protected File compileTestFile(File f, String testClass, String... extraParams) {
   10.79 +        List<String> options = new ArrayList<>();
   10.80 +        options.addAll(Arrays.asList("-source", "1.8"));
   10.81 +        options.addAll(Arrays.asList(extraParams));
   10.82 +        options.add(f.getPath());
   10.83 +        int rc = com.sun.tools.javac.Main.compile(options.toArray(new String[options.size()]));
   10.84          if (rc != 0)
   10.85              throw new Error("compilation failed. rc=" + rc);
   10.86          String path;
    11.1 --- a/test/tools/javac/annotations/typeAnnotations/referenceinfos/ExceptionParameters.java	Wed Mar 26 12:01:32 2014 -0700
    11.2 +++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/ExceptionParameters.java	Tue Apr 01 11:44:05 2014 -0700
    11.3 @@ -1,5 +1,5 @@
    11.4  /*
    11.5 - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    11.6 + * Copyright (c) 2013, 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 @@ -25,6 +25,7 @@
   11.11  
   11.12  /*
   11.13   * @test
   11.14 + * @bug 8028576
   11.15   * @summary Test population of reference info for exception parameters
   11.16   * @author Werner Dietl
   11.17   * @compile -g Driver.java ReferenceInfoUtil.java ExceptionParameters.java
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/test/tools/javac/classfiles/InnerClasses/SyntheticClasses.java	Tue Apr 01 11:44:05 2014 -0700
    12.3 @@ -0,0 +1,97 @@
    12.4 +/*
    12.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    12.7 + *
    12.8 + * This code is free software; you can redistribute it and/or modify it
    12.9 + * under the terms of the GNU General Public License version 2 only, as
   12.10 + * published by the Free Software Foundation.
   12.11 + *
   12.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   12.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   12.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   12.15 + * version 2 for more details (a copy is included in the LICENSE file that
   12.16 + * accompanied this code).
   12.17 + *
   12.18 + * You should have received a copy of the GNU General Public License version
   12.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   12.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   12.21 + *
   12.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   12.23 + * or visit www.oracle.com if you need additional information or have any
   12.24 + * questions.
   12.25 + */
   12.26 +
   12.27 +/** @test
   12.28 + *  @bug 8034854
   12.29 + *  @summary Verify that the InnerClasses attribute has outer_class_info_index zero if it has
   12.30 + *           inner_name_index zero (for synthetic classes)
   12.31 + *  @compile SyntheticClasses.java
   12.32 + *  @run main SyntheticClasses
   12.33 + */
   12.34 +
   12.35 +import java.io.*;
   12.36 +import java.util.*;
   12.37 +import com.sun.tools.classfile.*;
   12.38 +
   12.39 +public class SyntheticClasses {
   12.40 +
   12.41 +    public static void main(String[] args) throws IOException, ConstantPoolException {
   12.42 +        new SyntheticClasses().run();
   12.43 +    }
   12.44 +
   12.45 +    private void run() throws IOException, ConstantPoolException {
   12.46 +        File testClasses = new File(System.getProperty("test.classes"));
   12.47 +        for (File classFile : testClasses.listFiles()) {
   12.48 +            ClassFile cf = ClassFile.read(classFile);
   12.49 +            if (cf.getName().matches(".*\\$[0-9]+")) {
   12.50 +                EnclosingMethod_attribute encl =
   12.51 +                        (EnclosingMethod_attribute) cf.getAttribute(Attribute.EnclosingMethod);
   12.52 +                if (encl != null) {
   12.53 +                    if (encl.method_index != 0)
   12.54 +                        throw new IllegalStateException("Invalid EnclosingMethod.method_index: " +
   12.55 +                                                        encl.method_index + ".");
   12.56 +                }
   12.57 +            }
   12.58 +            InnerClasses_attribute attr =
   12.59 +                    (InnerClasses_attribute) cf.getAttribute(Attribute.InnerClasses);
   12.60 +            if (attr != null) {
   12.61 +                for (InnerClasses_attribute.Info info : attr.classes) {
   12.62 +                    if (cf.major_version < 51)
   12.63 +                        throw new IllegalStateException();
   12.64 +                    if (info.inner_name_index == 0 && info.outer_class_info_index != 0)
   12.65 +                        throw new IllegalStateException("Invalid outer_class_info_index=" +
   12.66 +                                                        info.outer_class_info_index +
   12.67 +                                                        "; inner_name_index=" +
   12.68 +                                                        info.inner_name_index + ".");
   12.69 +                }
   12.70 +            }
   12.71 +        }
   12.72 +    }
   12.73 +}
   12.74 +
   12.75 +class SyntheticConstructorAccessTag {
   12.76 +
   12.77 +    private static class A {
   12.78 +        private A(){}
   12.79 +    }
   12.80 +
   12.81 +    public void test() {
   12.82 +        new A();
   12.83 +    }
   12.84 +}
   12.85 +
   12.86 +class SyntheticEnumMapping {
   12.87 +    private int convert(E e) {
   12.88 +        switch (e) {
   12.89 +            case A: return 0;
   12.90 +            default: return -1;
   12.91 +        }
   12.92 +    }
   12.93 +    enum E { A }
   12.94 +}
   12.95 +
   12.96 +interface SyntheticAssertionsDisabled {
   12.97 +    public default void test() {
   12.98 +        assert false;
   12.99 +    }
  12.100 +}
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/test/tools/javac/processing/environment/ProcessingEnvAnnoDiscovery.java	Tue Apr 01 11:44:05 2014 -0700
    13.3 @@ -0,0 +1,78 @@
    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 +/*
   13.28 + * @test
   13.29 + * @bug 8038080
   13.30 + * @summary make sure that all declaration annotations are discovered
   13.31 + *          by the processing environment
   13.32 + * @library /tools/javac/lib
   13.33 + * @build JavacTestingAbstractProcessor ProcessingEnvAnnoDiscovery
   13.34 + * @compile/process -processor ProcessingEnvAnnoDiscovery ProcessingEnvAnnoDiscovery.java
   13.35 + */
   13.36 +
   13.37 +import java.lang.annotation.*;
   13.38 +import java.util.Set;
   13.39 +import javax.annotation.processing.*;
   13.40 +import javax.lang.model.element.*;
   13.41 +
   13.42 +import com.sun.tools.javac.util.*;
   13.43 +
   13.44 +@ProcessingEnvAnnoDiscovery.Anno1
   13.45 +public class ProcessingEnvAnnoDiscovery<@ProcessingEnvAnnoDiscovery.Anno4 T>
   13.46 +        extends JavacTestingAbstractProcessor {
   13.47 +    private int round = 0;
   13.48 +
   13.49 +    public boolean process(Set<? extends TypeElement> annos, RoundEnvironment rEnv) {
   13.50 +        if (round++ == 0) {
   13.51 +            System.out.println(annos);
   13.52 +            Assert.check(annos.contains(eltUtils.getTypeElement("java.lang.annotation.Target")));
   13.53 +            Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno1")));
   13.54 +            Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno2")));
   13.55 +            Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno3")));
   13.56 +            Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno4")));
   13.57 +            Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno5")));
   13.58 +            Assert.check(annos.size() == 6, "Found extra annotations"); //Anno1-5 + @Target
   13.59 +        }
   13.60 +
   13.61 +        return true;
   13.62 +    }
   13.63 +
   13.64 +    @Anno2
   13.65 +    public <@Anno5 K> K m(@Anno3 long foo) {
   13.66 +        return null;
   13.67 +    }
   13.68 +
   13.69 +    @interface Anno1 {}
   13.70 +
   13.71 +    @interface Anno2 {}
   13.72 +
   13.73 +    @interface Anno3 {}
   13.74 +
   13.75 +    @Target(ElementType.TYPE_PARAMETER)
   13.76 +    @interface Anno4 {}
   13.77 +
   13.78 +    @Target(ElementType.TYPE_PARAMETER)
   13.79 +    @interface Anno5 {}
   13.80 +
   13.81 +}
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/test/tools/javac/processing/environment/round/Anno.java	Tue Apr 01 11:44:05 2014 -0700
    14.3 @@ -0,0 +1,28 @@
    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 +import java.lang.annotation.*;
   14.28 +import static java.lang.annotation.RetentionPolicy.*;
   14.29 +
   14.30 +@Retention(RUNTIME)
   14.31 +public @interface Anno {}
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/test/tools/javac/processing/environment/round/ParameterAnnotations.java	Tue Apr 01 11:44:05 2014 -0700
    15.3 @@ -0,0 +1,33 @@
    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 +/**
   15.28 + * Class to hold annotations for ElementsAnnotatedWithTest.
   15.29 + */
   15.30 +
   15.31 +@AnnotatedElementInfo(annotationName="Anno",
   15.32 +                      expectedSize=1,
   15.33 +                      names={"annotatedParameter"})
   15.34 +public class ParameterAnnotations {
   15.35 +    private void foo(@Anno Object annotatedParameter) {}
   15.36 +}
    16.1 --- a/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java	Wed Mar 26 12:01:32 2014 -0700
    16.2 +++ b/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java	Tue Apr 01 11:44:05 2014 -0700
    16.3 @@ -23,7 +23,7 @@
    16.4  
    16.5  /*
    16.6   * @test
    16.7 - * @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854 8030049
    16.8 + * @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854 8030049 8038080
    16.9   * @summary Tests that getElementsAnnotatedWith works properly.
   16.10   * @author  Joseph D. Darcy
   16.11   * @library /tools/javac/lib
   16.12 @@ -31,12 +31,14 @@
   16.13   * @compile TestElementsAnnotatedWith.java
   16.14   * @compile InheritedAnnotation.java
   16.15   * @compile TpAnno.java
   16.16 + * @compile Anno.java
   16.17   * @compile -processor TestElementsAnnotatedWith -proc:only SurfaceAnnotations.java
   16.18   * @compile -processor TestElementsAnnotatedWith -proc:only BuriedAnnotations.java
   16.19   * @compile -processor TestElementsAnnotatedWith -proc:only Part1.java Part2.java
   16.20   * @compile -processor TestElementsAnnotatedWith -proc:only C2.java
   16.21   * @compile -processor TestElementsAnnotatedWith -proc:only Foo.java
   16.22   * @compile -processor TestElementsAnnotatedWith -proc:only TypeParameterAnnotations.java
   16.23 + * @compile -processor TestElementsAnnotatedWith -proc:only ParameterAnnotations.java
   16.24   * @compile/fail/ref=ErroneousAnnotations.out -processor TestElementsAnnotatedWith -proc:only -XDrawDiagnostics ErroneousAnnotations.java
   16.25   * @compile Foo.java
   16.26   * @compile/process -processor TestElementsAnnotatedWith -proc:only Foo
    17.1 --- a/test/tools/javap/T4975569.java	Wed Mar 26 12:01:32 2014 -0700
    17.2 +++ b/test/tools/javap/T4975569.java	Tue Apr 01 11:44:05 2014 -0700
    17.3 @@ -40,10 +40,10 @@
    17.4          verify("T4975569$Anno", "flags: ACC_INTERFACE, ACC_ABSTRACT, ACC_ANNOTATION");
    17.5          verify("T4975569$E",    "flags: ACC_FINAL, ACC_SUPER, ACC_ENUM");
    17.6          verify("T4975569$S",    "flags: ACC_BRIDGE, ACC_SYNTHETIC",
    17.7 -                                "InnerClasses:\n       static");
    17.8 +                                "InnerClasses:\n     static");
    17.9          verify("T4975569$V",    "void m(java.lang.String...)",
   17.10                                  "flags: ACC_VARARGS");
   17.11 -        verify("T4975569$Prot", "InnerClasses:\n       protected");
   17.12 +        verify("T4975569$Prot", "InnerClasses:\n     protected");
   17.13          //verify("T4975569$Priv", "InnerClasses");
   17.14          if (errors > 0)
   17.15              throw new Error(errors + " found.");
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/test/tools/javap/T8035104.java	Tue Apr 01 11:44:05 2014 -0700
    18.3 @@ -0,0 +1,67 @@
    18.4 +/*
    18.5 + * Copyright (c) 2014, 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 +/*
   18.28 + * @test
   18.29 + * @bug 8035104
   18.30 + * @summary reorder class file attributes in javap listing
   18.31 + */
   18.32 +
   18.33 +import java.io.*;
   18.34 +
   18.35 +public class T8035104 {
   18.36 +    public static void main(String[] args) throws Exception {
   18.37 +        new T8035104().run();
   18.38 +    }
   18.39 +
   18.40 +    public void run() throws Exception {
   18.41 +        String[] lines = javap("-v", T8035104.class.getName()).split("[\r\n]+");
   18.42 +        int minor = -1;
   18.43 +        int SourceFile = -1;
   18.44 +        for (int i = 0; i < lines.length; i++) {
   18.45 +            String line = lines[i];
   18.46 +            if (line.matches(" *minor version: [0-9.]+"))
   18.47 +                minor = i;
   18.48 +            if (line.matches(" *SourceFile: .+"))
   18.49 +                SourceFile = i;
   18.50 +        }
   18.51 +        if (minor == -1)
   18.52 +            throw new Exception("minor version not found");
   18.53 +        if (SourceFile == -1)
   18.54 +            throw new Exception("SourceFile not found");
   18.55 +        if (SourceFile < minor)
   18.56 +            throw new Exception("unexpected order of output");
   18.57 +
   18.58 +        System.out.println("output OK");
   18.59 +    }
   18.60 +
   18.61 +    String javap(String... args) {
   18.62 +        StringWriter sw = new StringWriter();
   18.63 +        PrintWriter out = new PrintWriter(sw);
   18.64 +        int rc = com.sun.tools.javap.Main.run(args, out);
   18.65 +        out.close();
   18.66 +        System.out.println(sw.toString());
   18.67 +        System.out.println("javap exited, rc=" + rc);
   18.68 +        return sw.toString();
   18.69 +    }
   18.70 +}

mercurial