Skip to content

fix(java): give Lombok @Getter fields the getter node javac sees (#5148) - #5347

Open
Deepjyoti-Sarmah wants to merge 3 commits into
Graphify-Labs:v8from
Deepjyoti-Sarmah:fix/5148-lombok-getter
Open

Deepjyoti-Sarmah wants to merge 3 commits into
Graphify-Labs:v8from
Deepjyoti-Sarmah:fix/5148-lombok-getter

Conversation

@Deepjyoti-Sarmah

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #5148. A call through a Lombok @Getter getter, Model.getInstance().work(), produced no calls edge. On 0.9.112 with the issue's repro:

lombok   (getInstance from @Getter)       no calls edges
control  (hand-written getInstance())     .run() calls .work()
                                          .run() calls .getInstance()

The caller side is the same in both cases. What differs is Model.java:

raw_call work   java_receiver_chain = ['call', 'getInstance', ['type', 'Model'], 0]

control  Model nodes: Model.java, Model, .getInstance() [_java_ret=Model, arity 0], .work()
lombok   Model nodes: Model.java, Model, .work()

_chain_type in graphify/extract.py types each step from the _java_ret of the method it names. Lombok writes getInstance() at compile time, so the source has no node for it. The step returns None and work() stays unresolved.

The fix gives a @Getter field the node a hand-written getter would get, as the issue suggests:

 field_declaration in a class body
   record field types (unchanged)
+  for each getter Lombok writes for this field
+    node .getX() / .isX()   metadata {arity: 0, signature: "", lombok: "Getter"}
+    class --method--> getter
+    _java_ret = the field's declared type

The chain typing from #4306 then works unchanged.

Which getters

field getter
@Getter static Model Instance getInstance()
@Getter boolean active isActive()
@Getter boolean isReady isReady()
@Getter Boolean flag getFlag()
@Getter int a, b getA(), getB()
@Getter on the class instance fields only, not static
@Getter(AccessLevel.NONE) none
class already has int getX() (any case) none, the hand-written one stays
@Getter not from Lombok (no lombok.Getter / lombok.* import, not @lombok.Getter) none

These follow Lombok's documented rules for @Getter.

Commits

7ef5a9d6  test(5148): pin Lombok @Getter getters as callable Java members
579a3083  fix(5148): give Lombok @Getter fields the getter node javac sees
db3bf60e  fix(cache): bump AST cache schema to 49 for Lombok getters

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Tests or CI
  • Refactor
  • Security fix

Verification & Invariants

Invariant: a getter that exists after Lombok runs is a member node with the field's type as its return type, the same as if it were written by hand.

  • Read the CONTRIBUTING.md guide.
  • Reproduced the issue and identified the invariant.
  • Made the smallest fix necessary.
  • Added a regression test (if bug fix) or isolated boundary test.
  • Kept the PR description synchronized with the final implementation.
  • Documented any limitations / unsupported cases explicitly.

Merge Danger

Door: two-way. Reverting the fix commit restores 0.9.112 output; the cache bump forces one re-extraction.

Blast Radius: small.

  • Only Java files that import Lombok's @Getter (or use @lombok.Getter) gain nodes.
  • Each such class gains one .getX() node per field and its method edge, so node counts and god-node rankings in Lombok-heavy repos go up.
  • _AST_CACHE_SCHEMA 48 -> 49, so every cached file re-extracts once.

Limitations

  • @Data and @Value also generate getters and are not handled here.
  • lombok.config settings (lombok.accessors.prefix, fluent, chain) are ignored; the getter name always uses the default rule.
  • A field whose type is a primitive or unknown gets the node but adds no chain typing, as for a hand-written getter.
  • Not checked against a real Lombok compile; the naming follows the @Getter docs.

How was this tested?

New tests/test_java_lombok_getter.py, 11 tests:

test_static_getter_chain_reaches_the_member          issue repro: .run() calls .work() and .getInstance()
test_generated_getter_looks_like_a_hand_written_one  _java_ret, arity 0, lombok marker, method edge
test_getter_name_follows_lombok                      boolean, boolean isX, Boolean, uRL, int a, b
test_class_level_getter_skips_static_fields
test_no_extra_getter_node                            AccessLevel.NONE, non-Lombok @Getter, hand-written getX()
tree new tests
0.9.112 340268a7 8 failed, 3 passed (the 3 are the no-extra-node guards)
db3bf60e 11 passed

The issue's CLI repro (graphify extract . --code-only --no-cluster) on this branch gives the Lombok case the same two edges as the control case.

Full suite, both trees run at the same time in the same venv:

tree failed passed
340268a7 76 11515
db3bf60e 77 11525

The 76 are identical. The extra one is test_language_override_lifecycle.py::test_watch_root_config_lifecycle_rebuilds_and_refreshes_event_mapping[delete], a watch timing test with no Java in it. Run alone it passed 29/30 on this branch and 30/30 on 340268a7; its [replace] twin failed only on the base tree in a run for another PR.

pytest -k java                                       -> 232 passed
ruff check graphify/extractors/engine.py graphify/cache.py tests/test_java_lombok_getter.py -> All checks passed

Graphify-specific checklist

  • I updated generated skill artifacts (uv run python -m tools.skillgen --bless) when changing their source fragments. (No fragment change.)
  • I confirmed that AST/structural extraction remains deterministic (no ambient state dependencies like ENV variables).
  • I reviewed changes for security implications (no unsafe interpolation into shell/Python).
  • I confirmed no API keys or local-only graph data are included.
  • (If applicable) I disclosed AI authorship in my commit messages. (No trailer in the commit messages.)

A chain through a Lombok-generated getter (Model.getInstance().work()) had no calls edge, because the getter has no declaration in the source. Pins the issue repro, the getter node's shape, Lombok's get/is naming, class-level @Getter skipping static fields, and the cases that must add nothing.
A field (or class) annotated with Lombok's @Getter now gets a .getX()/.isX() node with arity 0, a method edge from its class, and the field's type as its return type, so the existing Java chain typing (Graphify-Labs#4306) resolves Model.getInstance().work(). A bare @Getter counts only when the file imports lombok.Getter or lombok.*; AccessLevel.NONE and a hand-written zero-argument method of the same name (case-insensitive) suppress it.
Cached Java extractions from 0.9.112 have no getter nodes, so they must re-run.
@github-actions github-actions Bot added the contributor Pull request from a returning community contributor label Nov 19, 2026
@github-actions

Copy link
Copy Markdown

Thanks for the pull request, @Deepjyoti-Sarmah. A maintainer will review it soon.

Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions.

A couple of things that speed up review: make sure the test suite passes on Python 3.11 and 3.13, and that the change keeps extraction deterministic.

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify code review View in Graphify

Review completed · db3bf60e1ecd

Warning

Merge confidence: 3/5 · Review before merging · 🟠 High impact
1 P2 bug checked against the code

Java extraction now adds method nodes for fields covered by Lombok @Getter, including their return types.

Full summary

Java extraction now adds method nodes for fields covered by Lombok @Getter, including their return types. The new tests cover common getter naming, class-level annotations, and several suppression cases.

Bugs (1)

P2 · Update _java_lombok_getters to honor @Accessors(fluent = true): it creates .getValue() instead of .value(), so calls to value() do not resolve to the generated getter. Inspect source

Detailed review · checked against the code

Fluent Lombok accessors get the wrong method name

For a field using @Getter with @Accessors(fluent = true), extraction adds .getValue() even though Lombok generates value(). Calls to the generated accessor therefore do not resolve to the getter node.

Expected: Extraction creates a generated getter node named .value() so the call resolves to it.
Actually: The helper creates .getValue() instead; the resolver's name-based lookup does not match the value() call to that node.

For a Lombok @Getter field, _java_lombok_getters derives the synthetic accessor using get or is plus the capitalized field name. It does not inspect @Accessors(fluent = true), so a fluent field such as value gets a .getValue() node instead of .value(). The extractor invokes this helper while processing Java field declarations, creates the generated method node, and the Java member-call resolver indexes and looks up methods by their names. Thus a call to value() will not match the generated getValue() node. The inspected Lombok tests cover conventional getter names but do not exercise fluent accessors.

  • Independent source review: Inspected the Java field-declaration path and member-call resolver; the resolver looks up methods by the callee name, and no fluent-accessor handling was found in the inspected source. The Lombok tests check ordinary getter naming and do not provide a counterexample for fluent naming.
What this review covered
  • One review pass used all of its turns for reading code, so it reported from what it had already read.
  • 3 of 3 changed files inspected. This is scope, not a correctness guarantee.
Code graph and static checks · 4821 functions depend on this change

Impact & health

Impact — 4821 functions depend on the 572 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: extract() — 1284 callers, 78 callees
  • worse: walk() — 1 callers, 100 callees

Formal checks — 4821 functions this change can affect weren't formally checked in this review. Formal checks are informational only.

Gate & verification

✅ PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 3145 function(s) in the blast radius were not formally verified this run

Test selection

102 of 594 test file(s) selected (17%) via static blast radius.

  • tests/test_4992_ts_import_types.py — impact
  • tests/test_astro_extraction.py — impact
  • tests/test_binary_media_words.py — impact
  • tests/test_build.py — impact
  • tests/test_cache.py — impact
  • tests/test_cache_long_paths.py — impact
  • tests/test_cache_stale_import_target.py — impact
  • tests/test_cache_windows_case_4925.py — impact
  • tests/test_charmap_encoding.py — impact
  • tests/test_chunking.py — impact
  • tests/test_cjs_module_extension.py — impact
  • tests/test_code_only_scope_4923.py — impact
  • tests/test_cpp_alias_member_resolution.py — impact
  • tests/test_cpp_conditional_initializers.py — impact
  • tests/test_cpp_inherited_member_resolution.py — impact
  • tests/test_cpp_nested_and_cli.py — impact
  • tests/test_cpp_template_members.py — impact
  • tests/test_csharp_extension_calls.py — impact
  • tests/test_csharp_extension_metadata.py — impact
  • tests/test_csharp_extension_resolution.py — impact
  • tests/test_csharp_partial_classes.py — impact
  • tests/test_dart.py — impact
  • tests/test_dart_typedef.py — impact
  • tests/test_definition_file_portability.py — impact
  • tests/test_detect.py — impact
  • tests/test_dotnet.py — impact
  • tests/test_ejs_extractor.py — impact
  • tests/test_ext_tagged_id_clash.py — impact
  • tests/test_extract.py — impact
  • tests/test_extract_cache_location.py — impact
  • tests/test_extract_cli.py — impact
  • tests/test_extract_php_closures.py — impact
  • tests/test_grammar_cache_key.py — impact
  • tests/test_hook_content_freshness.py — impact
  • tests/test_ignore_file_encoding.py — impact
  • tests/test_import_extension_resolution.py — impact
  • tests/test_incremental_mtime_collision.py — impact
  • tests/test_indirect_call_block_scoped_shadow.py — impact
  • tests/test_indirect_dispatch.py — impact
  • tests/test_indirect_dispatch_assign_return.py — impact
  • tests/test_indirect_dispatch_getattr.py — impact
  • tests/test_java_lombok_getter.py — impact, changed-test
  • tests/test_java_member_calls.py — impact
  • tests/test_java_nested_type_identity.py — impact
  • tests/test_js_exported_scalar_bindings.py — impact
  • tests/test_js_member_collisions.py — impact
  • tests/test_language_override_lifecycle.py — impact
  • tests/test_language_overrides.py — impact
  • tests/test_languages.py — impact
  • tests/test_linked_worktree_reconcile.py — impact
  • … and 52 more

Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.

Every flagged function

  • extract() in graphify/extract.py:11742 · 1284 callers, 78 callees: fans out to 78 callees (efferent coupling); 1284 callers depend on it (afferent coupling)
  • walk() in graphify/extractors/engine.py:7977 · 1 callers, 100 callees: fans out to 100 callees (efferent coupling)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor Pull request from a returning community contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Java: calls through a Lombok @Getter static singleton (Model.getInstance().m()) get no calls edge

1 participant