Skip to content

Commit 8e3620a

Browse files
committed
8370237: AssertionError in Annotate.fromAnnotations with -Xdoclint and type annotations
Reviewed-by: jlahoda
1 parent 4ca88aa commit 8e3620a

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

src/jdk.compiler/share/classes/com/sun/tools/javac/parser/ReferenceParser.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@ private JCTree parseType(String sig, int beginIndex, int endIndex, Log.DeferredD
211211
if (p.token().kind != TokenKind.EOF) {
212212
throw new ParseException(beginIndex + p.token().pos, "dc.ref.unexpected.input");
213213
}
214+
Tree typeAnno = new TypeAnnotationFinder().scan(tree, null);
215+
if (typeAnno != null) {
216+
int annoPos = ((JCTree) typeAnno).getStartPosition();
217+
throw new ParseException(beginIndex + annoPos, "dc.ref.annotations.not.allowed");
218+
}
214219
checkDiags(dh, beginIndex);
215220
return tree;
216221
} finally {
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CrashInAnnotateTest.java:10:20: compiler.err.proc.messager: annotations not allowed
2-
CrashInAnnotateTest.java:11:37: compiler.err.proc.messager: syntax error in reference
2+
CrashInAnnotateTest.java:11:12: compiler.err.proc.messager: annotations not allowed
33
CrashInAnnotateTest.java:16:39: compiler.err.proc.messager: annotations not allowed
4-
CrashInAnnotateTest.java:21:23: compiler.err.proc.messager: syntax error in reference
5-
CrashInAnnotateTest.java:24:54: compiler.err.proc.messager: syntax error in reference
6-
CrashInAnnotateTest.java:25:37: compiler.err.proc.messager: syntax error in reference
7-
6 errors
4+
CrashInAnnotateTest.java:21:12: compiler.err.proc.messager: annotations not allowed
5+
CrashInAnnotateTest.java:24:12: compiler.err.proc.messager: annotations not allowed
6+
CrashInAnnotateTest.java:25:12: compiler.err.proc.messager: annotations not allowed
7+
6 errors
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* @test /nodynamiccopyright/
3+
* @bug 8370237
4+
* @summary AssertionError in Annotate.fromAnnotations with -Xdoclint and type annotations
5+
* @compile/fail/ref=CrashInTypeAnnotateTest.out -Xdoclint:all,-missing -XDrawDiagnostics CrashInTypeAnnotateTest.java
6+
*/
7+
8+
import java.util.List;
9+
import java.lang.annotation.ElementType;
10+
import java.lang.annotation.Retention;
11+
import java.lang.annotation.RetentionPolicy;
12+
import java.lang.annotation.Target;
13+
14+
@Target(ElementType.TYPE_PARAMETER)
15+
@Retention(RetentionPolicy.RUNTIME)
16+
@interface A {}
17+
18+
/** {@link List<@A String>}
19+
*/
20+
class CrashInTypeAnnotateTest {
21+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CrashInTypeAnnotateTest.java:18:17: compiler.err.proc.messager: annotations not allowed
2+
1 error

0 commit comments

Comments
 (0)