invoking package-private constructor from native code

Oskar Liljeblad osk@hem.passagen.se
Sat Sep 16 02:49:00 GMT 2000


Hi!
In short:
How do I get the jmethodID for a certain package-private
constructor?
In detail:
In Gnome-GCJ it is necessary to invoke a package-private constructor
in a number of classes. This is done when a new java object must be
created for a previously unseen (to java code) native object. I have
solved this so far by generating code like this:
 ..
 switch (type) {
 case 1: return new gnu::gtk::GtkObject((gnu::gcj::RawData*) data);
 case 2: return new gnu::gtk::Widget((gnu::gcj::RawData*) data);
 ..
The reason the constructor that takes the RawData argument is
package-private, is simply because it shouldn't be used from
user code.
In the GLib 1.3/2.0 version of Gnome-GCJ, I want to make things more
dynamic. From a jclass reference I wish to be able to create an
instance using a package-private constructor. So I figured I can use
_Jv_CallAnyMethodA for this. But I need a jmethodID of the
constructor. How do I get that?
Or is there some other way to do this instantiation?
Oskar Liljeblad (osk@hem.passagen.se)


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /