Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JNA access - Multiple inheritance

843829Oct 22 2009 — edited Oct 25 2009
I am trying access a native library with an interface function which returns a base class pointer.

For example

C implementation *
Class Base {
int basevar;
}

Class Derived1 : public Base {
int derived1;
}

Class Derived2 : public Base {
int derived2;
}

Base myFunction(); // Function which returns base pointer. But it could be of type Derived1 or 2.

I am trying to access it From java using JNA. I have defined mapping files for all the types. But how can I resolve the type at runtime? Is there any possibility to identify this at runtime? (something like instanceof in Java).

Also when we specify the java function, we say it is of type base. But actually it could be of derived. Will JNA automatically do this coversion?
Any suggestions would be helpful.
Regards,
Boby Thomas
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 22 2009
Added on Oct 22 2009
12 comments
412 views