Merge

Tue, 06 Oct 2015 11:04:41 -0700

author
asaha
date
Tue, 06 Oct 2015 11:04:41 -0700
changeset 2990
a3ac7297f72a
parent 2989
f00463ff3b1a
parent 2908
dfb368f2498e
child 2994
e59a1ed58d98

Merge

.hgtags file | annotate | diff | comparison | revisions
     1.1 --- a/.hgtags	Mon Sep 28 15:35:52 2015 -0700
     1.2 +++ b/.hgtags	Tue Oct 06 11:04:41 2015 -0700
     1.3 @@ -489,3 +489,4 @@
     1.4  8063e4ac4caabe1756f8393859ab56da3bb29122 jdk8u66-b15
     1.5  01e7f91d993b341986f574d0eb3fbfe3d7cae68e jdk8u66-b16
     1.6  1c93d260bf996e56d1e1f6d187aceadaa9a38d0c jdk8u72-b00
     1.7 +aec633bcb3af5382013c6c25b435564aba5bc3d4 jdk8u72-b01
     2.1 --- a/src/share/classes/com/sun/tools/javac/resources/javac.properties	Mon Sep 28 15:35:52 2015 -0700
     2.2 +++ b/src/share/classes/com/sun/tools/javac/resources/javac.properties	Tue Oct 06 11:04:41 2015 -0700
     2.3 @@ -232,9 +232,9 @@
     2.4  
     2.5  javac.msg.bug=\
     2.6  An exception has occurred in the compiler ({0}). \
     2.7 -Please file a bug at the Java Bug Database (http://bugreport.java.com/bugreport/) \
     2.8 -after checking the database for duplicates. \
     2.9 -Include your program and the following diagnostic in your report.  Thank you.
    2.10 +Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) \
    2.11 +after checking the Bug Database (http://bugs.java.com) for duplicates. \
    2.12 +Include your program and the following diagnostic in your report. Thank you.
    2.13  
    2.14  javac.msg.io=\
    2.15  \n\nAn input/output error occurred.\n\
     3.1 --- a/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java	Mon Sep 28 15:35:52 2015 -0700
     3.2 +++ b/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java	Tue Oct 06 11:04:41 2015 -0700
     3.3 @@ -124,19 +124,14 @@
     3.4       * Returns the flags of a ClassSymbol in terms of javac's flags
     3.5       */
     3.6      static long getFlags(ClassSymbol clazz) {
     3.7 -        while (true) {
     3.8 -            try {
     3.9 -                return clazz.flags();
    3.10 -            } catch (CompletionFailure ex) {
    3.11 -                /* Quietly ignore completion failures.
    3.12 -                 * Note that a CompletionFailure can only
    3.13 -                 * occur as a result of calling complete(),
    3.14 -                 * which will always remove the current
    3.15 -                 * completer, leaving it to be null or
    3.16 -                 * follow-up completer. Thus the loop
    3.17 -                 * is guaranteed to eventually terminate.
    3.18 -                 */
    3.19 -            }
    3.20 +        try {
    3.21 +            return clazz.flags();
    3.22 +        } catch (CompletionFailure ex) {
    3.23 +            /* Quietly ignore completion failures and try again - the type
    3.24 +             * for which the CompletionFailure was thrown shouldn't be completed
    3.25 +             * again by the completer that threw the CompletionFailure.
    3.26 +             */
    3.27 +            return getFlags(clazz);
    3.28          }
    3.29      }
    3.30  
     4.1 --- a/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java	Mon Sep 28 15:35:52 2015 -0700
     4.2 +++ b/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java	Tue Oct 06 11:04:41 2015 -0700
     4.3 @@ -128,7 +128,7 @@
     4.4               t.hasTag(CLASS);
     4.5               t = env.types.supertype(t)) {
     4.6              ClassSymbol c = (ClassSymbol)t.tsym;
     4.7 -            for (Scope.Entry e = c.members().lookup(sym.name); e.scope != null; e = e.next()) {
     4.8 +            for (Scope.Entry e = membersOf(c).lookup(sym.name); e.scope != null; e = e.next()) {
     4.9                  if (sym.overrides(e.sym, origin, env.types, true)) {
    4.10                      return TypeMaker.getType(env, t);
    4.11                  }
    4.12 @@ -160,7 +160,7 @@
    4.13               t.hasTag(CLASS);
    4.14               t = env.types.supertype(t)) {
    4.15              ClassSymbol c = (ClassSymbol)t.tsym;
    4.16 -            for (Scope.Entry e = c.members().lookup(sym.name); e.scope != null; e = e.next()) {
    4.17 +            for (Scope.Entry e = membersOf(c).lookup(sym.name); e.scope != null; e = e.next()) {
    4.18                  if (sym.overrides(e.sym, origin, env.types, true)) {
    4.19                      return env.getMethodDoc((MethodSymbol)e.sym);
    4.20                  }
    4.21 @@ -169,6 +169,19 @@
    4.22          return null;
    4.23      }
    4.24  
    4.25 +    /**Retrieve members of c, ignoring any CompletionFailures that occur. */
    4.26 +    private Scope membersOf(ClassSymbol c) {
    4.27 +        try {
    4.28 +            return c.members();
    4.29 +        } catch (CompletionFailure cf) {
    4.30 +            /* Quietly ignore completion failures and try again - the type
    4.31 +             * for which the CompletionFailure was thrown shouldn't be completed
    4.32 +             * again by the completer that threw the CompletionFailure.
    4.33 +             */
    4.34 +            return membersOf(c);
    4.35 +        }
    4.36 +    }
    4.37 +
    4.38      /**
    4.39       * Tests whether this method overrides another.
    4.40       * The overridden method may be one declared in a superclass or
     5.1 --- a/src/share/classes/com/sun/tools/javadoc/TypeMaker.java	Mon Sep 28 15:35:52 2015 -0700
     5.2 +++ b/src/share/classes/com/sun/tools/javadoc/TypeMaker.java	Tue Oct 06 11:04:41 2015 -0700
     5.3 @@ -28,6 +28,7 @@
     5.4  import com.sun.javadoc.*;
     5.5  import com.sun.tools.javac.code.Symbol;
     5.6  import com.sun.tools.javac.code.Symbol.ClassSymbol;
     5.7 +import com.sun.tools.javac.code.Symbol.CompletionFailure;
     5.8  import com.sun.tools.javac.code.Type;
     5.9  import com.sun.tools.javac.code.Type.ArrayType;
    5.10  import com.sun.tools.javac.code.Type.ClassType;
    5.11 @@ -56,8 +57,21 @@
    5.12          return getType(env, t, errorToClassDoc, true);
    5.13      }
    5.14  
    5.15 +    public static com.sun.javadoc.Type getType(DocEnv env, Type t,
    5.16 +            boolean errToClassDoc, boolean considerAnnotations) {
    5.17 +        try {
    5.18 +            return getTypeImpl(env, t, errToClassDoc, considerAnnotations);
    5.19 +        } catch (CompletionFailure cf) {
    5.20 +            /* Quietly ignore completion failures and try again - the type
    5.21 +             * for which the CompletionFailure was thrown shouldn't be completed
    5.22 +             * again by the completer that threw the CompletionFailure.
    5.23 +             */
    5.24 +            return getType(env, t, errToClassDoc, considerAnnotations);
    5.25 +        }
    5.26 +    }
    5.27 +
    5.28      @SuppressWarnings("fallthrough")
    5.29 -    public static com.sun.javadoc.Type getType(DocEnv env, Type t,
    5.30 +    private static com.sun.javadoc.Type getTypeImpl(DocEnv env, Type t,
    5.31              boolean errToClassDoc, boolean considerAnnotations) {
    5.32          if (env.legacyDoclet) {
    5.33              t = env.types.erasure(t);
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/test/tools/javadoc/CompletionError.java	Tue Oct 06 11:04:41 2015 -0700
     6.3 @@ -0,0 +1,174 @@
     6.4 +/*
     6.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
     6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.7 + *
     6.8 + * This code is free software; you can redistribute it and/or modify it
     6.9 + * under the terms of the GNU General Public License version 2 only, as
    6.10 + * published by the Free Software Foundation.
    6.11 + *
    6.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    6.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    6.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    6.15 + * version 2 for more details (a copy is included in the LICENSE file that
    6.16 + * accompanied this code).
    6.17 + *
    6.18 + * You should have received a copy of the GNU General Public License version
    6.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    6.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    6.21 + *
    6.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    6.23 + * or visit www.oracle.com if you need additional information or have any
    6.24 + * questions.
    6.25 + */
    6.26 +
    6.27 +/*
    6.28 + * @test
    6.29 + * @bug 8135307
    6.30 + * @summary Check that CompletionFailures for missing classes are not incorrectly passed to
    6.31 + *          the javadoc API clients.
    6.32 + * @modules jdk.javadoc
    6.33 + * @run main CompletionError
    6.34 + */
    6.35 +
    6.36 +import java.io.File;
    6.37 +import java.net.URI;
    6.38 +import java.nio.file.Files;
    6.39 +import java.nio.file.Paths;
    6.40 +import java.util.Arrays;
    6.41 +import java.util.List;
    6.42 +
    6.43 +import javax.tools.JavaCompiler;
    6.44 +import javax.tools.JavaFileObject;
    6.45 +import javax.tools.SimpleJavaFileObject;
    6.46 +import javax.tools.ToolProvider;
    6.47 +
    6.48 +import com.sun.javadoc.*;
    6.49 +import com.sun.tools.javadoc.Main;
    6.50 +
    6.51 +public class CompletionError extends Doclet
    6.52 +{
    6.53 +    private static final String template =
    6.54 +            "public class CompletionErrorAuxiliary #extends CompletionErrorMissing# #implements CompletionErrorIntfMissing# {" +
    6.55 +            "   #public CompletionErrorMissing tf;#" +
    6.56 +            "   #public CompletionErrorMissing tm() { return null; }#" +
    6.57 +            "   #public void tm(CompletionErrorMissing m) {}#" +
    6.58 +            "   #public void tm() throws CompletionErrorExcMissing {}#" +
    6.59 +            "   #public <T extends CompletionErrorMissing> void tm() {}#" +
    6.60 +            "   public String toString() { return null; }" +
    6.61 +            "}";
    6.62 +
    6.63 +    public static void main(String[] args) throws Exception {
    6.64 +        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    6.65 +        String[] templateParts = template.split("#");
    6.66 +        int sources = templateParts.length / 2;
    6.67 +        for (int source = 0; source < sources; source++) {
    6.68 +            StringBuilder testSource = new StringBuilder();
    6.69 +            for (int i = 0; i < templateParts.length; i += 2) {
    6.70 +                testSource.append(templateParts[i]);
    6.71 +                if (i == 2 * source) {
    6.72 +                    testSource.append(templateParts[i + 1]);
    6.73 +                }
    6.74 +            }
    6.75 +            test = 0;
    6.76 +            testsDone = false;
    6.77 +            while (!testsDone) {
    6.78 +                List<JavaSource> fileObjects =
    6.79 +                        Arrays.asList(new JavaSource("CompletionErrorAuxiliary", testSource.toString()),
    6.80 +                                      new JavaSource("CompletionErrorMissing", "public class CompletionErrorMissing {}"),
    6.81 +                                      new JavaSource("CompletionErrorIntfMissing", "public interface CompletionErrorIntfMissing {}"),
    6.82 +                                      new JavaSource("CompletionErrorExcMissing", "public class CompletionErrorExcMissing extends Exception {}"));
    6.83 +                Boolean result = compiler.getTask(null, null, null, Arrays.asList("-d", "."), null, fileObjects).call();
    6.84 +                if (!result)
    6.85 +                    throw new Error();
    6.86 +                for (String delete : new String[] {"CompletionErrorMissing.class", "CompletionErrorIntfMissing.class", "CompletionErrorExcMissing.class"}) {
    6.87 +                    Files.delete(Paths.get(delete));
    6.88 +                }
    6.89 +                // run javadoc:
    6.90 +                if (Main.execute("javadoc", "CompletionError", CompletionError.class.getClassLoader(),
    6.91 +                                 "-classpath", ".",
    6.92 +                                 System.getProperty("test.src", ".") + File.separatorChar + "CompletionError.java") != 0)
    6.93 +                    throw new Error();
    6.94 +            }
    6.95 +        }
    6.96 +    }
    6.97 +
    6.98 +    private static int test;
    6.99 +    private static boolean testsDone;
   6.100 +
   6.101 +    public static boolean start(com.sun.javadoc.RootDoc root) {
   6.102 +        ClassDoc aux = root.classNamed("CompletionErrorAuxiliary");
   6.103 +        if (aux == null)
   6.104 +            throw new AssertionError("Cannot find CompletionErrorAuxiliary");
   6.105 +
   6.106 +        FieldDoc tf = findField(aux, "tf");
   6.107 +        MethodDoc tm = findMethod(aux, "tm");
   6.108 +        MethodDoc cm = findMethod(aux, "toString");
   6.109 +        switch (test) {
   6.110 +            case 0: aux.superclass(); break;
   6.111 +            case 1: aux.superclassType(); break;
   6.112 +            case 2: aux.interfaces(); break;
   6.113 +            case 3: aux.interfaceTypes(); break;
   6.114 +            case 4: if (tf != null) tf.type(); break;
   6.115 +            case 5: if (tm != null) tm.overriddenClass(); break;
   6.116 +            case 6: if (tm != null) tm.overriddenMethod(); break;
   6.117 +            case 7: if (tm != null) tm.overriddenType(); break;
   6.118 +            case 8:
   6.119 +                if (tm != null) {
   6.120 +                    for (Parameter p : tm.parameters()) {
   6.121 +                        p.type();
   6.122 +                    }
   6.123 +                }
   6.124 +                break;
   6.125 +            case 9: if (tm != null) tm.receiverType(); break;
   6.126 +            case 10: if (tm != null) tm.returnType(); break;
   6.127 +            case 11: if (tm != null) tm.thrownExceptionTypes(); break;
   6.128 +            case 12: if (tm != null) tm.thrownExceptions(); break;
   6.129 +            case 13:
   6.130 +                if (tm != null) {
   6.131 +                    for (TypeVariable tv : tm.typeParameters()) {
   6.132 +                        tv.bounds();
   6.133 +                    }
   6.134 +                }
   6.135 +                break;
   6.136 +            case 14: if (cm != null) cm.overriddenClass(); break;
   6.137 +            case 15: if (cm != null) cm.overriddenMethod(); break;
   6.138 +            case 16: if (cm != null) cm.overriddenType(); testsDone = true; break;
   6.139 +            default:
   6.140 +                throw new IllegalStateException("Unrecognized test!");
   6.141 +        }
   6.142 +        test++;
   6.143 +        return true;
   6.144 +    }
   6.145 +
   6.146 +    private static MethodDoc findMethod(ClassDoc cd, String name) {
   6.147 +        for (MethodDoc m : cd.methods()) {
   6.148 +            if (name.equals(m.name()))
   6.149 +                return m;
   6.150 +        }
   6.151 +
   6.152 +        return null;
   6.153 +    }
   6.154 +
   6.155 +    private static FieldDoc findField(ClassDoc cd, String name) {
   6.156 +        for (FieldDoc m : cd.fields()) {
   6.157 +            if (name.equals(m.name()))
   6.158 +                return m;
   6.159 +        }
   6.160 +
   6.161 +        return null;
   6.162 +    }
   6.163 +
   6.164 +    static class JavaSource extends SimpleJavaFileObject {
   6.165 +        final String source;
   6.166 +
   6.167 +        public JavaSource(String name, String source) {
   6.168 +            super(URI.create("myfo:/" + name + ".java"), JavaFileObject.Kind.SOURCE);
   6.169 +            this.source = source;
   6.170 +        }
   6.171 +
   6.172 +        @Override
   6.173 +        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
   6.174 +            return source;
   6.175 +        }
   6.176 +    }
   6.177 +}

mercurial