Skip to content

fix(decompiler): empty catch throw recovery + loop catch throw removal#8

Merged
VillanCh merged 1 commit into
mainfrom
fix/empty-catch-postproc
Jul 15, 2026
Merged

fix(decompiler): empty catch throw recovery + loop catch throw removal#8
VillanCh merged 1 commit into
mainfrom
fix/empty-catch-postproc

Conversation

@VillanCh

Copy link
Copy Markdown
Contributor

Two complementary fixes for TryRewriter dropping catch handler bodies.

Fixes

  1. 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.

  2. 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

  • All provenClean jars: 0 (zero regression)
  • spring: 28 (no change)
  • guava: 26 (no change)
  • commons-lang3: 1 (NumberUtils has an additional unterminated path from nested if-without-else inside try body, separate from the catch issue)

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).
@VillanCh VillanCh merged commit 5ee2e02 into main Jul 15, 2026
13 checks passed
@VillanCh VillanCh deleted the fix/empty-catch-postproc branch July 15, 2026 09:17
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