1、C函数
typedef int(*func)(int a, int b);
int init(func c) {
return (*c)(1, 2);
}
2、Java
public interface JNA extends Library {
JNA instance = (JNA ) Native.loadLibrary("dllName",JNA.class);
public interface Func extends Callback{
int invoke(int a,int b);
}
int init(Func c);
}
public class JNATest{
static {
System.setProperty("jna.library.path","xxx");
}
public static void main(String[] args) {
int result= JNA.instance.init(new JNA.Func() {
@Override
public int invoke(int a, int b) {
System.out.println(a * b);
return a*b;
}
});
System.out.println(result);
}
}