Hi Leute und besonders JNI experten:
ich bräuchte mal Hiiiilfe; stricke gerade ein Interface zu einer vorhandenen DLL.
Setze Jbuilder2005 (free edition) ein; runtime ist 1.5 7. JBuilder hat die 1.4 als JRE, hab das Projekt aber auf 1.5 explizit umgestellt nachdem vorher die printfs vom native code gar nicht kamen..
Nun folgendes Problem, vielleicht bin ich aber irgendwo auch nur blind:
JNI -> native code - tickt schon ganz gut (ein bisschen), aber folgende C routine treibt mich zum Wahnsinn:
.
.
static byte year = 0;
static byte month = 0;
static byte day = 0;
static byte hour = 0;
static byte minute = 0;
.
.
JNIEXPORT jint JNICALL Java_easyCOM_ReadClock
(JNIEnv *env, jobject self, jbyte jnet_id)
{
int result = -1;
byte err = 0;
lasterr = 0;
checkEasyInit(env);
result = (pRead_Clock)(jnet_id, &year, &month, &day, &hour, &minute);
if (result) {
err = (byte)year;
lasterr = err;
(*env)->SetIntField(env, self, fldid_lasterr, err);
}
printf("C Got time\n");
//printf ("C ReadClock year :%d\n", year);
//printf ("C ReadClock month:%d\n", month);
//printf ("C ReadClock day :%d\n", day);
//printf ("C ReadClock hour :%d\n", hour);
//printf ("C ReadClock min :%d\n", min);
return (jint)result;
}
Und zwar bekomme ich exceptions von der JVM wenn ich versuche in der methode printf auszugeben. An anderen Stellen funktioniert es problemlos zu printf'en. Die printfs tun es sogar - also commen an - und die Datums-werte stimmen auch. Nachfolgend der errorlog.
Many thanks ahead!
tb
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# EXCEPTION_ILLEGAL_INSTRUCTION (0xc000001d) at pc=0x0006fa14, pid=2576, tid=3680
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_07-b03 mixed mode, sharing)
# Problematic frame:
# C 0x0006fa14
#
--------------- T H R E A D ---------------
Current thread (0x00357aa8): JavaThread "main" [_thread_in_native, id=3680]
siginfo: ExceptionCode=0xc000001d
Registers:
EAX=0x10212d90, EBX=0x26a75798, ECX=0xdf72b3e8, EDX=0x10312d30
ESP=0x0006fa28, EBP=0xfffffffe, ESI=0x26a75798, EDI=0x00357aa8
EIP=0x0006fa14, EFLAGS=0x00010206
Top of Stack: (sp=0x0006fa28)
0x0006fa28: 0006fa28 26a75798 0006fa58 26a76570
0x0006fa38: 00000000 26a75798 0006fa54 0006fa78
0x0006fa48: 00a729cf 00000000 00a76449 00000000
0x0006fa58: 22aa2880 0006fa5c 26a75f4a 0006fa84
0x0006fa68: 26a76570 00000000 26a75f58 0006fa80
0x0006fa78: 0006faa4 00a729cf 00000000 22aa2880
0x0006fa88: 0006fa88 26a748cf 0006fac4 26a74b20
0x0006fa98: 00000000 26a74960 0006fac4 0006fad8
Instructions: (pc=0x0006fa14)
0x0006fa04: 10 00 00 00 10 00 00 00 85 1f 08 00 50 ec be 06
0x0006fa14: 28 67 22 01 3c 00 00 00 00 00 00 00 10 bb 3d 15
Stack: [0x00030000,0x00070000), sp=0x0006fa28, free space=254k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C 0x0006fa14
[error occurred during error reporting, step 120, id 0xc0000005]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j easyCOM.ReadClock(B)I+0
j easyCOM.EasyReadClock(B)I+2
j test.main([Ljava/lang/StringV+223
v ~StubRoutines::call_stub
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x00a10a18 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=832]
0x00a0f688 JavaThread "CompilerThread0" daemon [_thread_blocked, id=3532]
0x00a0e970 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=2032]
0x009e8e18 JavaThread "Finalizer" daemon [_thread_blocked, id=3644]
0x009e8aa0 JavaThread "Reference Handler" daemon [_thread_blocked, id=2920]
=>0x00357aa8 JavaThread "main" [_thread_in_native, id=3680]
Other Threads:
0x00a088f0 VMThread [id=3656]
0x00a0e860 WatcherThread [id=2180]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
Heap
def new generation total 576K, used 210K [0x22a70000, 0x22b10000, 0x22f50000)
eden space 512K, 41% used [0x22a70000, 0x22aa4be8, 0x22af0000)
from space 64K, 0% used [0x22af0000, 0x22af0000, 0x22b00000)
to space 64K, 0% used [0x22b00000, 0x22b00000, 0x22b10000)
tenured generation total 1408K, used 0K [0x22f50000, 0x230b0000, 0x26a70000)
the space 1408K, 0% used [0x22f50000, 0x22f50000, 0x22f50200, 0x230b0000)
compacting perm gen total 8192K, used 26K [0x26a70000, 0x27270000, 0x2aa70000)
the space 8192K, 0% used [0x26a70000, 0x26a76940, 0x26a76a00, 0x27270000)
ro space 8192K, 67% used [0x2aa70000, 0x2afcd9f8, 0x2afcda00, 0x2b270000)
rw space 12288K, 46% used [0x2b270000, 0x2b813808, 0x2b813a00, 0x2be70000)
Dynamic libraries:
0x00400000 - 0x0040d000 C:\Programme\Java\jdk1.5.0_07\bin\javaw.exe
0x7c910000 - 0x7c9c7000 C:\WINDOWS\system32\ntdll.dll
0x7c800000 - 0x7c906000 C:\WINDOWS\system32\kernel32.dll
0x77da0000 - 0x77e4a000 C:\WINDOWS\system32\ADVAPI32.dll
0x77e50000 - 0x77ee1000 C:\WINDOWS\system32\RPCRT4.dll
0x77d10000 - 0x77da0000 C:\WINDOWS\system32\USER32.dll
0x77ef0000 - 0x77f37000 C:\WINDOWS\system32\GDI32.dll
0x77be0000 - 0x77c38000 C:\WINDOWS\system32\MSVCRT.dll
0x6d730000 - 0x6d8c7000 C:\Programme\Java\jdk1.5.0_07\jre\bin\client\jvm.dll
0x76af0000 - 0x76b1e000 C:\WINDOWS\system32\WINMM.dll
0x6d2f0000 - 0x6d2f8000 C:\Programme\Java\jdk1.5.0_07\jre\bin\hpi.dll
0x76bb0000 - 0x76bbb000 C:\WINDOWS\system32\PSAPI.DLL
0x6d700000 - 0x6d70c000 C:\Programme\Java\jdk1.5.0_07\jre\bin\verify.dll
0x6d370000 - 0x6d38d000 C:\Programme\Java\jdk1.5.0_07\jre\bin\java.dll
0x6d720000 - 0x6d72f000 C:\Programme\Java\jdk1.5.0_07\jre\bin\zip.dll
0x10000000 - 0x10008000 N:\java\iplanteasy\java\easyCOM\jnieasy.dll
0x10200000 - 0x10320000 C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugCRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_f75eb16c\MSVCR80D.dll
0x02c60000 - 0x02c6d000 N:\java\iplanteasy\java\easyCOM\EASY_COM_8XX.DLL
0x02c70000 - 0x02c7e000 N:\java\iplanteasy\java\easyCOM\COM_HARDWARE.dll
VM Arguments:
java_command: test
Launcher Type: SUN_STANDARD
Environment Variables:
PATH=.;C:\Borland\JBuilder2005\bin;C:\Borland\JBuilder2005\jdk1.4\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\Programme\Microsoft SQL Server\90\Tools\binn\;c:\util;c:\programme\util;c:\cygwin\bin;C:\Programme\WinSCP3\;C:\Programme\Microsoft Visual Studio 8\VC\bin;C:\Programme\Microsoft Visual Studio 8\Common7\IDE;C:\Programme\Microsoft Platform SDK for Windows XP SP2\Bin\.;C:\Programme\Microsoft Platform SDK for Windows XP SP2\Bin\WinNT\.;C:\Programme\Gemeinsame Dateien\GTK\2.0\bin;C:\Programme\Bitvise Tunnelier;C:\Programme\Support Tools\;C:\Programme\Microsoft Platform SDK for Windows XP SP2\Bin\.;C:\Programme\Microsoft Platform SDK for Windows XP SP2\Bin\WinNT\.;C:\Borland\JBuilder2005\debug\sa;C:\Borland\JBuilder2005\lib
USERNAME=tb
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 9 Stepping 5, 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, sse2
Memory: 4k page, physical 2095984k(1055716k free), swap 4038144k(3049264k free)
vm_info: Java HotSpot(TM) Client VM (1.5.0_07-b03) for windows-x86, built on May 3 2006 01:04:38 by "java_re" with MS VC++ 6.0
ich bräuchte mal Hiiiilfe; stricke gerade ein Interface zu einer vorhandenen DLL.
Setze Jbuilder2005 (free edition) ein; runtime ist 1.5 7. JBuilder hat die 1.4 als JRE, hab das Projekt aber auf 1.5 explizit umgestellt nachdem vorher die printfs vom native code gar nicht kamen..
Nun folgendes Problem, vielleicht bin ich aber irgendwo auch nur blind:
JNI -> native code - tickt schon ganz gut (ein bisschen), aber folgende C routine treibt mich zum Wahnsinn:
.
.
static byte year = 0;
static byte month = 0;
static byte day = 0;
static byte hour = 0;
static byte minute = 0;
.
.
JNIEXPORT jint JNICALL Java_easyCOM_ReadClock
(JNIEnv *env, jobject self, jbyte jnet_id)
{
int result = -1;
byte err = 0;
lasterr = 0;
checkEasyInit(env);
result = (pRead_Clock)(jnet_id, &year, &month, &day, &hour, &minute);
if (result) {
err = (byte)year;
lasterr = err;
(*env)->SetIntField(env, self, fldid_lasterr, err);
}
printf("C Got time\n");
//printf ("C ReadClock year :%d\n", year);
//printf ("C ReadClock month:%d\n", month);
//printf ("C ReadClock day :%d\n", day);
//printf ("C ReadClock hour :%d\n", hour);
//printf ("C ReadClock min :%d\n", min);
return (jint)result;
}
Und zwar bekomme ich exceptions von der JVM wenn ich versuche in der methode printf auszugeben. An anderen Stellen funktioniert es problemlos zu printf'en. Die printfs tun es sogar - also commen an - und die Datums-werte stimmen auch. Nachfolgend der errorlog.
Many thanks ahead!
tb
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# EXCEPTION_ILLEGAL_INSTRUCTION (0xc000001d) at pc=0x0006fa14, pid=2576, tid=3680
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_07-b03 mixed mode, sharing)
# Problematic frame:
# C 0x0006fa14
#
--------------- T H R E A D ---------------
Current thread (0x00357aa8): JavaThread "main" [_thread_in_native, id=3680]
siginfo: ExceptionCode=0xc000001d
Registers:
EAX=0x10212d90, EBX=0x26a75798, ECX=0xdf72b3e8, EDX=0x10312d30
ESP=0x0006fa28, EBP=0xfffffffe, ESI=0x26a75798, EDI=0x00357aa8
EIP=0x0006fa14, EFLAGS=0x00010206
Top of Stack: (sp=0x0006fa28)
0x0006fa28: 0006fa28 26a75798 0006fa58 26a76570
0x0006fa38: 00000000 26a75798 0006fa54 0006fa78
0x0006fa48: 00a729cf 00000000 00a76449 00000000
0x0006fa58: 22aa2880 0006fa5c 26a75f4a 0006fa84
0x0006fa68: 26a76570 00000000 26a75f58 0006fa80
0x0006fa78: 0006faa4 00a729cf 00000000 22aa2880
0x0006fa88: 0006fa88 26a748cf 0006fac4 26a74b20
0x0006fa98: 00000000 26a74960 0006fac4 0006fad8
Instructions: (pc=0x0006fa14)
0x0006fa04: 10 00 00 00 10 00 00 00 85 1f 08 00 50 ec be 06
0x0006fa14: 28 67 22 01 3c 00 00 00 00 00 00 00 10 bb 3d 15
Stack: [0x00030000,0x00070000), sp=0x0006fa28, free space=254k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C 0x0006fa14
[error occurred during error reporting, step 120, id 0xc0000005]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j easyCOM.ReadClock(B)I+0
j easyCOM.EasyReadClock(B)I+2
j test.main([Ljava/lang/StringV+223
v ~StubRoutines::call_stub
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x00a10a18 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=832]
0x00a0f688 JavaThread "CompilerThread0" daemon [_thread_blocked, id=3532]
0x00a0e970 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=2032]
0x009e8e18 JavaThread "Finalizer" daemon [_thread_blocked, id=3644]
0x009e8aa0 JavaThread "Reference Handler" daemon [_thread_blocked, id=2920]
=>0x00357aa8 JavaThread "main" [_thread_in_native, id=3680]
Other Threads:
0x00a088f0 VMThread [id=3656]
0x00a0e860 WatcherThread [id=2180]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
Heap
def new generation total 576K, used 210K [0x22a70000, 0x22b10000, 0x22f50000)
eden space 512K, 41% used [0x22a70000, 0x22aa4be8, 0x22af0000)
from space 64K, 0% used [0x22af0000, 0x22af0000, 0x22b00000)
to space 64K, 0% used [0x22b00000, 0x22b00000, 0x22b10000)
tenured generation total 1408K, used 0K [0x22f50000, 0x230b0000, 0x26a70000)
the space 1408K, 0% used [0x22f50000, 0x22f50000, 0x22f50200, 0x230b0000)
compacting perm gen total 8192K, used 26K [0x26a70000, 0x27270000, 0x2aa70000)
the space 8192K, 0% used [0x26a70000, 0x26a76940, 0x26a76a00, 0x27270000)
ro space 8192K, 67% used [0x2aa70000, 0x2afcd9f8, 0x2afcda00, 0x2b270000)
rw space 12288K, 46% used [0x2b270000, 0x2b813808, 0x2b813a00, 0x2be70000)
Dynamic libraries:
0x00400000 - 0x0040d000 C:\Programme\Java\jdk1.5.0_07\bin\javaw.exe
0x7c910000 - 0x7c9c7000 C:\WINDOWS\system32\ntdll.dll
0x7c800000 - 0x7c906000 C:\WINDOWS\system32\kernel32.dll
0x77da0000 - 0x77e4a000 C:\WINDOWS\system32\ADVAPI32.dll
0x77e50000 - 0x77ee1000 C:\WINDOWS\system32\RPCRT4.dll
0x77d10000 - 0x77da0000 C:\WINDOWS\system32\USER32.dll
0x77ef0000 - 0x77f37000 C:\WINDOWS\system32\GDI32.dll
0x77be0000 - 0x77c38000 C:\WINDOWS\system32\MSVCRT.dll
0x6d730000 - 0x6d8c7000 C:\Programme\Java\jdk1.5.0_07\jre\bin\client\jvm.dll
0x76af0000 - 0x76b1e000 C:\WINDOWS\system32\WINMM.dll
0x6d2f0000 - 0x6d2f8000 C:\Programme\Java\jdk1.5.0_07\jre\bin\hpi.dll
0x76bb0000 - 0x76bbb000 C:\WINDOWS\system32\PSAPI.DLL
0x6d700000 - 0x6d70c000 C:\Programme\Java\jdk1.5.0_07\jre\bin\verify.dll
0x6d370000 - 0x6d38d000 C:\Programme\Java\jdk1.5.0_07\jre\bin\java.dll
0x6d720000 - 0x6d72f000 C:\Programme\Java\jdk1.5.0_07\jre\bin\zip.dll
0x10000000 - 0x10008000 N:\java\iplanteasy\java\easyCOM\jnieasy.dll
0x10200000 - 0x10320000 C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugCRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_f75eb16c\MSVCR80D.dll
0x02c60000 - 0x02c6d000 N:\java\iplanteasy\java\easyCOM\EASY_COM_8XX.DLL
0x02c70000 - 0x02c7e000 N:\java\iplanteasy\java\easyCOM\COM_HARDWARE.dll
VM Arguments:
java_command: test
Launcher Type: SUN_STANDARD
Environment Variables:
PATH=.;C:\Borland\JBuilder2005\bin;C:\Borland\JBuilder2005\jdk1.4\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\Programme\Microsoft SQL Server\90\Tools\binn\;c:\util;c:\programme\util;c:\cygwin\bin;C:\Programme\WinSCP3\;C:\Programme\Microsoft Visual Studio 8\VC\bin;C:\Programme\Microsoft Visual Studio 8\Common7\IDE;C:\Programme\Microsoft Platform SDK for Windows XP SP2\Bin\.;C:\Programme\Microsoft Platform SDK for Windows XP SP2\Bin\WinNT\.;C:\Programme\Gemeinsame Dateien\GTK\2.0\bin;C:\Programme\Bitvise Tunnelier;C:\Programme\Support Tools\;C:\Programme\Microsoft Platform SDK for Windows XP SP2\Bin\.;C:\Programme\Microsoft Platform SDK for Windows XP SP2\Bin\WinNT\.;C:\Borland\JBuilder2005\debug\sa;C:\Borland\JBuilder2005\lib
USERNAME=tb
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 9 Stepping 5, 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, sse2
Memory: 4k page, physical 2095984k(1055716k free), swap 4038144k(3049264k free)
vm_info: Java HotSpot(TM) Client VM (1.5.0_07-b03) for windows-x86, built on May 3 2006 01:04:38 by "java_re" with MS VC++ 6.0