JNI Invocation Problem

Hi @all,

I am using the Invocation Interface to Start an JVM from a C Progam. The Java Programm is only an User Interface to get some Input. The Input the User made is gievn through the a Java class to the C Program. I save the Input in A static int. This Static is read by the C program when the Java Program ends. (

fid = (*env)->GetStaticFieldID(env, cls, "iRet", "I");

*iRet = (int) (*env)->GetStaticIntField(env, cls, fid);

And now According to my Problem. when i call the Gui for more than 10 Times. The Program Chrash with the following message:

#

# An unexpected error has been detected by HotSpot Virtual Machine:

#

# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d7a9cae, pid=3492, tid=3776

#

# Java VM: Java HotSpot(TM) Client VM (1.5.0_08-b03 interpreted mode, sharing)

# Problematic frame:

# V [jvm.dll+0x79cae]

#

Now please give me a hint whats the Problem. Is it in my C code or Java Code? i dont know what to do...

Next thing ist that this behavior appears earlier when i use a complex GUI. I have 2 guis where in each gui are only 1 jTextField and 5 or 6 Labels. when i switch between these there is no Problem. But theres another GUI with a Combobox and 10 jTextFields. The JVM crashes faster when this gui is started.

Thanks for your help....

Message was edited by:

mephisto2

Message was edited by:

mephisto2

[1488 byte] By [mephisto2a] at [2007-10-3 2:27:26]
# 1

Hi Mephisto,

Dont type cast the result of GetStaticIntField. The return datatype is jint and its equivalent to C's long value.

You can verify in jni_md.h available in /jdk/include/win32 dir.

typedef long jint;

You have to be careful while declaring variables.

Because , if the value that the Java int variable hold is greater and if the C program couldnt hold that, you will not get proper results.

I doubt whether this could be a problem.

>

> fid = (*env)->GetStaticFieldID(env, cls, "iRet",

> "I");

> *iRet = (int) (*env)->GetStaticIntField(env, cls,

> fid);

>

DhamoJNIa at 2007-7-14 19:26:30 > top of Java-index,Java HotSpot Virtual Machine,Specifications...