Skip to content

Implement exception handling in java-slang - #96

Open
kjw142857 wants to merge 12 commits into
mainfrom
exception-handling
Open

Implement exception handling in java-slang#96
kjw142857 wants to merge 12 commits into
mainfrom
exception-handling

Conversation

@kjw142857

@kjw142857 kjw142857 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Implement exception handling for the following components (in progress):

  • JVM
  • Compiler
  • Type Checker
  • Parser
  • Testing components

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for compiling try-catch-finally statements, refactors the JVM's ExceptionTable to be iterable and use a dedicated class structure, and adds unit tests for exception routing. It also fixes a buffer offset calculation bug in the disassembler when reading code attributes. The reviewer identified several critical bugs in the TryStatement code generation implementation—including a pass-by-value bug with unresolved label offsets, an early return bug when catches are absent but a finally block is present, and incorrect execution paths for finally blocks—and provided a comprehensive rewrite to address these issues.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/compiler/code-generator.ts
@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
72.66% (+0.39% 🔼)
7577/10428
🔴 Branches
59.31% (+0.19% 🔼)
2551/4301
🟡 Functions
69.65% (+0.61% 🔼)
1354/1944
🟡 Lines
73.54% (+0.42% 🔼)
7136/9703
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🔴
... / exception-table.ts
23.08% 20% 28.57% 25%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟡
... / statement-extractor.ts
65.93% (+5.69% 🔼)
55.1% (-4.9% 🔻)
70.91% (+9.21% 🔼)
66.48% (+5.37% 🔼)
🟡 types/errors.ts
64.06% (-0.45% 🔻)
0%
42.86% (-1.59% 🔻)
65.57% (-0.53% 🔻)
🟡
... / throws.ts
53.85% (-12.82% 🔻)
50% (-50% 🔻)
57.14% (+7.14% 🔼)
77.78% (-2.22% 🔻)
🟢
... / methodFactory.ts
90.24% (-0.93% 🔻)
86.84% (-0.66% 🔻)
100% 100%
🟡
... / statements.ts
75% (-8.33% 🔻)
77.78% 100%
75% (-12.5% 🔻)

Test suite run success

1148 tests passing in 65 suites.

Report generated by 🧪jest coverage report action from df4fede

@kjw142857

Copy link
Copy Markdown
Contributor Author

/gemini review

@kjw142857 kjw142857 self-assigned this Jul 1, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for parsing and compiling Java try-catch-finally and throw statements, including AST extraction, code generation, and JVM exception table handling. Feedback on the changes identifies several critical issues: first, accessing finallyNode.blockStatements directly in the code generator will throw a runtime TypeError because finallyNode is of type Finally and its statements reside under finallyNode.block.blockStatements; second, the catch-all exception handler for the finally block is added before specific catch clauses, which would shadow them in the JVM exception table; and third, raw parser tokens (such as LCurly, RCurly, Throw, Try, Catch, and Finally) are incorrectly assumed to have a .location property or are used directly as Location objects, and should instead have their location properties explicitly mapped.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/compiler/code-generator.ts
Comment thread src/compiler/code-generator.ts
Comment thread src/compiler/code-generator.ts Outdated
Comment thread src/compiler/code-generator.ts Outdated
Comment thread src/compiler/code-generator.ts
Comment thread src/ast/astExtractor/statement-extractor.ts
Comment thread src/ast/astExtractor/statement-extractor.ts
Comment thread src/ast/astExtractor/statement-extractor.ts
Comment thread src/ast/astExtractor/statement-extractor.ts
Comment thread src/ast/astExtractor/statement-extractor.ts
@kjw142857
kjw142857 marked this pull request as ready for review July 21, 2026 21:22
@kjw142857
kjw142857 requested a review from martin-henz July 21, 2026 21:22
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@martin-henz
martin-henz requested a review from hj235 July 29, 2026 05:13
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.

2 participants