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 convert void pointer from c/c++ to java Object ?

843829Nov 28 2002 — edited Nov 29 2002
I encountered great difficulties in JNI.

I have a java class,
public class GeneralName
{
public int nametype = 0;
public Object namevalue = null;

public GeneralName() {}
public GeneralName(GeneralName gname)
{
setGeneralName(gname.nametype, gname.namevalue);
}
public void setGeneralName(int nType, Object valueobj)
{
nametype = nType;
if ( nType == 0 )
{
String strname = (String)valueobj
namevalue = new String(strname);
}
if ( nType == 1 )
{
LV lvname = (LV)valueobj;
namevalue = new LV(lvname);
}
}
}
and I have a c/c++ structure,
typedef struct GeneralName {
int ntype;
void *pnamevalue;
} GeneralName;

In JNI, I don't know how to convert void pointer to java Object?
Is there anyone can help me?
thanks in advance, and best regards.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 27 2002
Added on Nov 28 2002
1 comment
514 views