mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-15 16:44:36 +02:00
8214571: -Xdoclint of array serialField gives "error: array type not allowed here"
Reviewed-by: jjg, sundar
This commit is contained in:
parent
d4acf96543
commit
c0099a8a0d
7 changed files with 39 additions and 32 deletions
|
@ -884,8 +884,6 @@ public class Checker extends DocTreePathScanner<Void, Void> {
|
||||||
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)) {
|
|
||||||
env.messages.error(REFERENCE, tree, "dc.array.type.not.allowed");
|
|
||||||
} else {
|
} else {
|
||||||
Element e = env.trees.getElement(getCurrentPath());
|
Element e = env.trees.getElement(getCurrentPath());
|
||||||
if (e == null)
|
if (e == null)
|
||||||
|
@ -975,12 +973,6 @@ 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,7 +25,6 @@
|
||||||
|
|
||||||
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,11 +443,7 @@ 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();
|
||||||
|
@ -478,7 +474,11 @@ public class JavacTrees extends DocTrees {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tsym = t.tsym;
|
Type e = t;
|
||||||
|
// If this is an array type convert to element type
|
||||||
|
while (e instanceof ArrayType)
|
||||||
|
e = ((ArrayType)e).elemtype;
|
||||||
|
tsym = e.tsym;
|
||||||
memberName = (Name) ref.memberName;
|
memberName = (Name) ref.memberName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class TestSeeTag extends JavadocTester {
|
||||||
checkOutput("badref/Test.html", true,
|
checkOutput("badref/Test.html", true,
|
||||||
"<dl>\n"
|
"<dl>\n"
|
||||||
+ "<dt><span class=\"seeLabel\">See Also:</span></dt>\n"
|
+ "<dt><span class=\"seeLabel\">See Also:</span></dt>\n"
|
||||||
+ "<dd><code>Object[]</code>, \n"
|
+ "<dd><code>Object</code>, \n"
|
||||||
+ "<code>Foo<String></code></dd>\n"
|
+ "<code>Foo<String></code></dd>\n"
|
||||||
+ "</dl>");
|
+ "</dl>");
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,13 +31,15 @@ public class SerializedForm implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @serialField name String a test
|
* @serialField name String a test
|
||||||
|
* @serialField longs Long[] the longs
|
||||||
* @see TestSerializedForm
|
* @see TestSerializedForm
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
private static final ObjectStreamField[] serialPersistentFields = {
|
private static final ObjectStreamField[] serialPersistentFields = {
|
||||||
new ObjectStreamField("i", int.class),
|
new ObjectStreamField("i", int.class),
|
||||||
new ObjectStreamField("count", Integer.TYPE),
|
new ObjectStreamField("count", Integer.TYPE),
|
||||||
new ObjectStreamField("name", String.class)
|
new ObjectStreamField("name", String.class),
|
||||||
|
new ObjectStreamField("longs", Long[].class)
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -84,6 +84,19 @@ public class TestSerializedForm extends JavadocTester {
|
||||||
+ "pkg1.ProtectedInnerClass.ProInnerClass</a> extends java.lang.Object implements Serializable</h3>",
|
+ "pkg1.ProtectedInnerClass.ProInnerClass</a> extends java.lang.Object implements Serializable</h3>",
|
||||||
"<h3>Class pkg1.PublicExcludeInnerClass.PubInnerClass extends java.lang.Object implements "
|
"<h3>Class pkg1.PublicExcludeInnerClass.PubInnerClass extends java.lang.Object implements "
|
||||||
+ "Serializable</h3>");
|
+ "Serializable</h3>");
|
||||||
|
|
||||||
|
checkOutput("serialized-form.html", true,
|
||||||
|
"<h3>Serialized Fields</h3>\n" +
|
||||||
|
"<ul class=\"blockList\">\n" +
|
||||||
|
"<li class=\"blockList\">\n" +
|
||||||
|
"<h4>longs</h4>\n" +
|
||||||
|
"<pre>Long[] longs</pre>\n" +
|
||||||
|
"<div class=\"block\">the longs</div>\n" +
|
||||||
|
"</li>\n" +
|
||||||
|
"<li class=\"blockListLast\">\n" +
|
||||||
|
"<h4>name</h4>\n" +
|
||||||
|
"<pre>java.lang.String name</pre>\n" +
|
||||||
|
"<div class=\"block\">a test</div>");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -113,6 +126,19 @@ public class TestSerializedForm extends JavadocTester {
|
||||||
"<h3>Class <a href=\"pkg1/PublicExcludeInnerClass.PubInnerClass.html\" "
|
"<h3>Class <a href=\"pkg1/PublicExcludeInnerClass.PubInnerClass.html\" "
|
||||||
+ "title=\"class in pkg1\">pkg1.PublicExcludeInnerClass.PubInnerClass</a> "
|
+ "title=\"class in pkg1\">pkg1.PublicExcludeInnerClass.PubInnerClass</a> "
|
||||||
+ "extends java.lang.Object implements Serializable</h3>");
|
+ "extends java.lang.Object implements Serializable</h3>");
|
||||||
|
|
||||||
|
checkOutput("serialized-form.html", true,
|
||||||
|
"<h3>Serialized Fields</h3>\n" +
|
||||||
|
"<ul class=\"blockList\">\n" +
|
||||||
|
"<li class=\"blockList\">\n" +
|
||||||
|
"<h4>longs</h4>\n" +
|
||||||
|
"<pre>Long[] longs</pre>\n" +
|
||||||
|
"<div class=\"block\">the longs</div>\n" +
|
||||||
|
"</li>\n" +
|
||||||
|
"<li class=\"blockListLast\">\n" +
|
||||||
|
"<h4>name</h4>\n" +
|
||||||
|
"<pre>java.lang.String name</pre>\n" +
|
||||||
|
"<div class=\"block\">a test</div>");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -43,24 +43,12 @@ ReferenceTest.java:64: error: type arguments not allowed here
|
||||||
ReferenceTest.java:65: error: type arguments not allowed here
|
ReferenceTest.java:65: error: type arguments not allowed here
|
||||||
* @see not.Found<String>
|
* @see not.Found<String>
|
||||||
^
|
^
|
||||||
ReferenceTest.java:70: error: array type not allowed here
|
ReferenceTest.java:72: error: reference not found
|
||||||
* {@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[]}
|
* {@link not.Found[]}
|
||||||
^
|
^
|
||||||
ReferenceTest.java:73: error: array type not allowed here
|
ReferenceTest.java:75: error: reference not found
|
||||||
* @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[]
|
* @see not.Found[]
|
||||||
^
|
^
|
||||||
20 errors
|
16 errors
|
||||||
1 warning
|
1 warning
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue