I call the DLL by passing it a functio callback object. One feature is simple printing. Then I have a loop of 100 iterations, just printing an index and a few fingerprints after the loop.
Here is the C code
extern "C" int Start(void* callback(CString))
{
for(int j=0; j<100; j++)
callback(AConvertToString(j));
callback("in Start called from Java");
callback("another line");
}
Here is the Java code
public interface MyDll extends Library{
MyDll INSTANCE = (MyDll) Native.loadLibrary("MyDll",MyDll.class);
public interface MyCallback extends StdCallCallback {
public boolean callback(String msg);
}
public int Start(MyCallback callback);
}
...
MyDll myDll = (MyDll)MyDll.INSTANCE;
myDll.Start(new MyDll.MyCallback() {
public boolean callback(String msg) {
System.out.println(msg);
return true;
}
});
The output is the numbers 0..41 (YES 41 !!! not 99), and then "in Start, called from Java", followed by a terrible failure:
I read a lot (here too), but I cannot find the problem. I am running Java6 JRE. I have 1.5 GB of memory on my machine. DLL is not used by any other process (no concurrency problems).
Thanks Azriel
source
share