This is the mail archive of the java-discuss@sources.redhat.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

invoking package-private constructor from native code


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)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]