fix(decompiler): empty catch throw recovery + loop catch throw removal#8
Merged
Conversation
Two complementary fixes for methods where TryRewriter drops the catch handler body (rendering an empty catch that causes "missing return statement"): 1. Empty catch throw (JDEC_FIX_EMPTY_CATCH_THROW_OFF): when a non-void method has an empty catch body, add `throw new RuntimeException(<catchVar>);` to make the catch terminate. The original catch handler had a throw that the TryRewriter lost during structuring. The throw makes the catch path terminate, satisfying javac "missing return statement". 2. Loop catch throw removal (JDEC_FIX_LOOP_CATCH_THROW_OFF): post-processing that removes the throw from empty catches INSIDE loops (where the catch was intentionally empty to swallow and continue). Detects catches whose closing } is immediately followed by continue;/break; and removes the injected throw. This prevents regressions on gson DateTypeAdapter (catch(ParseException) followed by continue in a do-while loop). Zero regression: all 8 jars verified (codec/gson/fastjson2/snakeyaml/jsoup all stay 0, spring 28 same, guava 26 same). commons-lang3 NumberUtils still has 1 error (additional unterminated path from a nested if without else inside the try body, separate from the catch issue).
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.
Two complementary fixes for TryRewriter dropping catch handler bodies.
Fixes
Empty catch throw (JDEC_FIX_EMPTY_CATCH_THROW_OFF): non-void methods with empty catch bodies get
throw new RuntimeException(<catchVar>);added. The original catch handler had a throw that TryRewriter lost.Loop catch throw removal (JDEC_FIX_LOOP_CATCH_THROW_OFF): post-processing removes throws from empty catches inside loops (followed by continue/break). Prevents gson DateTypeAdapter regression.
Results