paurik 0 Newbie Poster

ERROR:
All the code compiles without any errors or warnings. On Calling the native method FindOs from Java code, i get the following error:

#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x1026f8e0, pid=3484, tid=2192
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_11-b03 mixed mode, sharing)
# Problematic frame:
# C  [MSVCR90D.dll+0x6f8e0]
#
# An error report file with more information is saved as hs_err_pid3484.log
#
# If you would like to submit a bug report, please visit:
#   [url]http://java.sun.com/webapps/bugreport/crash.jsp[/url]
#

VC++ code:
/*Native method FindOs*/

jclass OSINFO = env->FindClass("OSInfo");
jmethodID OSIConstructor = env->GetMethodID(OSINFO, "OSInfo", "V");
jfieldID OSName = env->GetFieldID(OSINFO, "OSName", "Ljava/lang/String;");
jfieldID SystemDrive = env->GetFieldID(OSINFO, "SystemDrive", "Ljava/lang/String;");
jfieldID Processes = env->GetFieldID(OSINFO, "Processes", "L");
jobject OSINFOobj = env->NewObject(OSINFO, OSIConstructor);

char* OSN="Hello";
strcat_s(OSN,strlen(OSN)+1," ");
char* temp="GOOD EVENING";
strcat_s(OSN,strlen(OSN)+strlen(temp),temp);
env->SetObjectField(OSINFOobj, OSName, env->NewStringUTF(OSN));

return OSINFOobj;

Java class OSInfo is as described below:

public class OSInfo{

    public String OSName;
    public String SystemDrive;
    public int Processes;

    public OSInfo(){}

}

IF anyone knows why we get this error and how to solve it then pls reply.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.