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!

How to map C++ abstract class to java class

843829Jun 26 2001 — edited Jun 27 2001
<pre>
Hi,
I have an abstract model in C++. That is I have one abstract base class (Attribute)
and few derived classes (Number,String,Boolean...etc) from it. (I call this base class
has abstract, bcoz it has got one pure virtual function.)
The Attribute(abstract) class has got one pure virtual function( getType() ) and few
set/get methods which are implemented in Attribute class itself. All the derived classes
are implementing the virtual function 'getType()' and returning their type. Derived classes
also have got few get/set methods.
I have one more c++ class called parser, It uses all the above classes in it. In this class
depending upon the attributetype I am doing some operations.

For this I need to write a JNI wrappers so that the existing Java GUI could use this
attributeModel.

Few questions I have;

1. How to map the abstract base class(in C++) 'attribute' to java class?(or interface!)
-since the c++ class has got pure virtual function in it, we can't create the instance of it.

2. How to map the derived classes(from attribute base class) from c++ to java classes?
-should I use something like,
public abstract class Attribute
{
//declare all the native methods here..

}

public class Number extends Attribute
{
// declare all native methods here..
}


I am new to JNI. Anykind of help will be appreciated.

Thanks in advance
siddupr
</pre>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 25 2001
Added on Jun 26 2001
2 comments
367 views