RFR: 8345614: Include container in "java.lang.annotation.AnnotationFormatError: Duplicate annotation for class" error
Chen Liang
liach at openjdk.org
Thu Dec 5 19:20:14 UTC 2024
On Thu, 5 Dec 2024 16:24:29 GMT, Scott Marlow <duke at openjdk.org> wrote:
> I am getting the `Duplication annotation for class` error as mentioned in https://hibernate.atlassian.net/browse/HHH-18901. The current error message does not include the application class name (e.g. container) that the specified annotation is unexpectedly duplicated. This pull request is for including the class name that has the (duplicate) annotation.
Created a JBS issue https://bugs.openjdk.org/browse/JDK-8345614 for you.
src/java.base/share/classes/sun/reflect/annotation/AnnotationParser.java line 126:
> 124: result.put(klass, a) != null) {
> 125: throw new AnnotationFormatError(
> 126: "Duplicate annotation for class: "+klass+": " + a + ": " + container);
Good RFE. I suggest a message like this:
"Duplicate annotation " + klass + " in " + container
So it will render something like "Duplicate annotation interface java.lang.Deprecated in class com.example.UserClass"
And the actual annotation content doesn't matter as much - it only jams up the message.
Unfortunately we don't have the location for the annotation, but printing out the class name should suffice mostly.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/22581#issuecomment-2521153367
PR Review Comment: https://git.openjdk.org/jdk/pull/22581#discussion_r1871863328
More information about the core-libs-dev
mailing list