Reputation: 4109
I have two C++ classes, one for creating a factory and another of the type of object which this factory creates.
Code Snippet:
class A{
};
class Factory
{
public:
A *CreateObject(char *p);
};
Factory *CreateFactory(char *);
So, I want the similar classes on Java side, for Factory
and concrete class A
. But, I am not able to understand that, when I call the CreateFactory
function through JNI
, where should I store the Factory
instance which it returns?
Please help!
Upvotes: 2
Views: 662
Reputation: 298153
You can associate native objects with Java objects by creating a private long
field in the Java class and store the pointer to the native object in that field via JNI.
Upvotes: 3