Skip to content

fix(java): allow type-use annotations interleaved with modifiers in func_start - #1489

Merged
squid-protocol merged 1 commit into
mainfrom
fix/java-1486-annotation-position
Aug 13, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix/java-1486-annotation-position

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

  • Widens java's func_start regex's modifier-repetition alternation to also accept an annotation (@[\w.]+(?:\([^)]*\))?) on each iteration, not just in the single leading position before all modifiers. Real JSR-308 type-use annotations (@Nullable/@NonNull) commonly appear between a modifier and the return type (protected @Nullable Foo bar(...)), which was previously entirely unmatched. The existing {0,5} ReDoS bound is untouched -- purely a repositioning of where the annotation alternative is allowed to match.
  • Confirmed 47 occurrences of this shape across the 7-file java crucible corpus -- the dominant cause of java's func_recall gap (extra_functions was already 0, so this was purely under-matching).

Measured: found_functions 233->266, extra_functions unchanged at 0, func_recall 87.6%->100%.

Fixes #1486.

Test plan

  • 3 new regression cases added to tests/extraction/languages/test_java.py (annotation-after-modifier, annotation-with-arguments, annotation-as-sole-modifier-token)
  • pytest tests/extraction/languages/test_java.py tests/extraction/languages/test_java_strict.py -- 161 passed
  • Pathological-input timing probe on the widened alternation -- no ReDoS blowup (microsecond-scale on adversarial repeated-annotation input)
  • tree_sitter_accuracy_audit.py --lang java --regenerate blessed, --summary-table regenerated
  • --all --ci clean across all 31 languages
  • crucible_check.py --mode both -- real drift confirmed as the intended effect (groovy/spock/SpecRewriter.java's Function/Method Declarations went 56->58, picking up 2 more real annotated methods in that Java file), rest is the expected cascading spatial-coordinate/PageRank shift documented in tests/tools/crucible_check.py's own guidance; blessed via --update --yes, re-ran to confirm PASS/PASS
  • audit_check.py --ci clean (ruff/mypy/dead-key/ast-accuracy)

Note for reviewers: the accuracy audit's args_exact_match sample output for java now surfaces a few pre-existing param-count mismatches on the newly-recovered functions (e.g. getAttributes real=1 got=2) -- that's #1339's tracked args-identification gap, not new fallout from this fix. func_start recall/precision (this issue's scope) is clean.

…unc_start

Java's func_start regex only allowed annotations in the leading position before
all modifiers. Real JSR-308 type-use annotations (@Nullable/@nonnull) commonly
appear between a modifier and the return type instead:

    protected @nullable AnnotationAttributes getAttributes(AnnotationMetadata metadata) {

This shape was entirely unmatched -- confirmed 47 occurrences across the java
crucible corpus, the dominant cause of java's func_recall gap. Fix widens the
modifier-repetition alternation to also accept an annotation on each iteration,
keeping the existing {0,5} ReDoS bound untouched.

found_functions 233->266, extra_functions unchanged at 0, func_recall 87.6%->100%.

Fixes #1486.

Co-authored-by: Claude Sonnet 5 <[email protected]>
@squid-protocol
squid-protocol merged commit 85a2be1 into main Aug 13, 2026
27 checks passed
@squid-protocol
squid-protocol deleted the fix/java-1486-annotation-position branch August 13, 2026 20:20
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

squid-protocol added a commit that referenced this pull request Aug 22, 2026
…omparison sweep (#2092)

Tri-comparison ledger sweep for java validated 4 unvalidated shapes and found 3
real, confirmed engine/audit-tool defects (all now fixed and re-verified):

- func_start silently dropped bodyless abstract/interface method declarations
  (`protected abstract long startTime();`) via detector.py's generic Mode-B
  fallback, which only ever searches for a `{` and discards `;`-terminated
  matches. Java never got the dedicated terminator-search handling that
  csharp/rust/go/objective-c/dart/perl already have for this same shape.
  (#2089)
- args' modifier-repeat group never got the interleaved-return-type-annotation
  fix (`private <T> @nullable T foo(...)`) that func_start's sibling group
  already got in #1486/#1489, causing the whole args alternation to fall
  through to the lambda-matching branch and misattribute an unrelated in-body
  lambda's arg count as the function's own. (#2091)
- tree_sitter_accuracy_audit.py's own `_get_param_count` was missing java's
  `spread_parameter` (varargs) node type from its counted_types whitelist --
  the same recurring per-grammar gap already fixed for 11 other languages.
  Not a GitGalaxy defect. (#2090)

All 4 ledger shapes (28+12+3+1 occurrences) now validated, still_reproduces:
false. Java's tri-comparison chart is now a clean 100% 3-way tie (318/318 func
precision, 35/35 class precision) with no unvalidated-disagreement asterisks.
Both golden-master fixtures re-blessed against the full differential-scan
corpus -- all drift traces to java/springboot's corrected function-parameter
counts, java files inside groovy-ecosystem repos, and the expected topological
ripple from the whole-graph layout recomputing.

Also adds docs/language_status/java.md (previously undocumented).

Co-authored-by: Joe Esquibel <[email protected]>
Co-authored-by: Claude Sonnet 5 <[email protected]>
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.

java func_start: type-use annotation between modifier and return type not matched (e.g. 'protected @Nullable Foo bar(...)')

1 participant