Skip to content

Fix getAnnotations() returning empty list for removed members - #498

Merged
siom79 merged 2 commits into
masterfrom
claude/fix-removed-annotations-fQAHT
Apr 9, 2026
Merged

siom79 merged 2 commits into
masterfrom
claude/fix-removed-annotations-fQAHT

Conversation

@siom79

@siom79 siom79 commented Apr 9, 2026

Copy link
Copy Markdown
Owner

When a member (method, constructor, field, class) is REMOVED,
computeAnnotationChanges() was called eagerly in constructors before
Javassist had parsed the class file attributes. This caused
getAttribute(AnnotationsAttribute.visibleTag) to return null, caching
an empty annotation list permanently.

Fix by deferring annotation computation to the first call of
getAnnotations() in JApiBehavior, JApiField, and JApiClass.

Also adds withAnnotation() support to CtConstructorBuilder (matching
the existing CtMethodBuilder and CtFieldBuilder pattern), and adds
tests in CompatibilityChangesTest for all three cases (removed
constructor, method, and field with annotations) plus an integration
test in AnnotationsTest.

https://claude.ai/code/session_019gTAxahJgAQ8tMhC8Wm5XZ

claude added 2 commits April 9, 2026 18:43
When a member (method, constructor, field, class) is REMOVED,
computeAnnotationChanges() was called eagerly in constructors before
Javassist had parsed the class file attributes. This caused
getAttribute(AnnotationsAttribute.visibleTag) to return null, caching
an empty annotation list permanently.

Fix by deferring annotation computation to the first call of
getAnnotations() in JApiBehavior, JApiField, and JApiClass.

Also adds withAnnotation() support to CtConstructorBuilder (matching
the existing CtMethodBuilder and CtFieldBuilder pattern), and adds
tests in CompatibilityChangesTest for all three cases (removed
constructor, method, and field with annotations) plus an integration
test in AnnotationsTest.

https://claude.ai/code/session_019gTAxahJgAQ8tMhC8Wm5XZ
…uilder

CtFieldBuilder defaults to PUBLIC and has no publicAccess() method,
unlike CtMethodBuilder.

https://claude.ai/code/session_019gTAxahJgAQ8tMhC8Wm5XZ
@siom79

siom79 commented Apr 9, 2026

Copy link
Copy Markdown
Owner Author

Fixes #497

@siom79
siom79 merged commit 2ba4bee into master Apr 9, 2026
12 checks passed
@siom79
siom79 deleted the claude/fix-removed-annotations-fQAHT branch April 9, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants