#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x10001053, pid=312, tid=1000
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_04-b05 mixed mode, sharing)
# Problematic frame:
# C [AsmTest.dll+0x1053]
#
--------------- T H R E A D ---------------
Current thread (0x00035b60): JavaThread "main" [_thread_in_native, id=1000]
siginfo: ExceptionCode=0xc0000005, reading address 0xffffffff
Registers:
EAX=0x6c6c0200, EBX=0x26b24460, ECX=0x6f77206f, EDX=0x2164fa84
ESP=0x0007fa38, EBP=0x0007fa94, ESI=0x26b24460, EDI=0x0007fa94
EIP=0x10001053, EFLAGS=0x00010206
Top of Stack: (sp=0x0007fa38)
0x0007fa38: 00035b60 26b24460 26b24460 cccccccc
0x0007fa48: cccccccc cccccccc cccccccc cccccccc
0x0007fa58: cccccccc cccccccc cccccccc cccccccc
0x0007fa68: cccccccc cccccccc cccccccc cccccccc
0x0007fa78: cccccccc cccccccc cccccccc 6c6c6568
0x0007fa88: 6f77206f 21646c72 cccccc00 0007fac0
0x0007fa98: 00ae826f 00035c1c 0007fac8 0007faa4
0x0007faa8: 26b24460 0007facc 26b24690 00000000
Instructions: (pc=0x10001053)
0x10001043: 28 90 02 10 88 45 fc 66 8d 95 f0 ff ff ff b4 02
0x10001053: cd 21 5f 5e 5b 83 c4 50 3b ec e8 1e 00 00 00 8b
Stack: [0x00040000,0x00080000), sp=0x0007fa38, free space=254k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [AsmTest.dll+0x1053]
j AsmTest.HelloWorld()V+0
j Test.main([Ljava/lang/String;)V+10
v ~StubRoutines::call_stub
V [jvm.dll+0x82696]
V [jvm.dll+0xd6fd9]
V [jvm.dll+0x82567]
V [jvm.dll+0x895e6]
C [java.exe+0x14c0]
C [java.exe+0x64cd]
C [kernel32.dll+0x2141a]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j AsmTest.HelloWorld()V+0
j Test.main([Ljava/lang/String;)V+10
v ~StubRoutines::call_stub
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x00a7e840 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=1032]
0x00a7d418 JavaThread "CompilerThread0" daemon [_thread_blocked, id=1784]
0x00a7c730 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=872]
0x0003fa48 JavaThread "Finalizer" daemon [_thread_blocked, id=1616]
0x00a57aa0 JavaThread "Reference Handler" daemon [_thread_blocked, id=720]
=>0x00035b60 JavaThread "main" [_thread_in_native, id=1000]
Other Threads:
0x00a77be0 VMThread [id=360]
0x00a992f0 WatcherThread [id=1028]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
Heap
def new generation total 576K, used 230K [0x22ad0000, 0x22b70000, 0x22fb0000)
eden space 512K, 44% used [0x22ad0000, 0x22b09978, 0x22b50000)
from space 64K, 0% used [0x22b50000, 0x22b50000, 0x22b60000)
to space 64K, 0% used [0x22b60000, 0x22b60000, 0x22b70000)
tenured generation total 1408K, used 0K [0x22fb0000, 0x23110000, 0x26ad0000)
the space 1408K, 0% used [0x22fb0000, 0x22fb0000, 0x22fb0200, 0x23110000)
compacting perm gen total 8192K, used 337K [0x26ad0000, 0x272d0000, 0x2aad0000)
the space 8192K, 4% used [0x26ad0000, 0x26b246f8, 0x26b24800, 0x272d0000)
ro space 8192K, 66% used [0x2aad0000, 0x2b029dc0, 0x2b029e00, 0x2b2d0000)
rw space 12288K, 46% used [0x2b2d0000, 0x2b867e98, 0x2b868000, 0x2bed0000)
Dynamic libraries:
0x00400000 - 0x0040c000 C:\Program Files\Java\jdk1.5.0_04\bin\java.exe
0x77f50000 - 0x77ff7000 C:\WINDOWS\System32\ntdll.dll
0x77e40000 - 0x77f4e000 C:\WINDOWS\system32\kernel32.dll
0x77da0000 - 0x77e3b000 C:\WINDOWS\system32\ADVAPI32.dll
0x78000000 - 0x78087000 C:\WINDOWS\system32\RPCRT4.dll
0x77be0000 - 0x77c33000 C:\WINDOWS\system32\MSVCRT.dll
0x6d6b0000 - 0x6d839000 C:\Program Files\Java\jdk1.5.0_04\jre\bin\client\jvm.dll
0x77d10000 - 0x77d9c000 C:\WINDOWS\system32\USER32.dll
0x7f000000 - 0x7f041000 C:\WINDOWS\system32\GDI32.dll
0x76b10000 - 0x76b39000 C:\WINDOWS\System32\WINMM.dll
0x76300000 - 0x7631c000 C:\WINDOWS\System32\IMM32.DLL
0x62c20000 - 0x62c28000 C:\WINDOWS\System32\LPK.DLL
0x72f10000 - 0x72f6a000 C:\WINDOWS\System32\USP10.dll
0x6d2f0000 - 0x6d2f8000 C:\Program Files\Java\jdk1.5.0_04\jre\bin\hpi.dll
0x76bc0000 - 0x76bcb000 C:\WINDOWS\System32\PSAPI.DLL
0x6d680000 - 0x6d68c000 C:\Program Files\Java\jdk1.5.0_04\jre\bin\verify.dll
0x6d370000 - 0x6d38d000 C:\Program Files\Java\jdk1.5.0_04\jre\bin\java.dll
0x6d6a0000 - 0x6d6af000 C:\Program Files\Java\jdk1.5.0_04\jre\bin\zip.dll
0x10000000 - 0x10033000 C:\AsmTest.dll
VM Arguments:
java_command: Test
Environment Variables:
CLASSPATH=.;C:\Program Files\Java\jdk1.5.0_04\lib\tools.jar
PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\Rational\common;;C:\Program Files\Java\jdk1.5.0_04\bin
USERNAME=Ahui
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 1
CPU:total 1 family 6, cmov, cx8, fxsr, mmx, sse
Memory: 4k page, physical 392688k(213184k free), swap 1174376k(963184k free)
vm_info: Java HotSpot(TM) Client VM (1.5.0_04-b05) for windows-x86, built on Jun 3 2005 02:10:41 by "java_re" with MS VC++ 6.0
-----------------------------------------------
以上是运行时Jvm产生的错误日志
因为java可以通过jni调用c++或者C,而它们又可以调用汇编语言,所以java应该可以通过这一系列的调用达到调用汇编的目的,
java语言的部分就不用说了,我的cpp实现如下:
----------------------------------------------
#include"AsmTest.h"
#include"iostream.h"
JNIEXPORT void JNICALL Java_AsmTest_HelloWorld
(JNIEnv *, jobject){
char mess[]="hello world!";
_asm{
push edx
push eax
lea edx,mess
mov eax,00000900h;
int 21h;
pop eax
pop edx
}
}
-----------------------------------------------
开始没有对对edx,eax保护时也出现上边的错误日志,于是怀疑是用c++实现输出用到的寄存器破坏了jvm的运行,可以加上保护之后还是一样。
由于c语言的一些基本函数也是用汇编实现的,理论上来说直接在c++里嵌入汇编,然后由java调用也是可以实现的,不知道什么原因不能实现