欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  Java

基于jni调用时,jvm报错问题的实例解析

程序员文章站 2022-03-17 18:21:06
...
本篇文章是对jni调用时,jvm的报错问题进行了详细的分析介绍,需要的朋友参考下

执行如下的jni调用:

代码如下:

package jni;
public class JNITransObject {
 public native TestJNI[] ObjectMethod(String text);
 static {
  System.loadLibrary("JNITransObject");
 }
 public static void main(String args[]) {
  JNITransObject jniTransObject = new JNITransObject();
  TestJNI[] testJNIs = jniTransObject.ObjectMethod("jni trans object");
  for (int i = 0; i < testJNIs.length; i++) {
   System.out.println(testJNIs[i].getTopic());
  }
 }
}


时,报如下的错误:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d91c1db, pid=3544, tid=5408
#
# JRE version: 6.0_21-b06
# Java VM: Java HotSpot(TM) Client VM (17.0-b16 mixed mode, sharing windows-x86 )
# Problematic frame:
# V  [jvm.dll+0x11c1db]
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#
---------------  T H R E A D  ---------------
Current thread (0x01aa6400):  JavaThread "main" [_thread_in_vm, id=5408, stack(0x00160000,0x001b0000)]
siginfo: ExceptionCode=0xc0000005, reading address 0x00000009
Registers:
EAX=0x00000005, EBX=0x00002000, ECX=0x00000006, EDX=0x23b47f28
ESP=0x001afa9c, EBP=0x001afaa8, ESI=0x01aa6400, EDI=0x01aa6400
EIP=0x6d91c1db, EFLAGS=0x00010202
Top of Stack: (sp=0x001afa9c)
0x001afa9c:   01aa6400 37b19738 3851d3b8 001afaf8
0x001afaac:   01b89f47 01aa6518 001afb00 001afb18
0x001afabc:   23b23bc0 001afb10 00000000 00002000
0x001afacc:   6d8f1751 01aa6400 00000006 001afad8
0x001afadc:   00000000 001afb18 3851ca08 00000000
0x001afaec:   3851d3b8 00000000 001afb08 001afb3c
0x001afafc:   01b82da1 38b317c8 01b88269 00002000
0x001afb0c:   00000000 23b47f28 23b23bc0 00000005 
Instructions: (pc=0x6d91c1db)
0x6d91c1cb:   74 5f 8b 55 18 85 d2 74 58 8b 5d 20 8b 12 8b 00
0x6d91c1db:   8b 48 04 8b 79 08 56 53 8b 5d 1c 53 52 8b 55 14 
Stack: [0x00160000,0x001b0000],  sp=0x001afa9c,  free space=13e001af45ck
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [jvm.dll+0x11c1db]
j  java.lang.System.arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V+0
j  java.lang.String.getChars(II[CI)V+62
j  java.io.BufferedWriter.write(Ljava/lang/String;II)V+63
j  java.io.Writer.write(Ljava/lang/String;)V+7
j  java.io.PrintStream.write(Ljava/lang/String;)V+13
j  java.io.PrintStream.print(Ljava/lang/String;)V+9
j  java.io.PrintStream.println(Ljava/lang/String;)V+6
j  jni.JNITransObject.main([Ljava/lang/String;)V+29
v  ~StubRoutines::call_stub
V  [jvm.dll+0xf3abc]
V  [jvm.dll+0x1865b1]
V  [jvm.dll+0xf3b3d]
V  [jvm.dll+0xfd385]
V  [jvm.dll+0x104fdd]
C  [javaw.exe+0x2155]
C  [javaw.exe+0x8614]
C  [kernel32.dll+0x4ed6c]
C  [ntdll.dll+0x637f5]
C  [ntdll.dll+0x637c8]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  java.lang.System.arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V+0
j  java.lang.String.getChars(II[CI)V+62
j  java.io.BufferedWriter.write(Ljava/lang/String;II)V+63
j  java.io.Writer.write(Ljava/lang/String;)V+7
j  java.io.PrintStream.write(Ljava/lang/String;)V+13
j  java.io.PrintStream.print(Ljava/lang/String;)V+9
j  java.io.PrintStream.println(Ljava/lang/String;)V+6
j  jni.JNITransObject.main([Ljava/lang/String;)V+29
v  ~StubRoutines::call_stub
---------------  P R O C E S S  ---------------
Java Threads: ( => current thread )
  0x01b2e800 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=7580, stack(0x03e10000,0x03e60000)]
  0x01b21800 JavaThread "CompilerThread0" daemon [_thread_blocked, id=6392, stack(0x03dc0000,0x03e10000)]
  0x01b19800 JavaThread "Attach Listener" daemon [_thread_blocked, id=6364, stack(0x03d70000,0x03dc0000)]
  0x01b16c00 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=6360, stack(0x03d20000,0x03d70000)]
  0x01acd000 JavaThread "Finalizer" daemon [_thread_blocked, id=6348, stack(0x03cd0000,0x03d20000)]
  0x01acb800 JavaThread "Reference Handler" daemon [_thread_blocked, id=6316, stack(0x03c80000,0x03cd0000)]
=>0x01aa6400 JavaThread "main" [_thread_in_vm, id=5408, stack(0x00160000,0x001b0000)]
Other Threads:
  0x01aca400 VMThread [stack: 0x03c30000,0x03c80000] [id=6320]
  0x01b2f400 WatcherThread [stack: 0x03e60000,0x03eb0000] [id=4824]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
Heap
 def new generation   total 4928K, used 1479K [0x23b10000, 0x24060000, 0x29060000)
  eden space 4416K,  33% used [0x23b10000, 0x23c81ef8, 0x23f60000)
  from space 512K,   0% used [0x23f60000, 0x23f60000, 0x23fe0000)
  to   space 512K,   0% used [0x23fe0000, 0x23fe0000, 0x24060000)
 tenured generation   total 10944K, used 0K [0x29060000, 0x29b10000, 0x33b10000)
   the space 10944K,   0% used [0x29060000, 0x29060000, 0x29060200, 0x29b10000)
 compacting perm gen  total 12288K, used 368K [0x33b10000, 0x34710000, 0x37b10000)
   the space 12288K,   2% used [0x33b10000, 0x33b6c1d0, 0x33b6c200, 0x34710000)
    ro space 10240K,  51% used [0x37b10000, 0x3803b700, 0x3803b800, 0x38510000)
    rw space 12288K,  54% used [0x38510000, 0x38ba76c0, 0x38ba7800, 0x39110000)
Dynamic libraries:
0x00400000 - 0x00424000 C:\Program Files\Java\jre6\bin\javaw.exe
0x77720000 - 0x7785c000 C:\Windows\SYSTEM32\ntdll.dll
0x75b10000 - 0x75be4000 C:\Windows\system32\kernel32.dll
0x75830000 - 0x7587a000 C:\Windows\system32\KERNELBASE.dll
0x774c0000 - 0x77560000 C:\Windows\system32\ADVAPI32.dll
0x77340000 - 0x773ec000 C:\Windows\system32\msvcrt.dll
0x77870000 - 0x77889000 C:\Windows\SYSTEM32\sechost.dll
0x760b0000 - 0x76151000 C:\Windows\system32\RPCRT4.dll
0x75ec0000 - 0x75f89000 C:\Windows\system32\USER32.dll
0x76010000 - 0x7605e000 C:\Windows\system32\GDI32.dll
0x75b00000 - 0x75b0a000 C:\Windows\system32\LPK.dll
0x75a50000 - 0x75aed000 C:\Windows\system32\USP10.dll
0x77030000 - 0x7704f000 C:\Windows\system32\IMM32.DLL
0x76db0000 - 0x76e7c000 C:\Windows\system32\MSCTF.dll
0x7c340000 - 0x7c396000 C:\Program Files\Java\jre6\bin\msvcr71.dll
0x6d800000 - 0x6daa7000 C:\Program Files\Java\jre6\bin\client\jvm.dll
0x755f0000 - 0x75622000 C:\Windows\system32\WINMM.dll
0x754a0000 - 0x754ec000 C:\Windows\system32\apphelp.dll
0x6d7b0000 - 0x6d7bc000 C:\Program Files\Java\jre6\bin\verify.dll
0x6d330000 - 0x6d34f000 C:\Program Files\Java\jre6\bin\java.dll
0x6d290000 - 0x6d298000 C:\Program Files\Java\jre6\bin\hpi.dll
0x76e80000 - 0x76e85000 C:\Windows\system32\PSAPI.DLL
0x6d7f0000 - 0x6d7ff000 C:\Program Files\Java\jre6\bin\zip.dll
0x10000000 - 0x10039000 E:\workspace\Zhy\JNITransObject.dll
VM Arguments:
jvm_args: -Dfile.encoding=GBK 
java_command: jni.JNITransObject
Launcher Type: SUN_STANDARD
Environment Variables:
JAVA_HOME=C:\Program Files\Java\jdk1.6.0_21
CLASSPATH=.;C:\Program Files\Java\jdk1.6.0_21\lib\dt.jar;C:\Program Files\Java\jdk1.6.0_21\lib\tools.jar
PATH=C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:/Program Files/Java/jre6/lib/i386;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files\AMD APP\bin\x86;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Common Files\Lenovo;C:\Program Files\Common Files\Ulead Systems\MPEG;C:\Program Files\Windows Live\Shared;C:\SWTOOLS\ReadyApps;C:\Program Files\Intel\Services\IPT\;C:\Program Files\Symantec\VIP Access Client\;C:\Program Files\Java\jdk1.6.0_21\bin;C:\Program Files\Java\jdk1.6.0_21\jre6\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Common Files\Thunder Network\KanKan\Codecs
USERNAME=think
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 42 Stepping 7, GenuineIntel
---------------  S Y S T E M  ---------------
OS: Windows 7 Build 7601 Service Pack 1
CPU:total 4 (8 cores per cpu, 2 threads per core) family 6 model 42 stepping 7, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, ht
Memory: 4k page, physical 3056880k(1883100k free), swap 6112004k(3307764k free)
vm_info: Java HotSpot(TM) Client VM (17.0-b16) for windows-x86 JRE (1.6.0_21-b06), built on Jun 22 2010 00:56:49 by "java_re" with MS VC++ 7.1 (VS2003)
time: Wed Apr 11 09:46:47 2012
elapsed time: 0 seconds

发生这样的错误,大多是JNI端代码有问题,如:不恰当的 printf 及 cout 调用,方法调用类型不兼容,调用被销毁的对象等。

以上就是基于jni调用时,jvm报错问题的实例解析的详细内容,更多请关注其它相关文章!