8370237: AssertionError in Annotate.fromAnnotations with -Xdoclint and type annotations

Reviewed-by: jlahoda
This commit is contained in:
Liam Miller-Cushon 2025-10-31 09:52:02 +00:00
parent 4ca88aa2e8
commit 8e3620a344
4 changed files with 33 additions and 5 deletions

View File

@ -211,6 +211,11 @@ public class ReferenceParser {
if (p.token().kind != TokenKind.EOF) {
throw new ParseException(beginIndex + p.token().pos, "dc.ref.unexpected.input");
}
Tree typeAnno = new TypeAnnotationFinder().scan(tree, null);
if (typeAnno != null) {
int annoPos = ((JCTree) typeAnno).getStartPosition();
throw new ParseException(beginIndex + annoPos, "dc.ref.annotations.not.allowed");
}
checkDiags(dh, beginIndex);
return tree;
} finally {

View File

@ -1,7 +1,7 @@
CrashInAnnotateTest.java:10:20: compiler.err.proc.messager: annotations not allowed
CrashInAnnotateTest.java:11:37: compiler.err.proc.messager: syntax error in reference
CrashInAnnotateTest.java:11:12: compiler.err.proc.messager: annotations not allowed
CrashInAnnotateTest.java:16:39: compiler.err.proc.messager: annotations not allowed
CrashInAnnotateTest.java:21:23: compiler.err.proc.messager: syntax error in reference
CrashInAnnotateTest.java:24:54: compiler.err.proc.messager: syntax error in reference
CrashInAnnotateTest.java:25:37: compiler.err.proc.messager: syntax error in reference
6 errors
CrashInAnnotateTest.java:21:12: compiler.err.proc.messager: annotations not allowed
CrashInAnnotateTest.java:24:12: compiler.err.proc.messager: annotations not allowed
CrashInAnnotateTest.java:25:12: compiler.err.proc.messager: annotations not allowed
6 errors

View File

@ -0,0 +1,21 @@
/*
* @test /nodynamiccopyright/
* @bug 8370237
* @summary AssertionError in Annotate.fromAnnotations with -Xdoclint and type annotations
* @compile/fail/ref=CrashInTypeAnnotateTest.out -Xdoclint:all,-missing -XDrawDiagnostics CrashInTypeAnnotateTest.java
*/
import java.util.List;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE_PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
@interface A {}
/** {@link List<@A String>}
*/
class CrashInTypeAnnotateTest {
}

View File

@ -0,0 +1,2 @@
CrashInTypeAnnotateTest.java:18:17: compiler.err.proc.messager: annotations not allowed
1 error