Skip to content
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

Throw Exceptions in JNI/JVM API #24

Open
dz333 opened this issue Aug 22, 2018 · 0 comments
Open

Throw Exceptions in JNI/JVM API #24

dz333 opened this issue Aug 22, 2018 · 0 comments

Comments

@dz333
Copy link
Collaborator

dz333 commented Aug 22, 2018

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.

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

No branches or pull requests

1 participant