After fix for
JRUBY-1988 (rev. 5634), the Kernel#exec method always raises SystemExit to simulate MRI's exec behavior, where exec'ed process replaces the original one. There is a minor problem with this approach - the raised SystemExit can be rescued from within the script, which is not possible in MRI. Ideally, we should raise in such a way that it's not possible to the parent script to see and rescue the exception.
Attached test case shows the problem.
With MRI, the test run is replaced with the sub-process.
In JRuby, the SystemExit is raised (and rescued by the test, allowing to continue the execution):