You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice that if a Java exception is throw, it is wrapped in a JavaException in Dart and that Dart exception is throw.
JavaException should contain as much information as possible.
JavaException should not refer to any Java object, but copy all information to Dart memory. (The error message, the Java stack trace, etc.) Exceptions should not be common, so we should not worry about the overhead of copying, and it would be good to not have to worry about native resource management at all.
JavaException should have a toString() that prints the Java error message and stack trace. This will ensure that if we don't catch it we can get some useful information from stderr/stdout.
I think getting the stack trace involves the following calls, as tried on JShell
jshell> var out = new ByteArrayOutputStream()
out ==>
jshell> var print = new PrintStream(out)
print ==> java.io.PrintStream@4520ebad
jshell> var random = new Random()
random ==> java.util.Random@d2cc05a
jshell> try {
...> random.nextInt(-1);
...> } catch (Exception e) {
...> e.printStackTrace(print);
...> }
jshell> out
out ==> java.lang.IllegalArgumentException: bound must be positive
at java.base/java.util.Random.nextInt(Random.java:388)
at do_it$(java:6)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at jdk.jshell/jdk.jshell.execution.DirectExecutionControl.invoke(DirectExecutionControl.java:209)
at jdk.jshell/jdk.jshell.execution.RemoteExecutionControl.invoke ... tionControlForwarder.commandLoop(ExecutionControlForwarder.java:262)
at jdk.jshell/jdk.jshell.execution.Util.forwardExecutionControl(Util.java:76)
at jdk.jshell/jdk.jshell.execution.Util.forwardExecutionControlAndIO(Util.java:137)
at jdk.jshell/jdk.jshell.execution.RemoteExecutionControl.main(RemoteExecutionControl.java:70)
It would be nice that if a Java exception is throw, it is wrapped in a
JavaException
in Dart and that Dart exception is throw.JavaException
should contain as much information as possible.JavaException
should not refer to any Java object, but copy all information to Dart memory. (The error message, the Java stack trace, etc.) Exceptions should not be common, so we should not worry about the overhead of copying, and it would be good to not have to worry about native resource management at all.JavaException
should have atoString()
that prints the Java error message and stack trace. This will ensure that if we don't catch it we can get some useful information from stderr/stdout.Related issues:
The text was updated successfully, but these errors were encountered: