# HG changeset patch # User jlahoda # Date 1452807370 0 # Node ID 3c71abf7435352aee6e74ba2581274181ad3d17e # Parent 057733ea4f82da703a94e76e8c686a99f756e994 8135307: CompletionFailure thrown when calling FieldDoc.type, if the field's type is missing Summary: Handling CompletionFailures inside the Javadoc API implementation. Reviewed-by: mcimadamore, ksrini, jjg diff -r 057733ea4f82 -r 3c71abf74353 src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java --- a/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Fri Nov 13 02:43:43 2015 +0000 +++ b/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Thu Jan 14 21:36:10 2016 +0000 @@ -120,12 +120,14 @@ * Returns the flags of a ClassSymbol in terms of javac's flags */ static long getFlags(ClassSymbol clazz) { - while (true) { - try { - return clazz.flags(); - } catch (CompletionFailure ex) { - // quietly ignore completion failures - } + try { + return clazz.flags(); + } catch (CompletionFailure ex) { + /* Quietly ignore completion failures and try again - the type + * for which the CompletionFailure was thrown shouldn't be completed + * again by the completer that threw the CompletionFailure. + */ + return getFlags(clazz); } } diff -r 057733ea4f82 -r 3c71abf74353 src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java --- a/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java Fri Nov 13 02:43:43 2015 +0000 +++ b/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java Thu Jan 14 21:36:10 2016 +0000 @@ -128,7 +128,7 @@ t.tag == TypeTags.CLASS; t = env.types.supertype(t)) { ClassSymbol c = (ClassSymbol)t.tsym; - for (Scope.Entry e = c.members().lookup(sym.name); e.scope != null; e = e.next()) { + for (Scope.Entry e = membersOf(c).lookup(sym.name); e.scope != null; e = e.next()) { if (sym.overrides(e.sym, origin, env.types, true)) { return TypeMaker.getType(env, t); } @@ -160,7 +160,7 @@ t.tag == TypeTags.CLASS; t = env.types.supertype(t)) { ClassSymbol c = (ClassSymbol)t.tsym; - for (Scope.Entry e = c.members().lookup(sym.name); e.scope != null; e = e.next()) { + for (Scope.Entry e = membersOf(c).lookup(sym.name); e.scope != null; e = e.next()) { if (sym.overrides(e.sym, origin, env.types, true)) { return env.getMethodDoc((MethodSymbol)e.sym); } @@ -169,6 +169,19 @@ return null; } + /**Retrieve members of c, ignoring any CompletionFailures that occur. */ + private Scope membersOf(ClassSymbol c) { + try { + return c.members(); + } catch (CompletionFailure cf) { + /* Quietly ignore completion failures and try again - the type + * for which the CompletionFailure was thrown shouldn't be completed + * again by the completer that threw the CompletionFailure. + */ + return membersOf(c); + } + } + /** * Tests whether this method overrides another. * The overridden method may be one declared in a superclass or diff -r 057733ea4f82 -r 3c71abf74353 src/share/classes/com/sun/tools/javadoc/TypeMaker.java --- a/src/share/classes/com/sun/tools/javadoc/TypeMaker.java Fri Nov 13 02:43:43 2015 +0000 +++ b/src/share/classes/com/sun/tools/javadoc/TypeMaker.java Thu Jan 14 21:36:10 2016 +0000 @@ -29,6 +29,7 @@ import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Symbol.ClassSymbol; +import com.sun.tools.javac.code.Symbol.CompletionFailure; import com.sun.tools.javac.code.Type; import com.sun.tools.javac.code.Type.ClassType; import com.sun.tools.javac.code.Type.TypeVar; @@ -44,12 +45,25 @@ return getType(env, t, true); } + public static com.sun.javadoc.Type getType(DocEnv env, Type t, + boolean errToClassDoc) { + try { + return getTypeImpl(env, t, errToClassDoc); + } catch (CompletionFailure cf) { + /* Quietly ignore completion failures and try again - the type + * for which the CompletionFailure was thrown shouldn't be completed + * again by the completer that threw the CompletionFailure. + */ + return getType(env, t, errToClassDoc); + } + } + /** * @param errToClassDoc if true, ERROR type results in a ClassDoc; * false preserves legacy behavior */ @SuppressWarnings("fallthrough") - public static com.sun.javadoc.Type getType(DocEnv env, Type t, + private static com.sun.javadoc.Type getTypeImpl(DocEnv env, Type t, boolean errToClassDoc) { if (env.legacyDoclet) { t = env.types.erasure(t);