Unexpected Signal : EXCEPTION_ACCESS_VIOLATION

Can anyone help me in this error.

E:\JNI\Ex5JNI>java -hotspot -Djava.library.path=.\EX5JNI\FixedStatic_Interface\D

ebug JNIServer

calling FixedStatic

INSIDE TRY

Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x6d4408d9

Function name=JVM_EnableCompiler

Library=D:\jdk1.3.1\jre\bin\hotspot\jvm.dll

Current Java thread:

at JNIServer.fixedStatic(Native Method)

at JNIServer.main(JNIServer.java:58)

Dynamic libraries:

0x00400000 - 0x00405000 D:\jdk1.3.1\bin\java.exe

0x77F80000 - 0x77FFB000 C:\WINNT\System32\ntdll.dll

0x77DB0000 - 0x77E0B000 C:\WINNT\system32\ADVAPI32.dll

0x77E80000 - 0x77F35000 C:\WINNT\system32\KERNEL32.DLL

0x77D40000 - 0x77DB0000 C:\WINNT\system32\RPCRT4.DLL

0x78000000 - 0x78046000 C:\WINNT\system32\MSVCRT.dll

0x6D420000 - 0x6D4EF000 D:\jdk1.3.1\jre\bin\hotspot\jvm.dll

0x77E10000 - 0x77E74000 C:\WINNT\system32\USER32.dll

0x77F40000 - 0x77F7C000 C:\WINNT\system32\GDI32.DLL

0x77570000 - 0x775A0000 C:\WINNT\System32\WINMM.dll

0x6D220000 - 0x6D227000 D:\jdk1.3.1\jre\bin\hpi.dll

0x6D3B0000 - 0x6D3BD000 D:\jdk1.3.1\jre\bin\verify.dll

0x6D250000 - 0x6D266000 D:\jdk1.3.1\jre\bin\java.dll

0x6D3C0000 - 0x6D3CD000 D:\jdk1.3.1\jre\bin\zip.dll

0x10000000 - 0x10165000 E:\JNI\Ex5JNI\EX5JNI\FixedStatic_Interface\Debug

\FixedStatic_Interface.dll

0x77B50000 - 0x77BD9000 C:\WINNT\system32\COMCTL32.dll

0x77800000 - 0x7781D000 C:\WINNT\System32\WINSPOOL.DRV

0x76B30000 - 0x76B6E000 C:\WINNT\system32\comdlg32.dll

0x77C70000 - 0x77CBA000 C:\WINNT\system32\SHLWAPI.DLL

0x782F0000 - 0x78532000 C:\WINNT\system32\SHELL32.DLL

0x77920000 - 0x77943000 C:\WINNT\system32\imagehlp.dll

0x72A00000 - 0x72A2D000 C:\WINNT\system32\DBGHELP.dll

0x690A0000 - 0x690AB000 C:\WINNT\System32\PSAPI.DLL

Local Time = Mon Oct 15 15:05:41 2001

Elapsed Time = 0

#

# HotSpot Virtual Machine Error : EXCEPTION_ACCESS_VIOLATION

# Error ID : 4F530E43505002CC

# Please report this error at

# http://java.sun.com/cgi-bin/bugreport.cgi

#

# Java VM: Java HotSpot(TM) Client VM (1.3.1-b24 mixed mode)

#

# An error report file has been saved as hs_err_pid1784.log.

# Please refer to the file for further information

[2437 byte] By [DeepaJ] at [2007-9-26 9:40:25]
# 1
Most of the time that means you have a memory problem in your JNI code (or a 3rd party library you are using.)Rarely it means there is a bug in the JVM that you are using.You would have to localize the problem and then present a code sample to get any more help.
jschell at 2007-7-1 21:12:30 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2

Here is my JNI file. Can u help me? Thanks a lot.

#include <stdio.h>

#include "Main.h"

JNIEXPORT jdouble JNICALL Java_Main_calculateAreaOfCircle(JNIEnv *env, jobject obj, jdouble radius)

{

const jdouble PI = 3.1415926535;

jdouble area = PI * (radius * radius);

return area;

}

JNIEXPORT void JNICALL Java_Main_calculate

(JNIEnv *env, jobject jThis, jobject dim, jobject jbox){

jclass cls;

jclass result;

jfieldID fid1, fid2,fid3, fid4,fid5;

jfieldID red_f, blue_f, green_f;

jstring shapeStr;

//jmethodID mid;

int value1;

int value2;

int area;

int volume;

const char *str;

//Getting values from Java and parsing it to C++

cls = env->GetObjectClass(dim);

fid1 = env->GetFieldID(cls, "l", "I");

fid2 = env->GetFieldID(cls,"b", "I");

fid5 = env->GetFieldID(cls, "shape","Ljava/lang/String;" );

shapeStr=(jstring)env->GetObjectField(dim, fid5);

//mid = env->GetMethodID(cls, "divByTwo", "()V");

value1 = env->GetIntField(dim, fid1);

value2 = env->GetIntField(dim, fid2);

str= env->GetStringUTFChars(shapeStr, NULL);

if(str==NULL){ printf("OUT of Memmory "); return; }

printf(" String value =\"%s\"\n", str);

env->ReleaseStringUTFChars(shapeStr, str);

//Calculation

area=value1*value2*6;

volume=value1*value2*value1;

//Setting Result

result= env->GetObjectClass(jbox);

fid3 = env->GetFieldID(result,"area", "I");

fid4 = env->GetFieldID(result,"volume", "I");

env->SetIntField(jbox, fid3, area);

env->SetIntField(jbox, fid4, volume);

jfieldID fid6 =env->GetFieldID(result,"ColorArray", "[ColorArray");

jobject colorResult_obj= env->GetObjectField(jbox,fid6);

jclass color_class =env->FindClass("ColorArray");

jmethodID mid=env->GetMethodID(color_class, "<init>", "()V");

jobject array_obj=env->NewObject(color_class,mid);

jobjectArray color_obj_array;

red_f = env->GetFieldID(color_class,"red", "I");

blue_f = env->GetFieldID(color_class,"blue", "I");

green_f= env->GetFieldID(color_class,"green", "I");

jint red_j, blue_j, green_j;

color_obj_array = (jobjectArray)env->NewObjectArray(1,color_class,array_obj);

red_j = 10;

blue_j= 20;

green_j= 30;

env-> SetIntField(array_obj,red_f,red_j);

env-> SetIntField(array_obj,blue_f,blue_j);

env-> SetIntField(array_obj,green_f,green_j);

env->SetObjectArrayElement(color_obj_array,1,array_obj);

env->SetObjectField(colorResult_obj, fid6, color_obj_array);

}

java pgm follows

class Main

{

static

{

System.loadLibrary("MathFuncsImp");

//System.loadLibrary("FixedStatic_Interface");

}

public native double calculateAreaOfCircle(double radius);

public native void calculate(Dim dim, Jbox jbox);

public static void main(String[] args)

{

Jbox ResultJbox = new Jbox();

Main mf = new Main();

int radius = 10;

double area = mf.calculateAreaOfCircle(radius);

System.out.println("Area of circle with radius " + radius + " is " + area);

int l = 10;

int b = 10;

Dim dim = new Dim(l,b,"Square");

mf.calculate(dim, ResultJbox);

int area1 = ResultJbox.area;

int volume = ResultJbox.volume;

ColorArray[] colArray = ResultJbox.colArray;

System.out.println("Area of Box with length " + l +

" and Breadth" + b +" --> "+area1+" and Volume is -->"+volume+"ColorArray -->"+colArray);

}

}

DeepaJ at 2007-7-1 21:12:30 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3
You have a lot of code that you do absolutely no error checking on.For examplecls = env->GetObjectClass(dim);How do you know this line returns a valid value?Add error checking.
jschell at 2007-7-1 21:12:30 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 4

Also: NewStringUTF takes an input parameter that is filled by the runtime system indicating whether or not the string was copied as part of the conversion.

You don't know, because you just pass a NULL argument.

You should be checking to see if there was a copy done before you call Reelease. Otherwise, who knows what you are releasing?

bschauwe at 2007-7-1 21:12:30 > top of Java-index,Java HotSpot Virtual Machine,Specifications...