Skip to content

Refactor Kernel#raise and fix remaining specs#9407

Merged
headius merged 22 commits into
jruby:masterfrom
headius:refactor_raise
May 2, 2026
Merged

Refactor Kernel#raise and fix remaining specs#9407
headius merged 22 commits into
jruby:masterfrom
headius:refactor_raise

Conversation

@headius

@headius headius commented May 1, 2026

Copy link
Copy Markdown
Member

In response to #9398 I finally did a major refactor of Kernel#raise. This PR splits up the different arity paths rather than running them all together and moves most of the logic to common utility methods. The last two rubyspecs related to cause have also been fixed.

@headius headius added this to the JRuby 10.1.1.0 milestone May 1, 2026
headius added 9 commits May 1, 2026 16:29
This is the first step in simplifying Kernel#raise logic by
splitting the various arities and ensuring each works on its own.
Sharing a single method, as in CRuby, is difficult to maintain and
obscures the intricate behaviors between those paths. Having each
arity separate will make it easier to get to 100% compliance and
maintain going forward.
This is zero-sum, no new behavior.
This is zero-sum, no new behavior.
This is zero-sum, no new behavior.
Whenever core logic prepares to throw an exception, it should
propagate the current error info as that exception's cause. This
fixes the NameError case but others should be audited. It may make
sense to route all core exception raises through a single piece of
code to perform this operation in one place.
* Introduce Cause record and common extraction logic.
* Factor out common parts of exception construction and cause
  setting.
* Clean up remaining variable-arity paths from kwargs handling.
* Document all utility methods.
headius added 13 commits May 1, 2026 16:56
LocalJumpErrors during END blocks become warnings so any remaining
END blocks can execute. Clear $! so they don't become the cause of
exceptions raised during other END blocks.
Fixes mri/ruby/test_exception test_warning_warn

See ruby/ruby@d249b04
We do not dynamically dispatch to get the backtrace and probably
never will.
Fixes one spec and CRuby test_exception's
test_marshal_circular_cause.
Unsure where else this is used. There's very few references in
tests, including the one this fixes.
@headius
headius merged commit 3484dfe into jruby:master May 2, 2026
108 checks passed
@headius
headius deleted the refactor_raise branch May 2, 2026 19:23
@headius

headius commented May 2, 2026

Copy link
Copy Markdown
Member Author

Merged! This does not do the additional work to improve pass rate and coverage of Thread#raise and Fiber#raise but it lays the groundwork to make that easy.

I also audited the CRuby test_exception failures, fixed several, and added good descriptions for the remaining ones.

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