8342934: TYPE_USE annotations printed with error causing "," in toString output

Reviewed-by: iris, vromero
This commit is contained in:
Joe Darcy 2024-10-25 16:49:11 +00:00
parent 0853aee3b3
commit ff165f9f0c
3 changed files with 8 additions and 4 deletions
src/jdk.compiler/share/classes/com/sun/tools/javac/code
test/langtools/tools/javac/processing/model/type/AnnotatedTypeToString

@ -500,7 +500,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror, PoolCons
if (prefix) {
sb.append(" ");
}
sb.append(getAnnotationMirrors());
sb.append(getAnnotationMirrors().toString(" "));
sb.append(" ");
}
}

@ -23,7 +23,7 @@
/*
* @test
* @bug 8284220
* @bug 8284220 8342934
* @summary Tests DeclaredType.toString with type annotations present, for example that '@A
* Map.Entry' is printed as 'java.util.@A Map.Entry' (and not '@A java.util.Map.Entry' or
* 'java.util.@A Entry').

@ -32,6 +32,10 @@ import java.lang.annotation.Target;
@Target(ElementType.TYPE_USE)
@interface A {}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE_USE)
@interface B {}
public class Test {
static class StaticNested {
static class InnerMostStaticNested {}
@ -41,8 +45,8 @@ public class Test {
class InnerMost {}
}
@ExpectedToString("p.Test.@p.A StaticNested")
@A StaticNested i;
@ExpectedToString("p.Test.@p.A @p.B StaticNested")
@A @B StaticNested i;
@ExpectedToString("p.Test.StaticNested.@p.A InnerMostStaticNested")
StaticNested.@A InnerMostStaticNested j;