RFR: 8345614: Include container in "java.lang.annotation.AnnotationFormatError: Duplicate annotation for class" error

Scott Marlow duke at openjdk.org
Thu Dec 5 19:20:14 UTC 2024


On Thu, 5 Dec 2024 18:43:50 GMT, Chen Liang <liach at openjdk.org> wrote:

> Created a JBS issue https://bugs.openjdk.org/browse/JDK-8345614 for you.

I'll force push once more to rename the commit to issue reference the ^ issue.  Thank you @liach for creating that!

> 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.

Thanks, change made and resolving conversation...

-------------

PR Comment: https://git.openjdk.org/jdk/pull/22581#issuecomment-2521190522
PR Review Comment: https://git.openjdk.org/jdk/pull/22581#discussion_r1871885258


More information about the core-libs-dev mailing list