JuliaInterop / JavaCall.jl

Call Java from Julia
http://juliainterop.github.io/JavaCall.jl
Other
118 stars 53 forks source link

Throw error on JavaCall.init if not on root Task and JULIA_COPY_STACKS is not set #105

Closed mkitti closed 4 years ago

mkitti commented 4 years ago

This pull request creates new assertions for JavaCall.init and JavaCall.destroy which will throw an error if JULIA_COPY_STACKS is not set and the current Task is not the root Task.

Without JULIA_COPY_STACKS=yes, JavaCall.init would result in a segmentation fault for me. With the added assertion, I just get an error message now from which the Julia REPL can recover.

The assertion could be expanded for use with the other exported calls such as jcall. Currently trying to execute those from the REPL just results in a wrong return value than a segmentation fault.

mkitti commented 4 years ago

indentation: I will check my Atom / Juno settings. I suspect it introduced an actual tab.

I'm not sure that the assertion is only needed in jvm.jl. It may also be needed for jcall and other functions. For example, if the JVM is started from a programfile by a file like in the tests, jcall would still silently fail at the REPL Julia prompt by returning an incorrect value.

Do you have a recommendation for another file that is included first?