Rethrow JVM errors unchanged in MethodHandleFactory.invokeExact - #70
Merged
garydgregory merged 1 commit intoSep 1, 2026
Merged
Conversation
An undeclared Error raised through the MethodHandle lookup path (an OutOfMemoryError, for example) was wrapped in IllegalStateException, demoting it from Error to RuntimeException and hiding it from supervisors that handle Error separately. Rethrow it unchanged; the IllegalStateException wrap now covers runtime exceptions only, since the looked-up factory methods declare no other checked exceptions. Assert instance identity, not just type, on both rethrow paths. Assisted-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CLnTBsvmYtxzNTWVGNyz33
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.
MethodHandleFactory.invokeExactwrapped every throwable that was not of the declared rethrow type inIllegalStateException— including undeclared JVMErrors. AnOutOfMemoryErrorraised mid-lookup was thereby demoted fromErrortoRuntimeException, hiding it from supervisors that handleErrorseparately and conflating it with securing failures (SecureExceptionalso extendsIllegalStateException).The fix rethrows an undeclared
Errorunchanged before the wrap, leavingIllegalStateExceptionto cover runtime exceptions only (the looked-upnewDefault*factory methods declare no other checked exceptions). Tests now assert instance identity, not just type, on both rethrow paths, and a new test drives anOutOfMemoryErrorthrough the helper.This completes the remainder of a scan finding whose headline defect — the inverted
e.getClass().isInstance(rethrow)check that made the declared-type rethrow dead code — was already fixed incd2a7a4.🤖 Generated with Claude Code