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!

JVM throws ExceptionCode=0xe0434f4d when JNI is used to call a func in DLL

843829Mar 13 2006 — edited Mar 23 2007
Hi,

I am using JNI to access a API in the dll(which is C program). Below is the java code that I use.

-------------------------------MY JAVA CODE --------------------------------------------
package com.mot.api123;

import java.io.*;
import java.util.*;
import java.text.*;

/**
 * A class that handles the details of a virtual connection.
 * Holds the state of the connection.
 */
public class VirtualConnection extends Connection {
	
                     boolean open = false;
	
	public VirtualConnection() {
			super();
		
	}

	/**
	 * Attempts to open a virtual pipe connectionno longer need it.
	 */
	public void openConnection() throws ConnectionException {
		
		open = open_service();		
				
	}

public native boolean open_service();
	
	static
	{
	System.load("D:\\my_project\\api123_6\\api123_6\\dll\\com_mot_api123_VirtualConnection\\Debug\\com_mot_api123_VirtualConnection.dll");	
}
}
-----------------------END OF MY JAVA CODE -----------------------------------------


And my native code was this:

-------------------------MY NATIVE CODE -----------------------------------------------
#include "stdafx.h"
#include <stdlib.h>
#include <string.h>
#include <Windows.h>
#include "MotSAPIC.h"
#include <jni.h>
#include "com_mot_api123_VirtualConnection.h"

// number of "phones"
#define PHONE_COUNT 1

// virutal pipes
struct MotPhoneIOStdVirtualPipe (*gpsStdPipe[PHONE_COUNT]);

// closure allowed by "phones"
BOOLEAN canClose[PHONE_COUNT];

typedef long (*importFunction0)(const char*,MotPhoneIOPhone**,MotSErrorInfo*);


JNIEXPORT jboolean JNICALL Java_com_mot_api123_VirtualConnection_open_1service(JNIEnv * env, jobject obj)
{
	// "phone" handles
	struct MotPhoneIOPhone(* psPhone[PHONE_COUNT]);

	struct MotSErrorInfo errorInfo;

	HINSTANCE hinstLib0, hinstLib1;
	importFunction0 func0;
	
	hinstLib0 = LoadLibrary("C:\\Program Files\\Freescale Cellular Platform\\Tools\\bin\\MotSAPIC.dll");
	hinstLib1 = LoadLibrary("C:\\Program Files\\Freescale Cellular Platform\\Tools\\bin\\MotPhoneIOC.dll");

	if (hinstLib0 != NULL && hinstLib1 != NULL)
    	{
        	func0 = (importFunction0)GetProcAddress(hinstLib0, "MotSAPIConnect_ConnectionMgrGUI");
				
    	}
	else
	{
		printf("ERROR: unable to load Phone IO's DLLs");
	}

	if (func0 != NULL)
    	{
	// for each "phone" handle
	for(int i = 0; i < PHONE_COUNT; i++)
	{
		psPhone[i] = 0;
		gpsStdPipe[i] = 0;
		canClose[i] = TRUE;
		const char* szPhoneNiceName = "Generic serial phone #1";
		
		printf(" I am here\n");
		printf("%s", szPhoneNiceName);
		// connect the "phone" using PhoneIO Connection Manager
		func0(szPhoneNiceName, &psPhone, &errorInfo);

printf(" I am not here");

if (psPhone[i] != 0)
{

printf("success");

// "phone" connected

}
// else closure allowed
}
}
else
{
printf("ERROR: unable to find the Phone IO's DLL function");
}


return true;
}


--------------------------END OF MY NATIVE CODE-----------------------------------
I am able to see the "I am here" string on the display. But whenever the control goes to the func0, the JVM throws error (ExceptionCode=0xe0434f4d ) and exits.

The same code executes fine when I run it directly using the int main (int argc, char* argv[]) . But when I try to call the func0 using Java , it fails.

I have pasted the error below.

----------------------------------------------ERROR FILE ---------------------------------#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# Internal Error (0xe0434f4d), pid=3760, tid=3220
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_06-b05 mixed mode, sharing)
# Problematic frame:
# C [kernel32.dll+0x1eb33]
#

--------------- T H R E A D ---------------

Current thread (0x00036a48): JavaThread "main" [_thread_in_native, id=3220]

siginfo: ExceptionCode=0xe0434f4d

Registers:
EAX=0x0007f1a4, EBX=0x00000001, ECX=0x000af9c8, EDX=0x00000000
ESP=0x0007f1a0, EBP=0x0007f1f4, ESI=0x00000000, EDI=0x00000000
EIP=0x7c81eb33, EFLAGS=0x00000246

Top of Stack: (sp=0x0007f1a0)
0x0007f1a0: 000af9c8 e0434f4d 00000001 00000000
0x0007f1b0: 7c81eb33 00000000 791b9d02 035a1160
0x0007f1c0: 07d15208 000af9c8 0007f1e0 791be271
0x0007f1d0: 000ac7a8 00000002 07d15208 00000000
0x0007f1e0: 0007f1f0 791be286 000ac7a8 07d15208
0x0007f1f0: 0007f200 0007f24c 7921020d e0434f4d
0x0007f200: 00000001 00000000 00000000 000af9c8
0x0007f210: 0007f25c 00000001 7c81eb33 0007eed4

Instructions: (pc=0x7c81eb33)
0x7c81eb23: 8d 7d c4 f3 a5 5f 8d 45 b0 50 ff 15 04 15 80 7c
0x7c81eb33: 5e c9 c2 10 00 85 ff 0f 8e e6 d0 fe ff 8b 55 fc


Stack: [0x00040000,0x00080000), sp=0x0007f1a0, free space=252k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [kernel32.dll+0x1eb33]
C [mscorwks.dll+0x6020d]
C [mscorwks.dll+0x60190]
C [mscorwks.dll+0x60144]
C [mscorwks.dll+0xa6dcb]
C [mscorwks.dll+0x26a7e]
C 0x000affee
j com.mot.api123.VirtualConnection.open_service()Z+0
j com.mot.api123.VirtualConnection.openConnection()V+2
j com.mot.api123.Message.<init>()V+19
j com.mot.api123.COMServer.main([Ljava/lang/String;)V+95
v ~StubRoutines::call_stub
V [jvm.dll+0x845a9]
V [jvm.dll+0xd9317]
V [jvm.dll+0x8447a]
V [jvm.dll+0x8b44a]
C [java.exe+0x14c5]
C [java.exe+0x64dd]
C [kernel32.dll+0x16d4f]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j com.mot.api123.VirtualConnection.open_service()Z+0
j com.mot.api123.VirtualConnection.openConnection()V+2
j com.mot.api123.Message.<init>()V+19
j com.mot.api123.COMServer.main([Ljava/lang/String;)V+95
v ~StubRoutines::call_stub

--------------- P R O C E S S ---------------

Java Threads: ( => current thread )
0x02f124d8 JavaThread "GC Daemon" daemon [_thread_blocked, id=2996]
0x00acfcf8 JavaThread "RMI Reaper" [_thread_blocked, id=2068]
0x02f12d08 JavaThread "Timer-0" daemon [_thread_blocked, id=2576]
0x00acbef8 JavaThread "RMI TCP Accept-0" daemon [_thread_in_native, id=2660]
0x00a6f340 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=3428]
0x00a6e040 JavaThread "CompilerThread0" daemon [_thread_blocked, id=3564]
0x00a6d218 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=3004]
0x00a480b8 JavaThread "Finalizer" daemon [_thread_blocked, id=2200]
0x0003fba8 JavaThread "Reference Handler" daemon [_thread_blocked, id=1460]
=>0x00036a48 JavaThread "main" [_thread_in_native, id=3220]

Other Threads:
0x00a682b0 VMThread [id=2700]
0x00a6ce40 WatcherThread [id=2352]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
def new generation total 576K, used 267K [0x22a70000, 0x22b10000, 0x22f50000)
eden space 512K, 39% used [0x22a70000, 0x22aa2ec0, 0x22af0000)
from space 64K, 100% used [0x22b00000, 0x22b10000, 0x22b10000)
to space 64K, 0% used [0x22af0000, 0x22af0000, 0x22b00000)
tenured generation total 1408K, used 123K [0x22f50000, 0x230b0000, 0x26a70000)
the space 1408K, 8% used [0x22f50000, 0x22f6ef18, 0x22f6f000, 0x230b0000)
compacting perm gen total 8192K, used 303K [0x26a70000, 0x27270000, 0x2aa70000)
the space 8192K, 3% used [0x26a70000, 0x26abbec8, 0x26abc000, 0x27270000)
ro space 8192K, 66% used [0x2aa70000, 0x2afcbcc0, 0x2afcbe00, 0x2b270000)
rw space 12288K, 46% used [0x2b270000, 0x2b812060, 0x2b812200, 0x2be70000)

Dynamic libraries:
0x00400000 - 0x0040c000 C:\Program Files\Java\jdk1.5.0_06\bin\java.exe
0x7c900000 - 0x7c9b0000 C:\WINNT\system32\ntdll.dll
0x7c800000 - 0x7c8f4000 C:\WINNT\system32\kernel32.dll
0x77dd0000 - 0x77e6b000 C:\WINNT\system32\ADVAPI32.dll
0x77e70000 - 0x77f01000 C:\WINNT\system32\RPCRT4.dll
0x77c10000 - 0x77c68000 C:\WINNT\system32\MSVCRT.dll
0x6d6e0000 - 0x6d874000 C:\Program Files\Java\jdk1.5.0_06\jre\bin\client\jvm.dll
0x77d40000 - 0x77dd0000 C:\WINNT\system32\USER32.dll
0x77f10000 - 0x77f57000 C:\WINNT\system32\GDI32.dll
0x76b40000 - 0x76b6d000 C:\WINNT\system32\WINMM.dll
0x6d2f0000 - 0x6d2f8000 C:\Program Files\Java\jdk1.5.0_06\jre\bin\hpi.dll
0x76bf0000 - 0x76bfb000 C:\WINNT\system32\PSAPI.DLL
0x6d6b0000 - 0x6d6bc000 C:\Program Files\Java\jdk1.5.0_06\jre\bin\verify.dll
0x6d370000 - 0x6d38d000 C:\Program Files\Java\jdk1.5.0_06\jre\bin\java.dll
0x6d6d0000 - 0x6d6df000 C:\Program Files\Java\jdk1.5.0_06\jre\bin\zip.dll
0x0ffd0000 - 0x0fff8000 C:\WINNT\system32\rsaenh.dll
0x769c0000 - 0x76a73000 C:\WINNT\system32\USERENV.dll
0x5b860000 - 0x5b8b4000 C:\WINNT\system32\netapi32.dll
0x6d530000 - 0x6d543000 C:\Program Files\Java\jdk1.5.0_06\jre\bin\net.dll
0x71ab0000 - 0x71ac7000 C:\WINNT\system32\WS2_32.dll
0x71aa0000 - 0x71aa8000 C:\WINNT\system32\WS2HELP.dll
0x71a50000 - 0x71a8f000 C:\WINNT\System32\mswsock.dll
0x76f20000 - 0x76f47000 C:\WINNT\system32\DNSAPI.dll
0x76fb0000 - 0x76fb8000 C:\WINNT\System32\winrnr.dll
0x76f60000 - 0x76f8c000 C:\WINNT\system32\WLDAP32.dll
0x76fc0000 - 0x76fc6000 C:\WINNT\system32\rasadhlp.dll
0x662b0000 - 0x66308000 C:\WINNT\system32\hnetcfg.dll
0x71a90000 - 0x71a98000 C:\WINNT\System32\wshtcpip.dll
0x10000000 - 0x10033000 D:\my_project\api123_6\api123_6\dll\com_mot_api123_VirtualConnection\Debug\com_mot_api123_VirtualConnection.dll
0x03470000 - 0x03492000 C:\Program Files\Freescale Cellular Platform\Tools\bin\MotSAPIC.dll
0x79170000 - 0x79196000 C:\WINNT\system32\mscoree.dll
0x034b0000 - 0x034d4000 C:\Program Files\Freescale Cellular Platform\Tools\bin\MotCommonC.dll
0x77f60000 - 0x77fd6000 C:\WINNT\system32\SHLWAPI.dll
0x791b0000 - 0x79412000 C:\WINNT\Microsoft.NET\Framework\v1.1.4322\mscorwks.dll
0x7c340000 - 0x7c396000 C:\WINNT\Microsoft.NET\Framework\v1.1.4322\MSVCR71.dll
0x79040000 - 0x79085000 C:\WINNT\Microsoft.NET\Framework\v1.1.4322\fusion.dll
0x7c9c0000 - 0x7d1d5000 C:\WINNT\system32\SHELL32.dll
0x773d0000 - 0x774d2000 C:\WINNT\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\comctl32.dll
0x5d090000 - 0x5d127000 C:\WINNT\system32\comctl32.dll
0x79780000 - 0x79980000 c:\winnt\microsoft.net\framework\v1.1.4322\mscorlib.dll
0x79980000 - 0x79ca6000 c:\winnt\assembly\nativeimages1_v1.1.4322\mscorlib\1.0.5000.0__b77a5c561934e089_6300a9df\mscorlib.dll
0x79430000 - 0x7947c000 C:\WINNT\Microsoft.NET\Framework\v1.1.4322\MSCORJIT.DLL
0x03790000 - 0x03810000 C:\Program Files\Freescale Cellular Platform\Tools\bin\MotPhoneIOC.dll
0x79510000 - 0x79523000 C:\WINNT\Microsoft.NET\Framework\v1.1.4322\mscorsn.dll

VM Arguments:
java_command: com.mot.api123.COMServer virtual
Launcher Type: SUN_STANDARD

Environment Variables:
CLASSPATH=C:\JET\lib;C:\Program Files\Freescale Cellular Platform\Tools\bin;C:\Program Files\Freescale Cellular Platform\Tools\lib;
PATH=C:\Perl\bin\;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\Program Files\doxygen\bin;C:\Program Files\Java\jdk1.5.0\bin;C:\Program Files\Java\jdk1.5.0\include;C:\Program Files\Java\jdk1.5.0\include\win32;C:\JET\lib;C:\Program Files\Freescale Cellular Platform\Tools\bin;C:\Program Files\Freescale Cellular Platform\Tools\lib;C:\Program Files\Freescale Cellular Platform\Tools\include;D:\my_project\api123_6\api123_6\dll;C:\Program Files\Microsoft Visual Studio\VC98\Bin;
USERNAME=shakeela
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 11 Stepping 1, GenuineIntel



--------------- S Y S T E M ---------------

OS: Windows XP Build 2600 Service Pack 2

CPU:total 1 family 6, cmov, cx8, fxsr, mmx, sse

Memory: 4k page, physical 522736k(198368k free), swap 886068k(557072k free)

vm_info: Java HotSpot(TM) Client VM (1.5.0_06-b05) for windows-x86, built on Nov 10 2005 11:12:14 by "java_re" with MS VC++ 6.0

-----------------------END OF ERROR FILE ----------------------------------

Can anyone tell me whether there is any other way of calling my function in the DLL?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 20 2007
Added on Mar 13 2006
3 comments
448 views