I am writing a program in Java and I would like to create a native interface for a library written in C++. But I am confused with how to write a native method declaration for a constructor.
Say I have this C++ class and constructor:
template <class _Tp,class _Val>
class Arbitrator
{
public:
Arbitrator();
}
How would I write a native method declaration?
This is what I'm doing so far: package hbot.proxy.bwsal.arbitrator;
public class Arbitrator<Tp, Val>
{
public native Arbitrator Arbitrator();
}
Is this how I would do this?
Thanks
Create native method. For example, private native void init()
. Call it from constructor in Java. In it's JNI implementation access C++ class as needed.
You will have to use JNI generated method signatures anyway, so you can't map directly Java class to C++ class if that's what you wanted to do.