# HG changeset patch # User jlahoda # Date 1453229972 0 # Node ID 16ee64960115d95a63243ee6da5b97e42742ca34 # Parent 3e734990164583924a394e95821a11bdd621b9fd 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 3e7349901645 -r 16ee64960115 src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java --- a/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Fri Nov 13 01:28:35 2015 +0000 +++ b/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Tue Jan 19 18:59:32 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 3e7349901645 -r 16ee64960115 src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java --- a/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java Fri Nov 13 01:28:35 2015 +0000 +++ b/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java Tue Jan 19 18:59:32 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 3e7349901645 -r 16ee64960115 src/share/classes/com/sun/tools/javadoc/TypeMaker.java --- a/src/share/classes/com/sun/tools/javadoc/TypeMaker.java Fri Nov 13 01:28:35 2015 +0000 +++ b/src/share/classes/com/sun/tools/javadoc/TypeMaker.java Tue Jan 19 18:59:32 2016 +0000 @@ -31,6 +31,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; @@ -47,11 +48,24 @@ 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 */ - 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);