Skip to content

Commit de35cc9

Browse files
cushonError Prone Team
authored andcommitted
Automated rollback of commit 09c78e0.
*** Reason for rollback *** -Xdoclint is still broken *** Original change description *** Remove an obsolete TODO The javac bug is long fixed. I noticed this debugging b/451598162, but it's unrelated. *** PiperOrigin-RevId: 827977814
1 parent c532950 commit de35cc9

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

core/src/main/java/com/google/errorprone/bugpatterns/javadoc/InvalidLink.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import static com.google.errorprone.bugpatterns.javadoc.Utils.getStartPosition;
2525
import static com.google.errorprone.bugpatterns.javadoc.Utils.replace;
2626
import static com.google.errorprone.matchers.Description.NO_MATCH;
27+
import static com.google.errorprone.util.ErrorProneLog.deferredDiagnosticHandler;
2728

2829
import com.google.common.collect.ImmutableSet;
2930
import com.google.errorprone.BugPattern;
@@ -46,6 +47,7 @@
4647
import com.sun.tools.javac.api.JavacTrees;
4748
import com.sun.tools.javac.tree.DCTree.DCDocComment;
4849
import com.sun.tools.javac.tree.DCTree.DCText;
50+
import com.sun.tools.javac.util.Log;
4951
import java.util.regex.Matcher;
5052
import java.util.regex.Pattern;
5153
import javax.lang.model.element.Element;
@@ -143,9 +145,20 @@ public Void visitLink(LinkTree linkTree, Void unused) {
143145
return super.visitLink(linkTree, null);
144146
}
145147
String reference = linkTree.getReference().getSignature();
146-
Element element =
147-
JavacTrees.instance(state.context)
148-
.getElement(new DocTreePath(getCurrentPath(), linkTree.getReference()));
148+
Element element = null;
149+
Log log = Log.instance(state.context);
150+
// Install a deferred diagnostic handler before calling DocTrees.getElement(DocTreePath)
151+
152+
Log.DeferredDiagnosticHandler deferredDiagnosticHandler = deferredDiagnosticHandler(log);
153+
try {
154+
element =
155+
JavacTrees.instance(state.context)
156+
.getElement(new DocTreePath(getCurrentPath(), linkTree.getReference()));
157+
} catch (NullPointerException | AssertionError e) {
158+
// TODO: cushon - remove if https://bugs.openjdk.org/browse/JDK-8371248 is fixed
159+
} finally {
160+
log.popDiagnosticHandler(deferredDiagnosticHandler);
161+
}
149162
// Don't warn about fully qualified types; they won't always be known at compile-time.
150163
if (element != null || reference.contains(".")) {
151164
return super.visitLink(linkTree, null);

0 commit comments

Comments
 (0)