This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNI: How to introspect an inner class

 
Guy Roberts
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a C JNI function, I need to construct an instance of an inner class. My problem occurs when I try to get the method ID for the constructor.
The class I want to construct in C is called Wrapper, and it looks like this;
public class Maths {
static { System.loadLibrary("Maths"); }
// Native method
public native void nativeM(Wrapper data );
public class Wrapper {
public Wrapper(){};
// Attributes used by the native method
// go here
}
}
If I call GetMethodID() as follows I get an exception saying "no such method".
jmethodID mid = (*env)->GetMethodID (env,
mathsClass,
"<init>",
"()V");
I suppose it must be something to do with the quiky way that inner classes need to be constructed, but can't find anyhting on the Internet about it.
Six cubic meters of sea water to who ever can help (winner collects)
Thanks,
Guy.
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I distinctly remember reading somewhere that this was not in any way supported through JNI -- but I can't remember distinctly where I read it. I'll go digging, see if I can find the reference.
Long story short, though, I'm pretty sure you're barking up the wrong tree.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic