Help with VM Crash using the foreign linker

Duncan McLean duncan.mclean at gmail.com
Fri May 14 20:20:21 UTC 2021


Hello,

I'm sorry if this isn't the right place to be asking for help with the
Foreign Linker, please let me know where I should direct this question if
I'm in the wrong place.

I'm using the Foreign Linker API in a project and experiencing an odd
result. The project is available here:

https://github.com/boulder-on/JPassport

The way my code works is:

Give JPassport an interface class that you would like to use with the
Foreign Linker. JPassport writes the java code required to call the foreign
library, compiles the code, and hands back an object that implements the
interface and calls the foreign library. (I'm trying to mimic JNA like
behaviour in terms of just providing an interface)

The problem I'm seeing is in my test cases for passing data to functions
requiring C structures

test_jpassport/src/jpassport/test/structs/TestUsingStructs

For some reason, any call to the foreign library causes the VM to crash.
However, this only happens if I invoke the compiler. The 3 scenarios I've
tested are:

1. Normal operation: write out a .java file, use JavaCompiler to compile,
use URLClassloader to load the compiled class, call a foreign method ->
crash.

2. Skip compiling: write out a .java file, do not compile, use URL
Classloader to load the class compiled in the previous test, call a foreigh
method -> no crash, the call works perfectly.

3. Compile manually: Take the java code written out in step 1, add it to my
project, compile, run the program, call a foreign method -> no crash

I've tested this with the most recent JDK 16, and the most recent JDK 17
early access builds. My other test cases for passing primitives and arrays
all work properly with the "normal operation".

I'm testing using 64 bit VM's on Windows 10. I've attached one of the crash
logs for further details on my set-up.

Is there something I'm doing wrong? Please let me know if there are any
other details I can provide or if there is any other way I can help
diagnose what's going on.

Thank you for your help,
Duncan


More information about the panama-dev mailing list