Skip to content

fix(java): reading another class's constant doesn't read the file's own - #3189

Merged
colbymchenry merged 1 commit into
mainfrom
claude/fix-java-qualified-value-reads
Nov 1, 2026
Merged

colbymchenry merged 1 commit into
mainfrom
claude/fix-java-qualified-value-reads

Conversation

@colbymchenry

Copy link
Copy Markdown
Owner

The value-reference pass links a symbol to the same-file constants its body
reads, and it matched identifiers by name alone: elasticsearch's
RerankRequest.parseStringOrObject passed for a reader of its own PARSER
because it reads InferenceString.PARSER.

The fix, in the wasm extractor (isForeignJavaField) and the kernel
(is_foreign_field) alike: an identifier that is the field of a field_access
counts only through this or through the class that declares the constant.

Validation:

  • java-value-reads.test.ts: 1 of 2 cases fails on main without the kernel, all
    pass with and without it.
  • Kernel parity, java: jsoup, Minestom and rocksdb's java/ 2,267 of 2,301 files
    byte-identical, 34 deferred to wasm, 0 with diffs; elasticsearch's action and
    cluster packages 1,269 of 1,270, spring-ai and kestra 5,488 of 5,489, 0 with
    diffs.
  • A/B against main 4499d00: value references dropped, elasticsearch 226,
    Minestom 72, kestra 19, jsoup 1, spring-ai and okhttp 0. A check over each
    dropped edge's source finds no bare, this. or owner-qualified read of the
    constant in any of them (LeafBucketCollector.NO_OP_COLLECTOR passes for one
    by its suffix, 3 times: it is a read of another class).
  • Kotlin and Swift have the same reader, and it matters little there (2 of 31
    and 3 of 496 on nowinandroid and okhttp), so they stay as they are.
  • CPU: with the Java overloads PR, which has the numbers.

Suite: 874 files passed, 6 skipped; 10,847 tests passed, 2 expected fail, 87 skipped, with the kernel on Windows, on the stack of these 8 PRs at 00b79ff2 over main 1f188da. The A/B numbers are against 4499d00; the stack on 1f188da is edge for edge the same arm on jsoup, rocksdb's java/, Minestom, okhttp, tokio, caddy, Alamofire, nowinandroid and mihon, and those repos give the same graph on both mains.

🤖 Generated with Claude Code

The value-reference pass links a symbol to the same-file constants its body
reads, and it matched identifiers by name alone: elasticsearch's
`RerankRequest.parseStringOrObject` passed for a reader of its own `PARSER`
because it reads `InferenceString.PARSER`.

The fix, in the wasm extractor (isForeignJavaField) and the kernel
(is_foreign_field) alike: an identifier that is the field of a `field_access`
counts only through `this` or through the class that declares the constant.

Validation:
- java-value-reads.test.ts: 1 of 2 cases fails on main without the kernel, all
  pass with and without it.
- Kernel parity, java: jsoup, Minestom and rocksdb's java/ 2,267 of 2,301 files
  byte-identical, 34 deferred to wasm, 0 with diffs; elasticsearch's action and
  cluster packages 1,269 of 1,270, spring-ai and kestra 5,488 of 5,489, 0 with
  diffs.
- A/B against main 4499d00: value references dropped, elasticsearch 226,
  Minestom 72, kestra 19, jsoup 1, spring-ai and okhttp 0. A check over each
  dropped edge's source finds no bare, `this.` or owner-qualified read of the
  constant in any of them (`LeafBucketCollector.NO_OP_COLLECTOR` passes for one
  by its suffix, 3 times: it is a read of another class).
- Kotlin and Swift have the same reader, and it matters little there (2 of 31
  and 3 of 496 on nowinandroid and okhttp), so they stay as they are.
- CPU: with the Java overloads PR, which has the numbers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@colbymchenry
colbymchenry merged commit c344366 into main Nov 1, 2026
@colbymchenry
colbymchenry deleted the claude/fix-java-qualified-value-reads branch November 1, 2026 09:35
bompus added a commit to bompus/codegraph that referenced this pull request Nov 2, 2026
…wn (colbymchenry#3189)

Ported from upstream c344366.

`InferenceString.PARSER` reads that class's constant, not the `PARSER` of the
file reading it, but value references went by the identifier alone: a method of
elasticsearch's `RerankRequest` passed for a reader of its own `PARSER` because
it read `InferenceString.PARSER`. A read through a qualifier now counts when
the qualifier is `this` or names the class that declares the constant. The
generic extractor's value-ref pass gains the same rule.

Also brings the TS extractor's interface-constant, Kotlin-property visibility,
`fun interface` and receiver-chain changes so the generic extractor and the
kernel still agree on the parity fixtures.
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.

1 participant