Repository navigation
fix(java): allow type-use annotations interleaved with modifiers in func_start - #1489
Merged
Merged
Conversation
…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]>
Contributor
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
func_startregex'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.Measured:
found_functions233->266,extra_functionsunchanged at 0, func_recall 87.6%->100%.Fixes #1486.
Test plan
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 passedtree_sitter_accuracy_audit.py --lang java --regenerateblessed,--summary-tableregenerated--all --ciclean across all 31 languagescrucible_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 intests/tools/crucible_check.py's own guidance; blessed via--update --yes, re-ran to confirm PASS/PASSaudit_check.py --ciclean (ruff/mypy/dead-key/ast-accuracy)Note for reviewers: the accuracy audit's
args_exact_matchsample output for java now surfaces a few pre-existing param-count mismatches on the newly-recovered functions (e.g.getAttributesreal=1 got=2) -- that's #1339's tracked args-identification gap, not new fallout from this fix.func_startrecall/precision (this issue's scope) is clean.