proguard icon indicating copy to clipboard operation
proguard copied to clipboard

Exclude annotation members from aggressive overloading

Open Nolij opened this issue 1 year ago • 1 comments

Aggressive overloading class members of annotations can cause errors like this:

Caused by: java.lang.annotation.AnnotationFormatError: java.lang.IllegalArgumentException: methods with same signature a() but incompatible return types: boolean and others
	at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:78)
	at java.base/java.lang.reflect.Field.declaredAnnotations(Field.java:1211)
	at java.base/java.lang.reflect.Field.declaredAnnotations(Field.java:1209)
	at java.base/java.lang.reflect.Field.getAnnotation(Field.java:1176)

This PR excludes annotation class members from aggressive overloading, allowing them to still be obfuscated and for the rest of a project to have aggressive overloading enabled.

Nolij avatar Dec 11 '24 22:12 Nolij

Is there a problem with how the fix for this bug has been implemented? I'd very much like to be able to enable aggressive overloading for one of my projects, and this bug is the only thing preventing me from doing so.

Nolij avatar Aug 07 '25 19:08 Nolij

Hi, thanks for the PR! Apologies for the waiting time.

Do you have a minimal reproduction of the issue that help us understand how you encountered this?

Code looks good, but can you also add an accompanying test?

piazzesiNiccolo-GS avatar Aug 08 '25 07:08 piazzesiNiccolo-GS

Hi, thanks for the PR! Apologies for the waiting time.

Do you have a minimal reproduction of the issue that help us understand how you encountered this?

Code looks good, but can you also add an accompanying test?

The issue should occur when the JVM attempts to classload any annotation class with multiple fields which has been aggressively overloaded. The unit test I added contains one such annotation class.

Nolij avatar Aug 09 '25 15:08 Nolij

The unit test I added contains one such annotation class.

Perfect, thanks!

piazzesiNiccolo-GS avatar Aug 11 '25 07:08 piazzesiNiccolo-GS