You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
getAnnotations() returns empty list for removed members due to eager initialization #497
When a method is marked as "removed", calling getAnnotations() on the corresponding JApiMethod often returns an empty list, even if the member had annotations in the old version.
I think the bug is caused by eager initialization of annotations during the constructor phase of the model classes. japicmp calls computeAnnotationChanges() directly inside the constructors of these classes. This method asks javassist for the AnnotationsAttribute.visibleTag attribute. If I'm not mistaken, javassist parses class file attributes lazily. At the exact moment japicmp instantiates the model object, javassist has not fully parsed the attributes for that removed member yet, so getAttribute() returns null.
I have somewhat validated this analysis in my build. I am manually calling javassist in a rule, once that javassist has fully loaded the attributes, but japicmp has already cached the empty list. This local patch works. Could getAnnotations() lazily collect the information from javassist?
I think the same issue exists for fields, classes and methods.
Steps to Reproduce:
Create a class with a constructor annotated with @Deprecated
In a newer version, remove the constructor.
Run japicmp and inspect the JApiConstructor for the removed constructor.
jApiConstructor.getAnnotations() will be empty, despite the old constructor having the @Deprecated annotation.
Activity
siom79 commentedon Apr 9, 2026
Thanks a lot for reporting and even analyzing the root cause. The PR #498 fixes the issue.
bclozel commentedon Apr 10, 2026
That was fast, thanks a lot for your work on this project!