8281238: TYPE_USE annotations not printed in correct position in toString output
Reviewed-by: vromero
This commit is contained in:
parent
83ffbd2e7a
commit
4032fe76dc
@ -1038,8 +1038,16 @@ public abstract class Type extends AnnoConstruct implements TypeMirror, PoolCons
|
||||
appendAnnotationsString(buf);
|
||||
buf.append(className(tsym, false));
|
||||
} else {
|
||||
appendAnnotationsString(buf);
|
||||
buf.append(className(tsym, true));
|
||||
if (isAnnotated()) {
|
||||
if (!tsym.packge().isUnnamed()) {
|
||||
buf.append(tsym.packge());
|
||||
buf.append(".");
|
||||
}
|
||||
appendAnnotationsString(buf);
|
||||
buf.append(tsym.name);
|
||||
} else {
|
||||
buf.append(className(tsym, true));
|
||||
}
|
||||
}
|
||||
|
||||
if (getTypeArguments().nonEmpty()) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2022, 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
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8256266
|
||||
* @bug 8256266 8281238
|
||||
* @summary Verify annotations work correctly on binding variables
|
||||
* @library /tools/javac/lib
|
||||
* @modules java.compiler
|
||||
@ -114,11 +114,11 @@ public class Annotations extends JavacTestingAbstractProcessor {
|
||||
}
|
||||
case "dta" -> {
|
||||
expectedDeclAnnos = "@Annotations.DTA";
|
||||
expectedType = "@Annotations.DTA java.lang.String";
|
||||
expectedType = "java.lang.@Annotations.DTA String";
|
||||
}
|
||||
case "ta" -> {
|
||||
expectedDeclAnnos = "";
|
||||
expectedType = "@Annotations.TA java.lang.String";
|
||||
expectedType = "java.lang.@Annotations.TA String";
|
||||
}
|
||||
default -> {
|
||||
throw new AssertionError("Unexpected variable: " + var);
|
||||
@ -133,7 +133,7 @@ public class Annotations extends JavacTestingAbstractProcessor {
|
||||
String type = varType.toString();
|
||||
if (!expectedType.equals(type)) {
|
||||
throw new AssertionError("Unexpected type: " + type +
|
||||
" for: " + var.getName());
|
||||
" for: " + var.getName() + " expected " + expectedType);
|
||||
}
|
||||
return super.visitInstanceOf(node, p);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2022, 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
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8068737
|
||||
* @bug 8068737 8281238
|
||||
* @summary Tests ArrayType.toString with type annotations present
|
||||
* @modules jdk.compiler/com.sun.tools.javac.code
|
||||
* @library /tools/javac/lib
|
||||
@ -66,7 +66,7 @@ public class ArrayTypeToString extends JavacTestingAbstractProcessor {
|
||||
// Normalize output by removing whitespace
|
||||
s = s.replaceAll("\\s", "");
|
||||
|
||||
// Expected: "@Foo(0)java.lang.String@Foo(3)[]@Foo(2)[]@Foo(1)[]"
|
||||
// Expected: "java.lang.@Foo(0)String@Foo(1)[]@Foo(2)[]@Foo(3)[]"
|
||||
processingEnv.getMessager().printNote(s);
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
- compiler.note.proc.messager: @Foo(0)java.lang.String@Foo(1)[]@Foo(2)[]@Foo(3)[]
|
||||
- compiler.note.proc.messager: java.lang.@Foo(0)String@Foo(1)[]@Foo(2)[]@Foo(3)[]
|
||||
|
Loading…
Reference in New Issue
Block a user