Many of the JNI APIs can throw exceptions; however we have not implemented this behavior in most cases yet.
There is an example for how to do this in: jvm.cpp: JVM_FindClassFromCaller & exception.cpp
This relies on JLang-compiled code for creating and throwing Java Exceptions. The downside of this is that a separate function needs to be compiled for each type of exception that the runtime might throw. This is actually probably reasonable since the runtime only throws a handful of exception types (probably fewer than a dozen).
However, we could use our runtime class loading and object creation (see class.cpp: LoadJavaClassFromLib and factory.cpp:CreateJavaObject) to create the exceptions and merely use a JLang-compiled method to throw them. This does require knowing how to call appropriate constructors however, which is a bit of runtime reflection that, as of yet, is unimplemented.
Many of the JNI APIs can throw exceptions; however we have not implemented this behavior in most cases yet.
There is an example for how to do this in: jvm.cpp: JVM_FindClassFromCaller & exception.cpp
This relies on JLang-compiled code for creating and throwing Java Exceptions. The downside of this is that a separate function needs to be compiled for each type of exception that the runtime might throw. This is actually probably reasonable since the runtime only throws a handful of exception types (probably fewer than a dozen).
However, we could use our runtime class loading and object creation (see class.cpp: LoadJavaClassFromLib and factory.cpp:CreateJavaObject) to create the exceptions and merely use a JLang-compiled method to throw them. This does require knowing how to call appropriate constructors however, which is a bit of runtime reflection that, as of yet, is unimplemented.