8200432: javadoc fails with ClassCastException on {@link byte[]}
Reviewed-by: jjg, sundar
This commit is contained in:
parent
710ecce7f7
commit
c047c5cfcf
@ -882,12 +882,15 @@ public class Checker extends DocTreePathScanner<Void, Void> {
|
|||||||
@Override @DefinedBy(Api.COMPILER_TREE)
|
@Override @DefinedBy(Api.COMPILER_TREE)
|
||||||
public Void visitReference(ReferenceTree tree, Void ignore) {
|
public Void visitReference(ReferenceTree tree, Void ignore) {
|
||||||
String sig = tree.getSignature();
|
String sig = tree.getSignature();
|
||||||
if (sig.contains("<") || sig.contains(">"))
|
if (sig.contains("<") || sig.contains(">")) {
|
||||||
env.messages.error(REFERENCE, tree, "dc.type.arg.not.allowed");
|
env.messages.error(REFERENCE, tree, "dc.type.arg.not.allowed");
|
||||||
|
} else if (isArrayType(sig)) {
|
||||||
Element e = env.trees.getElement(getCurrentPath());
|
env.messages.error(REFERENCE, tree, "dc.array.type.not.allowed");
|
||||||
if (e == null)
|
} else {
|
||||||
env.messages.error(REFERENCE, tree, "dc.ref.not.found");
|
Element e = env.trees.getElement(getCurrentPath());
|
||||||
|
if (e == null)
|
||||||
|
env.messages.error(REFERENCE, tree, "dc.ref.not.found");
|
||||||
|
}
|
||||||
return super.visitReference(tree, ignore);
|
return super.visitReference(tree, ignore);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -972,6 +975,12 @@ public class Checker extends DocTreePathScanner<Void, Void> {
|
|||||||
return scan(tree.getDescription(), ignore);
|
return scan(tree.getDescription(), ignore);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isArrayType(String signature) {
|
||||||
|
int brackets = signature.indexOf('[');
|
||||||
|
int parens = signature.indexOf('(');
|
||||||
|
return brackets >= 0 && (parens < 0 || brackets < parens);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isThrowable(TypeMirror tm) {
|
private boolean isThrowable(TypeMirror tm) {
|
||||||
switch (tm.getKind()) {
|
switch (tm.getKind()) {
|
||||||
case DECLARED:
|
case DECLARED:
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
dc.anchor.already.defined = anchor already defined: "{0}"
|
dc.anchor.already.defined = anchor already defined: "{0}"
|
||||||
dc.anchor.value.missing = no value given for anchor
|
dc.anchor.value.missing = no value given for anchor
|
||||||
|
dc.array.type.not.allowed = array type not allowed here
|
||||||
dc.attr.lacks.value = attribute lacks value
|
dc.attr.lacks.value = attribute lacks value
|
||||||
dc.attr.not.number = attribute value is not a number
|
dc.attr.not.number = attribute value is not a number
|
||||||
dc.attr.not.supported.html4 = attribute not supported in HTML4: {0}
|
dc.attr.not.supported.html4 = attribute not supported in HTML4: {0}
|
||||||
|
@ -443,7 +443,11 @@ public class JavacTrees extends DocTrees {
|
|||||||
// we first check if qualifierExpression identifies a type,
|
// we first check if qualifierExpression identifies a type,
|
||||||
// and if not, then we check to see if it identifies a package.
|
// and if not, then we check to see if it identifies a package.
|
||||||
Type t = attr.attribType(ref.qualifierExpression, env);
|
Type t = attr.attribType(ref.qualifierExpression, env);
|
||||||
if (t.isErroneous()) {
|
|
||||||
|
if (t.getKind() == TypeKind.ARRAY) {
|
||||||
|
// cannot refer to an array type
|
||||||
|
return null;
|
||||||
|
} else if (t.isErroneous()) {
|
||||||
JCCompilationUnit toplevel =
|
JCCompilationUnit toplevel =
|
||||||
treeMaker.TopLevel(List.nil());
|
treeMaker.TopLevel(List.nil());
|
||||||
final ModuleSymbol msym = modules.getDefaultModule();
|
final ModuleSymbol msym = modules.getDefaultModule();
|
||||||
@ -451,6 +455,9 @@ public class JavacTrees extends DocTrees {
|
|||||||
toplevel.packge = msym.unnamedPackage;
|
toplevel.packge = msym.unnamedPackage;
|
||||||
Symbol sym = attr.attribIdent(ref.qualifierExpression, toplevel);
|
Symbol sym = attr.attribIdent(ref.qualifierExpression, toplevel);
|
||||||
|
|
||||||
|
if (sym == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
sym.complete();
|
sym.complete();
|
||||||
|
|
||||||
if ((sym.kind == PCK || sym.kind == TYP) && sym.exists()) {
|
if ((sym.kind == PCK || sym.kind == TYP) && sym.exists()) {
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8017191 8182765
|
* @bug 8017191 8182765 8200432
|
||||||
* @summary Javadoc is confused by at-link to imported classes outside of the set of generated packages
|
* @summary Javadoc is confused by at-link to imported classes outside of the set of generated packages
|
||||||
* @author jjg
|
* @author jjg
|
||||||
* @library ../lib
|
* @library ../lib
|
||||||
@ -83,5 +83,20 @@ public class TestSeeTag extends JavadocTester {
|
|||||||
+ "<a href=\"http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#see\">Javadoc</a>, \n"
|
+ "<a href=\"http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#see\">Javadoc</a>, \n"
|
||||||
+ "<a href=\"Test.InnerOne.html#baz-float-\"><code>something</code></a></dd>\n"
|
+ "<a href=\"Test.InnerOne.html#baz-float-\"><code>something</code></a></dd>\n"
|
||||||
+ "</dl>");
|
+ "</dl>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testBadReference() {
|
||||||
|
javadoc("-d", "out-badref",
|
||||||
|
"-sourcepath", testSrc,
|
||||||
|
"badref");
|
||||||
|
checkExit(Exit.ERROR);
|
||||||
|
|
||||||
|
checkOutput("badref/Test.html", true,
|
||||||
|
"<dl>\n"
|
||||||
|
+ "<dt><span class=\"seeLabel\">See Also:</span></dt>\n"
|
||||||
|
+ "<dd><code>Object[]</code>, \n"
|
||||||
|
+ "<code>Foo<String></code></dd>\n"
|
||||||
|
+ "</dl>");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package badref;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Object[]
|
||||||
|
* @see Foo<String>
|
||||||
|
*/
|
||||||
|
public interface Test {}
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8004832 8020556 8002154
|
* @bug 8004832 8020556 8002154 8200432
|
||||||
* @summary Add new doclint package
|
* @summary Add new doclint package
|
||||||
* @modules jdk.compiler/com.sun.tools.doclint
|
* @modules jdk.compiler/com.sun.tools.doclint
|
||||||
* @build DocLintTester
|
* @build DocLintTester
|
||||||
@ -59,9 +59,21 @@ public class ReferenceTest {
|
|||||||
/**
|
/**
|
||||||
* {@link java.util.List<String>}
|
* {@link java.util.List<String>}
|
||||||
* {@link java.util.List<String>#equals}
|
* {@link java.util.List<String>#equals}
|
||||||
|
* {@link not.Found<String>}
|
||||||
* @see java.util.List<String>
|
* @see java.util.List<String>
|
||||||
* @see java.util.List<String>#equals
|
* @see java.util.List<String>#equals
|
||||||
|
* @see not.Found<String>
|
||||||
*/
|
*/
|
||||||
public void invalid_type_args() { }
|
public void invalid_type_args() { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link java.lang.String[]}
|
||||||
|
* {@link java.lang.String[]#equals}
|
||||||
|
* {@link not.Found[]}
|
||||||
|
* @see java.lang.String[]
|
||||||
|
* @see java.lang.String[]#equals
|
||||||
|
* @see not.Found[]
|
||||||
|
*/
|
||||||
|
public void invalid_array_types() { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,11 +32,35 @@ ReferenceTest.java:61: error: type arguments not allowed here
|
|||||||
* {@link java.util.List<String>#equals}
|
* {@link java.util.List<String>#equals}
|
||||||
^
|
^
|
||||||
ReferenceTest.java:62: error: type arguments not allowed here
|
ReferenceTest.java:62: error: type arguments not allowed here
|
||||||
|
* {@link not.Found<String>}
|
||||||
|
^
|
||||||
|
ReferenceTest.java:63: error: type arguments not allowed here
|
||||||
* @see java.util.List<String>
|
* @see java.util.List<String>
|
||||||
^
|
^
|
||||||
ReferenceTest.java:63: error: type arguments not allowed here
|
ReferenceTest.java:64: error: type arguments not allowed here
|
||||||
* @see java.util.List<String>#equals
|
* @see java.util.List<String>#equals
|
||||||
^
|
^
|
||||||
12 errors
|
ReferenceTest.java:65: error: type arguments not allowed here
|
||||||
|
* @see not.Found<String>
|
||||||
|
^
|
||||||
|
ReferenceTest.java:70: error: array type not allowed here
|
||||||
|
* {@link java.lang.String[]}
|
||||||
|
^
|
||||||
|
ReferenceTest.java:71: error: array type not allowed here
|
||||||
|
* {@link java.lang.String[]#equals}
|
||||||
|
^
|
||||||
|
ReferenceTest.java:72: error: array type not allowed here
|
||||||
|
* {@link not.Found[]}
|
||||||
|
^
|
||||||
|
ReferenceTest.java:73: error: array type not allowed here
|
||||||
|
* @see java.lang.String[]
|
||||||
|
^
|
||||||
|
ReferenceTest.java:74: error: array type not allowed here
|
||||||
|
* @see java.lang.String[]#equals
|
||||||
|
^
|
||||||
|
ReferenceTest.java:75: error: array type not allowed here
|
||||||
|
* @see not.Found[]
|
||||||
|
^
|
||||||
|
20 errors
|
||||||
1 warning
|
1 warning
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user