-
Notifications
You must be signed in to change notification settings - Fork 336
Transfer stack trace elements from the other JVM when rethrowing #14666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
lib/java/jvm-interop/src/test/java/org/enso/jvm/interop/impl/OtherJvmObjectTest.java
Show resolved
Hide resolved
| default -> new IllegalStateException(clazz + ":" + msg); | ||
| }; | ||
| stack.addAll(List.of(ex.getStackTrace())); | ||
| ex.setStackTrace(stack.toArray(StackTraceElement[]::new)); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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: truethe printed stack trace references decrementAndSendMessage method five times as expected and seems to be concatenated with original stack traces of JUnit runner properly.
lib/java/jvm-channel/src/main/java/org/enso/jvm/channel/Channel.java
Outdated
Show resolved
Hide resolved
…always unexpected.
|
Jaroslav Tulach reports a new STANDUP for the last Wednesday (2026-01-21): Progress: .
|
Pull Request Description
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Java,