Wed, 14 Oct 2015 12:35:59 -0700
Merge
.hgtags | file | annotate | diff | comparison | revisions |
1.1 --- a/.hgtags Mon Oct 12 12:39:04 2015 -0700 1.2 +++ b/.hgtags Wed Oct 14 12:35:59 2015 -0700 1.3 @@ -480,6 +480,7 @@ 1.4 ec4fa681ae411edc666a60ca5470a56c5cf0fa81 jdk8u65-b14 1.5 02e92f7edc325dc1d17141477ee851a1cc7e71d8 jdk8u65-b15 1.6 20703c32d5ae5d53ecb40bcef79ae933558411aa jdk8u65-b16 1.7 +d038f63e516730c240b5ee0559fc7b09c22393c4 jdk8u65-b17 1.8 d1febf79ce5ea41fb4b818ffd3589cf923e6de5f jdk8u66-b00 1.9 4c13b9cd06222be73b9c44607ae929b4818aed17 jdk8u66-b01 1.10 ec4e102b4bd02b08336e172047e70971a3ed7489 jdk8u66-b02 1.11 @@ -493,6 +494,8 @@ 1.12 70489ab07527a3ef65e2a30f23b164220466775a jdk8u66-b14 1.13 8063e4ac4caabe1756f8393859ab56da3bb29122 jdk8u66-b15 1.14 01e7f91d993b341986f574d0eb3fbfe3d7cae68e jdk8u66-b16 1.15 +ad3f528335b4c609eee7227d150c9a0a39b1dd73 jdk8u66-b17 1.16 +f55af75598d85f45f779f3e632152a067fb7efbc jdk8u66-b31 1.17 aaad025819b721f7f291048a07cd1c144319b68d jdk8u71-b00 1.18 fb2756fb330047dbbff0fa89b79e1d8d96146868 jdk8u71-b01 1.19 21306b94f23ef63cc3ac48a509d491187dadb0f6 jdk8u71-b02
2.1 --- a/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Mon Oct 12 12:39:04 2015 -0700 2.2 +++ b/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Wed Oct 14 12:35:59 2015 -0700 2.3 @@ -124,19 +124,14 @@ 2.4 * Returns the flags of a ClassSymbol in terms of javac's flags 2.5 */ 2.6 static long getFlags(ClassSymbol clazz) { 2.7 - while (true) { 2.8 - try { 2.9 - return clazz.flags(); 2.10 - } catch (CompletionFailure ex) { 2.11 - /* Quietly ignore completion failures. 2.12 - * Note that a CompletionFailure can only 2.13 - * occur as a result of calling complete(), 2.14 - * which will always remove the current 2.15 - * completer, leaving it to be null or 2.16 - * follow-up completer. Thus the loop 2.17 - * is guaranteed to eventually terminate. 2.18 - */ 2.19 - } 2.20 + try { 2.21 + return clazz.flags(); 2.22 + } catch (CompletionFailure ex) { 2.23 + /* Quietly ignore completion failures and try again - the type 2.24 + * for which the CompletionFailure was thrown shouldn't be completed 2.25 + * again by the completer that threw the CompletionFailure. 2.26 + */ 2.27 + return getFlags(clazz); 2.28 } 2.29 } 2.30
3.1 --- a/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java Mon Oct 12 12:39:04 2015 -0700 3.2 +++ b/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java Wed Oct 14 12:35:59 2015 -0700 3.3 @@ -128,7 +128,7 @@ 3.4 t.hasTag(CLASS); 3.5 t = env.types.supertype(t)) { 3.6 ClassSymbol c = (ClassSymbol)t.tsym; 3.7 - for (Scope.Entry e = c.members().lookup(sym.name); e.scope != null; e = e.next()) { 3.8 + for (Scope.Entry e = membersOf(c).lookup(sym.name); e.scope != null; e = e.next()) { 3.9 if (sym.overrides(e.sym, origin, env.types, true)) { 3.10 return TypeMaker.getType(env, t); 3.11 } 3.12 @@ -160,7 +160,7 @@ 3.13 t.hasTag(CLASS); 3.14 t = env.types.supertype(t)) { 3.15 ClassSymbol c = (ClassSymbol)t.tsym; 3.16 - for (Scope.Entry e = c.members().lookup(sym.name); e.scope != null; e = e.next()) { 3.17 + for (Scope.Entry e = membersOf(c).lookup(sym.name); e.scope != null; e = e.next()) { 3.18 if (sym.overrides(e.sym, origin, env.types, true)) { 3.19 return env.getMethodDoc((MethodSymbol)e.sym); 3.20 } 3.21 @@ -169,6 +169,19 @@ 3.22 return null; 3.23 } 3.24 3.25 + /**Retrieve members of c, ignoring any CompletionFailures that occur. */ 3.26 + private Scope membersOf(ClassSymbol c) { 3.27 + try { 3.28 + return c.members(); 3.29 + } catch (CompletionFailure cf) { 3.30 + /* Quietly ignore completion failures and try again - the type 3.31 + * for which the CompletionFailure was thrown shouldn't be completed 3.32 + * again by the completer that threw the CompletionFailure. 3.33 + */ 3.34 + return membersOf(c); 3.35 + } 3.36 + } 3.37 + 3.38 /** 3.39 * Tests whether this method overrides another. 3.40 * The overridden method may be one declared in a superclass or
4.1 --- a/src/share/classes/com/sun/tools/javadoc/TypeMaker.java Mon Oct 12 12:39:04 2015 -0700 4.2 +++ b/src/share/classes/com/sun/tools/javadoc/TypeMaker.java Wed Oct 14 12:35:59 2015 -0700 4.3 @@ -28,6 +28,7 @@ 4.4 import com.sun.javadoc.*; 4.5 import com.sun.tools.javac.code.Symbol; 4.6 import com.sun.tools.javac.code.Symbol.ClassSymbol; 4.7 +import com.sun.tools.javac.code.Symbol.CompletionFailure; 4.8 import com.sun.tools.javac.code.Type; 4.9 import com.sun.tools.javac.code.Type.ArrayType; 4.10 import com.sun.tools.javac.code.Type.ClassType; 4.11 @@ -56,8 +57,21 @@ 4.12 return getType(env, t, errorToClassDoc, true); 4.13 } 4.14 4.15 + public static com.sun.javadoc.Type getType(DocEnv env, Type t, 4.16 + boolean errToClassDoc, boolean considerAnnotations) { 4.17 + try { 4.18 + return getTypeImpl(env, t, errToClassDoc, considerAnnotations); 4.19 + } catch (CompletionFailure cf) { 4.20 + /* Quietly ignore completion failures and try again - the type 4.21 + * for which the CompletionFailure was thrown shouldn't be completed 4.22 + * again by the completer that threw the CompletionFailure. 4.23 + */ 4.24 + return getType(env, t, errToClassDoc, considerAnnotations); 4.25 + } 4.26 + } 4.27 + 4.28 @SuppressWarnings("fallthrough") 4.29 - public static com.sun.javadoc.Type getType(DocEnv env, Type t, 4.30 + private static com.sun.javadoc.Type getTypeImpl(DocEnv env, Type t, 4.31 boolean errToClassDoc, boolean considerAnnotations) { 4.32 if (env.legacyDoclet) { 4.33 t = env.types.erasure(t);
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/test/tools/javadoc/CompletionError.java Wed Oct 14 12:35:59 2015 -0700 5.3 @@ -0,0 +1,174 @@ 5.4 +/* 5.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 5.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.7 + * 5.8 + * This code is free software; you can redistribute it and/or modify it 5.9 + * under the terms of the GNU General Public License version 2 only, as 5.10 + * published by the Free Software Foundation. 5.11 + * 5.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 5.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 5.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 5.15 + * version 2 for more details (a copy is included in the LICENSE file that 5.16 + * accompanied this code). 5.17 + * 5.18 + * You should have received a copy of the GNU General Public License version 5.19 + * 2 along with this work; if not, write to the Free Software Foundation, 5.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 5.21 + * 5.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 5.23 + * or visit www.oracle.com if you need additional information or have any 5.24 + * questions. 5.25 + */ 5.26 + 5.27 +/* 5.28 + * @test 5.29 + * @bug 8135307 5.30 + * @summary Check that CompletionFailures for missing classes are not incorrectly passed to 5.31 + * the javadoc API clients. 5.32 + * @modules jdk.javadoc 5.33 + * @run main CompletionError 5.34 + */ 5.35 + 5.36 +import java.io.File; 5.37 +import java.net.URI; 5.38 +import java.nio.file.Files; 5.39 +import java.nio.file.Paths; 5.40 +import java.util.Arrays; 5.41 +import java.util.List; 5.42 + 5.43 +import javax.tools.JavaCompiler; 5.44 +import javax.tools.JavaFileObject; 5.45 +import javax.tools.SimpleJavaFileObject; 5.46 +import javax.tools.ToolProvider; 5.47 + 5.48 +import com.sun.javadoc.*; 5.49 +import com.sun.tools.javadoc.Main; 5.50 + 5.51 +public class CompletionError extends Doclet 5.52 +{ 5.53 + private static final String template = 5.54 + "public class CompletionErrorAuxiliary #extends CompletionErrorMissing# #implements CompletionErrorIntfMissing# {" + 5.55 + " #public CompletionErrorMissing tf;#" + 5.56 + " #public CompletionErrorMissing tm() { return null; }#" + 5.57 + " #public void tm(CompletionErrorMissing m) {}#" + 5.58 + " #public void tm() throws CompletionErrorExcMissing {}#" + 5.59 + " #public <T extends CompletionErrorMissing> void tm() {}#" + 5.60 + " public String toString() { return null; }" + 5.61 + "}"; 5.62 + 5.63 + public static void main(String[] args) throws Exception { 5.64 + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); 5.65 + String[] templateParts = template.split("#"); 5.66 + int sources = templateParts.length / 2; 5.67 + for (int source = 0; source < sources; source++) { 5.68 + StringBuilder testSource = new StringBuilder(); 5.69 + for (int i = 0; i < templateParts.length; i += 2) { 5.70 + testSource.append(templateParts[i]); 5.71 + if (i == 2 * source) { 5.72 + testSource.append(templateParts[i + 1]); 5.73 + } 5.74 + } 5.75 + test = 0; 5.76 + testsDone = false; 5.77 + while (!testsDone) { 5.78 + List<JavaSource> fileObjects = 5.79 + Arrays.asList(new JavaSource("CompletionErrorAuxiliary", testSource.toString()), 5.80 + new JavaSource("CompletionErrorMissing", "public class CompletionErrorMissing {}"), 5.81 + new JavaSource("CompletionErrorIntfMissing", "public interface CompletionErrorIntfMissing {}"), 5.82 + new JavaSource("CompletionErrorExcMissing", "public class CompletionErrorExcMissing extends Exception {}")); 5.83 + Boolean result = compiler.getTask(null, null, null, Arrays.asList("-d", "."), null, fileObjects).call(); 5.84 + if (!result) 5.85 + throw new Error(); 5.86 + for (String delete : new String[] {"CompletionErrorMissing.class", "CompletionErrorIntfMissing.class", "CompletionErrorExcMissing.class"}) { 5.87 + Files.delete(Paths.get(delete)); 5.88 + } 5.89 + // run javadoc: 5.90 + if (Main.execute("javadoc", "CompletionError", CompletionError.class.getClassLoader(), 5.91 + "-classpath", ".", 5.92 + System.getProperty("test.src", ".") + File.separatorChar + "CompletionError.java") != 0) 5.93 + throw new Error(); 5.94 + } 5.95 + } 5.96 + } 5.97 + 5.98 + private static int test; 5.99 + private static boolean testsDone; 5.100 + 5.101 + public static boolean start(com.sun.javadoc.RootDoc root) { 5.102 + ClassDoc aux = root.classNamed("CompletionErrorAuxiliary"); 5.103 + if (aux == null) 5.104 + throw new AssertionError("Cannot find CompletionErrorAuxiliary"); 5.105 + 5.106 + FieldDoc tf = findField(aux, "tf"); 5.107 + MethodDoc tm = findMethod(aux, "tm"); 5.108 + MethodDoc cm = findMethod(aux, "toString"); 5.109 + switch (test) { 5.110 + case 0: aux.superclass(); break; 5.111 + case 1: aux.superclassType(); break; 5.112 + case 2: aux.interfaces(); break; 5.113 + case 3: aux.interfaceTypes(); break; 5.114 + case 4: if (tf != null) tf.type(); break; 5.115 + case 5: if (tm != null) tm.overriddenClass(); break; 5.116 + case 6: if (tm != null) tm.overriddenMethod(); break; 5.117 + case 7: if (tm != null) tm.overriddenType(); break; 5.118 + case 8: 5.119 + if (tm != null) { 5.120 + for (Parameter p : tm.parameters()) { 5.121 + p.type(); 5.122 + } 5.123 + } 5.124 + break; 5.125 + case 9: if (tm != null) tm.receiverType(); break; 5.126 + case 10: if (tm != null) tm.returnType(); break; 5.127 + case 11: if (tm != null) tm.thrownExceptionTypes(); break; 5.128 + case 12: if (tm != null) tm.thrownExceptions(); break; 5.129 + case 13: 5.130 + if (tm != null) { 5.131 + for (TypeVariable tv : tm.typeParameters()) { 5.132 + tv.bounds(); 5.133 + } 5.134 + } 5.135 + break; 5.136 + case 14: if (cm != null) cm.overriddenClass(); break; 5.137 + case 15: if (cm != null) cm.overriddenMethod(); break; 5.138 + case 16: if (cm != null) cm.overriddenType(); testsDone = true; break; 5.139 + default: 5.140 + throw new IllegalStateException("Unrecognized test!"); 5.141 + } 5.142 + test++; 5.143 + return true; 5.144 + } 5.145 + 5.146 + private static MethodDoc findMethod(ClassDoc cd, String name) { 5.147 + for (MethodDoc m : cd.methods()) { 5.148 + if (name.equals(m.name())) 5.149 + return m; 5.150 + } 5.151 + 5.152 + return null; 5.153 + } 5.154 + 5.155 + private static FieldDoc findField(ClassDoc cd, String name) { 5.156 + for (FieldDoc m : cd.fields()) { 5.157 + if (name.equals(m.name())) 5.158 + return m; 5.159 + } 5.160 + 5.161 + return null; 5.162 + } 5.163 + 5.164 + static class JavaSource extends SimpleJavaFileObject { 5.165 + final String source; 5.166 + 5.167 + public JavaSource(String name, String source) { 5.168 + super(URI.create("myfo:/" + name + ".java"), JavaFileObject.Kind.SOURCE); 5.169 + this.source = source; 5.170 + } 5.171 + 5.172 + @Override 5.173 + public CharSequence getCharContent(boolean ignoreEncodingErrors) { 5.174 + return source; 5.175 + } 5.176 + } 5.177 +}