Skip to content

Commit 5d3e73b

Browse files
committed
8371248: Crash in -Xdoclint with invalid @link
Reviewed-by: hannesw, vromero
1 parent 473471c commit 5d3e73b

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,10 @@ private Symbol attributeDocReference(TreePath path, DCReference ref) {
473473
if (memberName == null)
474474
return tsym;
475475

476+
if (tsym.type.isPrimitive()) {
477+
return null;
478+
}
479+
476480
final List<Type> paramTypes;
477481
if (ref.paramTypes == null)
478482
paramTypes = null;

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ private class IdentAttributer extends SimpleTreeVisitor<Symbol,Env<AttrContext>>
377377
@Override @DefinedBy(Api.COMPILER_TREE)
378378
public Symbol visitMemberSelect(MemberSelectTree node, Env<AttrContext> env) {
379379
Symbol site = visit(node.getExpression(), env);
380-
if (site.kind == ERR || site.kind == ABSENT_TYP || site.kind == HIDDEN)
380+
if (site == null || site.kind == ERR || site.kind == ABSENT_TYP || site.kind == HIDDEN)
381381
return site;
382382
Name name = (Name)node.getIdentifier();
383383
if (site.kind == PCK) {

test/langtools/tools/javac/doctree/ReferenceTest.java

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
2323

2424
/*
2525
* @test
26-
* @bug 7021614 8278373 8164094
26+
* @bug 7021614 8278373 8164094 8371248
2727
* @summary extend com.sun.source API to support parsing javadoc comments
2828
* @summary check references in at-see and {at-link} tags
2929
* @modules jdk.compiler
@@ -43,6 +43,7 @@
4343
import com.sun.source.util.TreePath;
4444

4545
import java.util.List;
46+
import java.util.Map;
4647
import java.util.Set;
4748
import java.util.stream.Collectors;
4849
import javax.annotation.processing.AbstractProcessor;
@@ -83,6 +84,31 @@
8384
* {@link #trees Field}
8485
* {@link #getSupportedSourceVersion Method}
8586
* {@link #init(ProcessingEnvironment Method}
87+
* {@link double Class}
88+
* {@link double.NAN Bad}
89+
* {@link double#NAN Bad}
90+
* {@link double#double Bad}
91+
* {@link java.base/double Bad}
92+
*
93+
* {@link List<String> Interface}
94+
* {@link List<String>.add Bad}
95+
* {@link List<String>#add Method}
96+
* {@link List<String>#add(Object) Method}
97+
* {@link Map<String, String>.Entry Interface}
98+
* {@link Map<String, String>.Entry<String, String> Interface}
99+
* {@link Map<String, String>.Entry<String, String>.getKey Bad}
100+
* {@link Map<String, String>.Entry<String, String>#getKey Method}
101+
* {@link Map<String, String>.Entry<String, String>#setValue(Object) Method}
102+
*
103+
* {@link java.base/java.util.List<String> Bad}
104+
* {@link java.base/java.util.List<String>.add Bad}
105+
* {@link java.base/java.util.List<String>#add Bad}
106+
* {@link java.base/java.util.List<String>#add(Object) Bad}
107+
* {@link java.base/java.util.Map<String, String>.Entry Bad}
108+
* {@link java.base/java.util.Map<String, String>.Entry<String, String> Bad}
109+
* {@link java.base/java.util.Map<String, String>.Entry<String, String>.getKey Bad}
110+
* {@link java.base/java.util.Map<String, String>.Entry<String, String>#getKey Bad}
111+
* {@link java.base/java.util.Map<String, String>.Entry<String, String>#setValue(Object) Bad}
86112
*
87113
* @see java.lang Package
88114
* @see java.lang.ERROR Bad

0 commit comments

Comments
 (0)