irus
07/20/2019, 11:07 AM#include <jvmti.h>
#include <stdio.h>
JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM* vm, char* options, void* reserved) {
return 0;
}
// SIGSEGV
@CName("Agent_OnLoad")
fun Agent_OnLoad(
vm: CValuesRef<JavaVMVar>?,
options: CValuesRef<ByteVar>?,
reserved: CValuesRef<*>?
:disappointed: jint {
println("Agent: Hello, World!")
return 0
}
// ok
@CName("Agent_OnLoad")
fun Agent_OnLoad(
vm: NativePtr,
options: NativePtr,
reserved: NativePtr
:disappointed: jint {
println("Agent: Hello, World!")
return 0
}
napperley
07/21/2019, 12:00 AMirus
07/21/2019, 12:11 PMolonho
07/22/2019, 1:05 PMCPointer<JavaVMVar>
and such is right type here.irus
07/22/2019, 8:40 PMcinterop
generated CValuesRef<JavaVMVar>?
here. Headers from jdk11irus
07/22/2019, 9:09 PMirus
07/23/2019, 9:01 AMolonho
07/23/2019, 11:02 AMCPointer
is subclass of CValuesRef
, and in this case it shall be used. cinterop
is not related to the problem here, as it provides bindings to the C library from Kotlin, and in your case you produce C library from Kotlin source code.