Repository navigation
Fix #816: Extraction hardening for java - #868
Merged
Merged
Conversation
Hardens all four extraction gauntlets for java and fixes three real bugs
found during empirical verification:
- func_start/args shared a flat `<[^>]*>` generic-bound modifier
alternative (Rule 11 bug class from how_to_add_a_language.md), breaking
any single-line one-level-nested generic bound, e.g.
`public static <T, U extends Comparable<U>> T Foo(T a, U b) {`. Widened
to the established one-level-nesting idiom `<(?:[^<>]|<[^<>]*>)*>`.
- class_start had no generic-parameter step-over at all between the class
name and its extends/implements check, so any generic class declaration
followed by extends/implements (`class Foo<T> extends Base<T> {`,
common real Java) silently lost the entire inheritance capture even
though the class name itself matched fine.
Verified via crucible_check.py: the only diff across the ~80-repo corpus
is gradle's DefaultPluginManager.java, which now correctly detects
`findPluginIdForClass` (a real method with `<P extends Plugin<?>>`, the
exact nested-generic-bound shape this fixes) -- previously silently
dropped. Golden masters re-blessed for this on-target, expected change.
Also documents two known, unfixed architectural limitations (out of scope
for a single-language pass, tracked in the epic): func_start's Mode-B
string-shielding gap reproduces on Java 15+ text blocks (recurring bug
class 3, now confirmed on a second language), and _dependency_capture
runs against fully unshielded raw file content for every language (new
recurring bug class, broader than the Mode-B gap).
Migrates java's test cases out of the four monolithic dict files into
tests/extraction/languages/test_java.py per the epic's per-language file
layout, and updates the epic + methodology doc with the new findings.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Contributor
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
Part of the extraction-hardening epic (#813). Closes #816.
Hardens all four extraction gauntlets (
func_start,args,class_start,_dependency_capture) for java pertests/extraction/how_to_harden_extraction.md, and fixes three real bugs found during empirical verification:func_start/argsshared a flat<[^>]*>generic-bound modifier alternative (the "Rule 11" bug class) that truncated at the first>, breaking any single-line one-level-nested generic bound, e.g.public static <T, U extends Comparable<U>> T Foo(T a, U b) {. Widened to the established one-level-nesting idiom<(?:[^<>]|<[^<>]*>)*>.class_starthad no generic-parameter step-over at all between the class name and itsextends/implementscheck (a worse variant of the same bug class than TypeScript's Extraction hardening: typescript #815 fix, which only needed widening an existing-but-flat step-over) — so any generic class declaration followed byextends/implements(class Foo<T> extends Base<T> {, common real Java) silently lost the entire inheritance capture even though the class name itself matched fine.Also documents two known, unfixed architectural limitations (out of scope for a single-language pass, tracked in the epic for a future follow-up):
func_start's Mode-B string-shielding gap (_slice_by_braces, currently gated to js/ts only) reproduces on Java 15+ text blocks — confirms recurring bug class 3 is a genuine cross-language gap, not a js/ts quirk._dependency_captureis matched against fully unshielded raw file content for every language (broader than the Mode-B gap, since there's no gate at all there) — new recurring bug class, recorded in the epic.Differential Scan
Ran
python tests/tools/crucible_check.py: the only diff across the ~80-repo corpus is gradle'sDefaultPluginManager.java, which now correctly detectsfindPluginIdForClass(public <P extends Plugin<?>> Optional<PluginId> findPluginIdForClass(...)) — exactly the nested-generic-bound shape this PR fixes, previously silently dropped from the function count (35 → 36 functions detected). Confirmed no other language/file is affected. Golden masters re-blessed for this on-target, expected change viacrucible_check.py --update --yes.Test plan
pytest tests/extraction/languages/test_java.py(67 new tests) — run via barepytestfrom an unrelated CWD to reproduce CI's invocation stylepytest tests/core_engine/ tests/extraction/ -q— 3381 passed, 1 known pre-existing tiktoken-environment failure, 1 xfailedpython tests/tools/audit_check.py— clean (only the pre-existing, already-trackedguidestar_lens.pymypy findings, unrelated to this change)python tests/tools/crucible_check.py— PASS on both venvs after re-blessingtests/extraction/languages/test_java.py🤖 Generated with Claude Code