My title may not make sense which is probably why I can't find a solution to the problem. I am lacking the vocabulary to properly search for it. Basically my problem is that I am implementing a c++ class with some virtual functions in Java through JNI. This works fine except for the fact that the parameters that are passed into the virtual function create new java objects each time and fill up the garbage collector.
class b2ContactListener
{
public:
virtual ~b2ContactListener() {}
/// Called when two fixtures begin to touch.
virtual void BeginContact(b2Contact* contact){}
};
As you can see the BeginContact method has the parameter b2Contact *. In Java this creates a new Contact object everytime the virtual method is called. Is there a way to simply pass a reference to Java through JNI? Even if you can give me the term I'm looking for that would be great.