Skip to content

Conversation

@JaroslavTulach
Copy link
Member

@JaroslavTulach JaroslavTulach commented Jan 20, 2026

Pull Request Description

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • All code follows the
    Java,
  • Unit tests have been written where possible.

@JaroslavTulach JaroslavTulach self-assigned this Jan 20, 2026
@JaroslavTulach JaroslavTulach added CI: No changelog needed Do not require a changelog entry for this PR. -compiler labels Jan 20, 2026
default -> new IllegalStateException(clazz + ":" + msg);
};
stack.addAll(List.of(ex.getStackTrace()));
ex.setStackTrace(stack.toArray(StackTraceElement[]::new));
Copy link
Member Author

@JaroslavTulach JaroslavTulach Jan 20, 2026

Choose a reason for hiding this comment

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

  • these lines try to concatenate the stack from the other JVM
  • with the current stack of this JVM
  • this seem to deliver good enough results as the factorial tests demonstrate

}
}
if (action.value() != countDecrementAndSendMessage) {
ex.printStackTrace();
Copy link
Member Author

Choose a reason for hiding this comment

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

One can check the stacktraces by applying for example this change:

/enso$ git diff
diff --git lib/java/os-environment/src/test/java/org/enso/os/environment/jni/LoadClassTest.java lib/java/os-environment/src/test/java/org/enso/os/environment/jni/LoadClassTest.java
index adcc89db04..cb6e11aae6 100644
--- lib/java/os-environment/src/test/java/org/enso/os/environment/jni/LoadClassTest.java
+++ lib/java/os-environment/src/test/java/org/enso/os/environment/jni/LoadClassTest.java
@@ -233,7 +233,7 @@ public class LoadClassTest {
           countDecrementAndSendMessage++;
         }
       }
-      if (action.value() != countDecrementAndSendMessage) {
+      if (action.value() != -1) {
         ex.printStackTrace();
         assertEquals(
             "There is exactly right amount of invocations",

and then executing:

enso$ sbt os-environment/test
enso$ ./lib/java/os-environment/target/test-os-env  throwFactorialFive


java.lang.IllegalStateException: 120
        at org.enso.os.environment.jni.TestMain$CountDownAndThrow.decrementAndSendMessage(TestMain.java:89)
        at org.enso.os.environment.jni.TestMain$CountDownAndThrow.apply(TestMain.java:83)
        at org.enso.os.environment.jni.TestMain$CountDownAndThrow.apply(TestMain.java:79)
        at org.enso.jvm.channel.ChannelExceptions.exceptionDeserialize(ChannelExceptions.java:91)
        at org.enso.jvm.channel.Channel.executeImpl(Channel.java:435)
        at org.enso.jvm.channel.Channel.execute(Channel.java:250)
        at org.enso.os.environment.jni.TestMain$CountDownAndThrow.decrementAndSendMessage(TestMain.java:91)
        at org.enso.os.environment.jni.TestMain$CountDownAndThrow.apply(TestMain.java:83)
        at org.enso.os.environment.jni.TestMain$CountDownAndThrow.apply(TestMain.java:79)
        at org.enso.jvm.channel.ChannelExceptions.exceptionDeserialize(ChannelExceptions.java:91)
        at org.enso.jvm.channel.Channel.executeImpl(Channel.java:435)
        at org.enso.jvm.channel.Channel.execute(Channel.java:250)
        at org.enso.os.environment.jni.TestMain$CountDownAndThrow.decrementAndSendMessage(TestMain.java:91)
        at org.enso.os.environment.jni.TestMain$CountDownAndThrow.apply(TestMain.java:83)
        at org.enso.os.environment.jni.TestMain$CountDownAndThrow.apply(TestMain.java:79)
        at org.enso.jvm.channel.ChannelExceptions.exceptionDeserialize(ChannelExceptions.java:91)
        at org.enso.jvm.channel.Channel.executeImpl(Channel.java:435)
        at org.enso.jvm.channel.Channel.execute(Channel.java:250)
        at org.enso.os.environment.jni.TestMain$CountDownAndThrow.decrementAndSendMessage(TestMain.java:91)
        at org.enso.os.environment.jni.TestMain$CountDownAndThrow.apply(TestMain.java:83)
        at org.enso.os.environment.jni.TestMain$CountDownAndThrow.apply(TestMain.java:79)
        at org.enso.jvm.channel.ChannelExceptions.exceptionDeserialize(ChannelExceptions.java:91)
        at org.enso.jvm.channel.Channel.executeImpl(Channel.java:435)
        at org.enso.jvm.channel.Channel.execute(Channel.java:250)
        at org.enso.os.environment.jni.TestMain$CountDownAndThrow.decrementAndSendMessage(TestMain.java:91)
        at org.enso.os.environment.jni.TestMain$CountDownAndThrow.apply(TestMain.java:83)
        at org.enso.os.environment.jni.TestMain$CountDownAndThrow.apply(TestMain.java:79)
        at org.enso.jvm.channel.ChannelExceptions.exceptionDeserialize(ChannelExceptions.java:91)
        at org.enso.jvm.channel.Channel.executeImpl(Channel.java:435)
        at org.enso.jvm.channel.Channel.execute(Channel.java:250)
        at org.enso.os.environment.jni.LoadClassTest.assertException(LoadClassTest.java:223)
        at org.enso.os.environment.jni.LoadClassTest.throwFactorialFive(LoadClassTest.java:192)
        at [email protected]/java.lang.reflect.Method.invoke(Method.java:565)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
        at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
        at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
        at org.junit.runners.Suite.runChild(Suite.java:128)
        at org.junit.runners.Suite.runChild(Suite.java:27)
        at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
        at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
        at org.enso.os.environment.TestRunner.main(TestRunner.java:21)
        at [email protected]/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
Test run finished.
Number of tests: 1
Number of tests failed: 0
Number of tests ignored: 0
Test run successful: true

the printed stack trace references decrementAndSendMessage method five times as expected and seems to be concatenated with original stack traces of JUnit runner properly.

@enso-bot enso-bot bot mentioned this pull request Jan 21, 2026
2 tasks
@JaroslavTulach JaroslavTulach changed the title Exception from dual JVM shall have the same heading stack trace Transfer stack trace elements from the other JVM when rethrowing Jan 21, 2026
@JaroslavTulach JaroslavTulach added the CI: Ready to merge This PR is eligible for automatic merge label Jan 22, 2026
@mergify mergify bot merged commit 7264867 into develop Jan 22, 2026
116 of 124 checks passed
@mergify mergify bot deleted the wip/jtulach/DualJvmStackTrace branch January 22, 2026 20:32
@enso-bot
Copy link

enso-bot bot commented Jan 23, 2026

Jaroslav Tulach reports a new STANDUP for the last Wednesday (2026-01-21):

Progress: .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

-compiler CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants