-
Bug
-
Resolution: Fixed
-
P4
-
23, 24
-
b22
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
openjdk 23 2024-09-17
OpenJDK Runtime Environment Corretto-23.0.0.37.1 (build 23+37-FR)
OpenJDK 64-Bit Server VM Corretto-23.0.0.37.1 (build 23+37-FR, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
TypeMirror's documentation says that a the result of a toString() should try to be valid to use in source code.
/**
* Returns an informative string representation of this type. If
* possible, the string should be of a form suitable for
* representing this type in source code. Any names embedded in
* the result are qualified if possible.
*
* @return a string representation of this type
*/
JDK-8281238 Solved this for the case of a single annotation. So now if we have
```
@Example String name;
```
The TypeMirror will give
```
java.lang.@Example String
```
But with multiple we get
```
java.lang.@A,@B String
```
Which is invalid. You would expect `java.lang.@A @B String`
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Make two annotations whose target is TYPE_USE
@Target({ElementType.TYPE_USE})
@interface ExampleAnn {}
@Target({ElementType.TYPE_USE})
@interface Other {}
2. Write some code which uses those annotation on a field type
class Example {
@ExampleAnn @Other String abc;
}
3. Obtain a TypeMirror of the VariableElement via an annotation processor.
4. Using .toString() on that TypeMirror
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
java.lang.@ExampleAnn @Other String
ACTUAL -
java.lang@ExampleAnn,@Other String
FREQUENCY : always
openjdk 23 2024-09-17
OpenJDK Runtime Environment Corretto-23.0.0.37.1 (build 23+37-FR)
OpenJDK 64-Bit Server VM Corretto-23.0.0.37.1 (build 23+37-FR, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
TypeMirror's documentation says that a the result of a toString() should try to be valid to use in source code.
/**
* Returns an informative string representation of this type. If
* possible, the string should be of a form suitable for
* representing this type in source code. Any names embedded in
* the result are qualified if possible.
*
* @return a string representation of this type
*/
```
@Example String name;
```
The TypeMirror will give
```
java.lang.@Example String
```
But with multiple we get
```
java.lang.@A,@B String
```
Which is invalid. You would expect `java.lang.@A @B String`
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Make two annotations whose target is TYPE_USE
@Target({ElementType.TYPE_USE})
@interface ExampleAnn {}
@Target({ElementType.TYPE_USE})
@interface Other {}
2. Write some code which uses those annotation on a field type
class Example {
@ExampleAnn @Other String abc;
}
3. Obtain a TypeMirror of the VariableElement via an annotation processor.
4. Using .toString() on that TypeMirror
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
java.lang.@ExampleAnn @Other String
ACTUAL -
java.lang@ExampleAnn,@Other String
FREQUENCY : always
- relates to
-
JDK-8281238 TYPE_USE annotations not printed in correct position in toString output
-
- Resolved
-
- links to
-
Commit(master) openjdk/jdk/ff165f9f
-
Review(master) openjdk/jdk/21702