3

我有一个驱动电机的 Java 应用程序。电机的驱动程序是用 Microsoft Visual Studio 用 C++ 编写的。我导入(本机代码)这个 dll。Java 应用程序运行没有问题。我可以启动和停止电机。但是当我关闭这个应用程序时,它会在本机代码(电机驱动程序)中崩溃。

我问了这台电机的供应商。他们告诉我,在 Microsoft 环境 (Visual Studio) 中,电机驱动器运行没有问题。他们说,没有错误。但他们从未使用 Java 应用程序测试过驱动程序。

我尝试使用 Exception 和 Error 类来抑制错误。但它没有用。

问题:是否可以抑制此错误消息?

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_UNCAUGHT_CXX_EXCEPTION (0xe06d7363) at pc=0x7c812afb, pid=2180, tid=660
#
# JRE version: 6.0_37-b06
# Java VM: Java HotSpot(TM) Client VM (20.12-b01 mixed mode, sharing windows-x86 )
# Problematic frame:
# C  [kernel32.dll+0x12afb]
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

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

Current thread (0x02ec8800):  JavaThread "AWT-EventQueue-0" [_thread_in_native, id=660, stack(0x03280000,0x032d0000)]

siginfo: ExceptionCode=0xe06d7363, ExceptionInformation=0x19930520 0x032cee88 0x0425be4c 

Registers:
EAX=0x032cedf0, EBX=0x00000000, ECX=0x00000000, EDX=0x0427eb1c
ESP=0x032cedec, EBP=0x032cee40, ESI=0x032cee78, EDI=0x00000000
EIP=0x7c812afb, EFLAGS=0x00000206

Top of Stack: (sp=0x032cedec)
0x032cedec:   0464dab8 e06d7363 00000001 00000000
0x032cedfc:   7c812afb 00000003 19930520 032cee88
0x032cee0c:   0425be4c 00000008 032cee2c 040d9e0a
0x032cee1c:   0427eb1c 00000000 0010f29c 00000000
0x032cee2c:   032cee58 040da3f8 040da418 5f210f53
0x032cee3c:   00000000 032cee78 041b873d e06d7363
0x032cee4c:   00000001 00000003 032cee6c e06d7363
0x032cee5c:   00000001 00000000 00000000 00000003 

Instructions: (pc=0x7c812afb)
0x7c812adb:   f9 0f 0f 87 6d 1e 03 00 85 c9 89 4d c0 74 07 57
0x7c812aeb:   8d 7d c4 f3 a5 5f 8d 45 b0 50 ff 15 10 15 80 7c
0x7c812afb:   5e c9 c2 10 00 85 ff 0f 8e 36 93 ff ff 8b 55 fc
0x7c812b0b:   89 55 0c 0f b7 16 8b 7d f8 8a 14 3a 88 11 8b 78 


Register to memory mapping:

EAX=0x032cedf0 is pointing into the stack for thread: 0x02ec8800
EBX=0x00000000 is an unknown value
ECX=0x00000000 is an unknown value
EDX=0x0427eb1c is an unknown value
ESP=0x032cedec is pointing into the stack for thread: 0x02ec8800
EBP=0x032cee40 is pointing into the stack for thread: 0x02ec8800
ESI=0x032cee78 is pointing into the stack for thread: 0x02ec8800
EDI=0x00000000 is an unknown value


Stack: [0x03280000,0x032d0000],  sp=0x032cedec,  free space=315k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [kernel32.dll+0x12afb]  RaiseException+0x52
C  [EposCmd.dll+0x26873d]
C  [EposCmd.dll+0x1705da]
C  [EposCmd.dll+0x17ec0d]
C  [EposCmd.dll+0x1564f1]
C  [EposCmd.dll+0x146bca]
C  [EposCmd.dll+0x137714]
C  [EposCmd.dll+0x12d5e8]
C  [EposCmd.dll+0x12fbb2]
C  [EposCmd.dll+0x106e38]
C  [EposCmd.dll+0x107b8b]
C  [EposCmd.dll+0xcfbb8]
C  [EposCmd.dll+0xd2e7b]
C  [EposCmd.dll+0x106e38]
C  [EposCmd.dll+0x43268]
C  [EposCmd.dll+0x39afb]
C  [EposCmd.dll+0x106e38]
C  [EposCmd.dll+0x102b3]
C  [EposCmd.dll+0x4f5b]
C  [EposCmd.dll+0x5125]
C  [MaxonMotor.dll+0x15fb]
j  finaltest.MaxonMotor.close()Z+8
j  finaltest.FrameGWF$1.windowClosing(Ljava/awt/event/WindowEvent;)V+87
j  java.awt.AWTEventMulticaster.windowClosing(Ljava/awt/event/WindowEvent;)V+8
j  java.awt.Window.processWindowEvent(Ljava/awt/event/WindowEvent;)V+68
j  javax.swing.JFrame.processWindowEvent(Ljava/awt/event/WindowEvent;)V+2
j  java.awt.Window.processEvent(Ljava/awt/AWTEvent;)V+69
j  java.awt.Component.dispatchEventImpl(Ljava/awt/AWTEvent;)V+573
j  java.awt.Container.dispatchEventImpl(Ljava/awt/AWTEvent;)V+42
j  java.awt.Window.dispatchEventImpl(Ljava/awt/AWTEvent;)V+65
j  java.awt.Component.dispatchEvent(Ljava/awt/AWTEvent;)V+2
j  java.awt.EventQueue.dispatchEventImpl(Ljava/awt/AWTEvent;Ljava/lang/Object;)V+41
j  java.awt.EventQueue.access$400(Ljava/awt/EventQueue;Ljava/awt/AWTEvent;Ljava/lang/Object;)V+3
j  java.awt.EventQueue$2.run()Ljava/lang/Void;+12
j  java.awt.EventQueue$2.run()Ljava/lang/Object;+1
v  ~StubRoutines::call_stub
V  [jvm.dll+0xfb7cb]
V  [jvm.dll+0x18d3d1]
V  [jvm.dll+0xfb84d]
V  [jvm.dll+0xbbf84]
C  [java.dll+0x102f]  Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedAction_2Ljava_security_AccessControlContext_2+0x17
J  java.security.AccessControlContext$1.doIntersectionPrivilege(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;Ljava/security/AccessControlContext;)Ljava/lang/Object;
j  java.awt.EventQueue$3.run()Ljava/lang/Void;+11
j  java.awt.EventQueue$3.run()Ljava/lang/Object;+1
v  ~StubRoutines::call_stub
V  [jvm.dll+0xfb7cb]
V  [jvm.dll+0x18d3d1]
V  [jvm.dll+0xfb84d]
V  [jvm.dll+0xbbf84]
C  [java.dll+0x102f]  Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedAction_2Ljava_security_AccessControlContext_2+0x17
J  java.security.AccessControlContext$1.doIntersectionPrivilege(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;Ljava/security/AccessControlContext;)Ljava/lang/Object;
J  java.awt.EventDispatchThread.pumpOneEventForFilters(I)Z
j  java.awt.EventDispatchThread.pumpEventsForHierarchy(ILjava/awt/Conditional;Ljava/awt/Component;)V+11
j  java.awt.EventDispatchThread.pumpEvents(ILjava/awt/Conditional;)V+4
j  java.awt.EventDispatchThread.pumpEvents(Ljava/awt/Conditional;)V+3
j  java.awt.EventDispatchThread.run()V+9
v  ~StubRoutines::call_stub
V  [jvm.dll+0xfb7cb]
V  [jvm.dll+0x18d3d1]
V  [jvm.dll+0xfb971]
V  [jvm.dll+0xfb9cb]
V  [jvm.dll+0xb5e99]
V  [jvm.dll+0x119ab4]
V  [jvm.dll+0x14209c]
C  [msvcr71.dll+0x9565]  endthreadex+0xa0
C  [kernel32.dll+0xb729]  GetModuleFileNameA+0x1ba

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  finaltest.MaxonMotorCmd.closeAllDevices()Z+0
j  finaltest.MaxonMotor.close()Z+8
j  finaltest.FrameGWF$1.windowClosing(Ljava/awt/event/WindowEvent;)V+87
j  java.awt.AWTEventMulticaster.windowClosing(Ljava/awt/event/WindowEvent;)V+8
j  java.awt.Window.processWindowEvent(Ljava/awt/event/WindowEvent;)V+68
j  javax.swing.JFrame.processWindowEvent(Ljava/awt/event/WindowEvent;)V+2
j  java.awt.Window.processEvent(Ljava/awt/AWTEvent;)V+69
j  java.awt.Component.dispatchEventImpl(Ljava/awt/AWTEvent;)V+573
j  java.awt.Container.dispatchEventImpl(Ljava/awt/AWTEvent;)V+42
j  java.awt.Window.dispatchEventImpl(Ljava/awt/AWTEvent;)V+65
j  java.awt.Component.dispatchEvent(Ljava/awt/AWTEvent;)V+2
j  java.awt.EventQueue.dispatchEventImpl(Ljava/awt/AWTEvent;Ljava/lang/Object;)V+41
j  java.awt.EventQueue.access$400(Ljava/awt/EventQueue;Ljava/awt/AWTEvent;Ljava/lang/Object;)V+3
j  java.awt.EventQueue$2.run()Ljava/lang/Void;+12
j  java.awt.EventQueue$2.run()Ljava/lang/Object;+1
v  ~StubRoutines::call_stub
J  java.security.AccessController.doPrivileged(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;
J  java.security.AccessControlContext$1.doIntersectionPrivilege(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;Ljava/security/AccessControlContext;)Ljava/lang/Object;
j  java.security.AccessControlContext$1.doIntersectionPrivilege(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;+6
j  java.awt.EventQueue$3.run()Ljava/lang/Void;+11
j  java.awt.EventQueue$3.run()Ljava/lang/Object;+1
v  ~StubRoutines::call_stub
J  java.security.AccessController.doPrivileged(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;
J  java.security.AccessControlContext$1.doIntersectionPrivilege(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;Ljava/security/AccessControlContext;)Ljava/lang/Object;
j  java.awt.EventQueue.dispatchEvent(Ljava/awt/AWTEvent;)V+73
J  java.awt.EventDispatchThread.pumpOneEventForFilters(I)Z
j  java.awt.EventDispatchThread.pumpEventsForFilter(ILjava/awt/Conditional;Ljava/awt/EventFilter;)V+30
j  java.awt.EventDispatchThread.pumpEventsForHierarchy(ILjava/awt/Conditional;Ljava/awt/Component;)V+11
j  java.awt.EventDispatchThread.pumpEvents(ILjava/awt/Conditional;)V+4
j  java.awt.EventDispatchThread.pumpEvents(Ljava/awt/Conditional;)V+3
j  java.awt.EventDispatchThread.run()V+9
v  ~StubRoutines::call_stub

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

Java Threads: ( => current thread )
  0x003b6c00 JavaThread "DestroyJavaVM" [_thread_blocked, id=2816, stack(0x008c0000,0x00910000)]
  0x02faf000 JavaThread "Thread-6" [_thread_blocked, id=1792, stack(0x04980000,0x049d0000)]
  0x02fd8400 JavaThread "Image Fetcher 0" daemon [_thread_blocked, id=1676, stack(0x03ef0000,0x03f40000)]
  0x02f75800 JavaThread "Thread-4" [_thread_blocked, id=3844, stack(0x03ea0000,0x03ef0000)]
  0x02eb7400 JavaThread "Thread-3" [_thread_blocked, id=1400, stack(0x03a60000,0x03ab0000)]
  0x02f3e400 JavaThread "TimerQueue" daemon [_thread_blocked, id=2528, stack(0x037c0000,0x03810000)]
=>0x02ec8800 JavaThread "AWT-EventQueue-0" [_thread_in_native, id=660, stack(0x03280000,0x032d0000)]
  0x02b7bc00 JavaThread "AWT-Windows" daemon [_thread_in_native, id=2824, stack(0x031a0000,0x031f0000)]
  0x02b7a800 JavaThread "AWT-Shutdown" [_thread_blocked, id=1516, stack(0x03150000,0x031a0000)]
  0x02b79800 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=296, stack(0x03100000,0x03150000)]
  0x02b61c00 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=3988, stack(0x02dd0000,0x02e20000)]
  0x02b53000 JavaThread "C1 CompilerThread0" daemon [_thread_blocked, id=1960, stack(0x02d80000,0x02dd0000)]
  0x02b51800 JavaThread "Attach Listener" daemon [_thread_blocked, id=2148, stack(0x02d30000,0x02d80000)]
  0x02b50400 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=3644, stack(0x02ce0000,0x02d30000)]
  0x02b4b800 JavaThread "Finalizer" daemon [_thread_blocked, id=1120, stack(0x02c90000,0x02ce0000)]
  0x02b46c00 JavaThread "Reference Handler" daemon [_thread_blocked, id=2820, stack(0x02c40000,0x02c90000)]

Other Threads:
  0x02b0a800 VMThread [stack: 0x02bf0000,0x02c40000] [id=2400]
  0x02b63c00 WatcherThread [stack: 0x02e20000,0x02e70000] [id=1396]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
 def new generation   total 5888K, used 69K [0x22990000, 0x22ff0000, 0x27ee0000)
  eden space 5248K,   1% used [0x22990000, 0x229a16e0, 0x22eb0000)
  from space 640K,   0% used [0x22eb0000, 0x22eb0000, 0x22f50000)
  to   space 640K,   0% used [0x22f50000, 0x22f50000, 0x22ff0000)
 tenured generation   total 12992K, used 7794K [0x27ee0000, 0x28b90000, 0x32990000)
   the space 12992K,  59% used [0x27ee0000, 0x2867cad8, 0x2867cc00, 0x28b90000)
 compacting perm gen  total 12288K, used 2179K [0x32990000, 0x33590000, 0x36990000)
   the space 12288K,  17% used [0x32990000, 0x32bb0ee0, 0x32bb1000, 0x33590000)
    ro space 10240K,  51% used [0x36990000, 0x36ec0500, 0x36ec0600, 0x37390000)
    rw space 12288K,  55% used [0x37390000, 0x37a2bd40, 0x37a2be00, 0x37f90000)

Code Cache  [0x00910000, 0x00a20000, 0x02910000)
 total_blobs=649 nmethods=432 adapters=153 free_code_cache=32450688 largest_free_block=320

Dynamic libraries:
0x00400000 - 0x00425000     C:\Programme\Java\jre6\bin\javaw.exe
0x7c910000 - 0x7c9c9000     C:\WINDOWS\system32\ntdll.dll
0x7c800000 - 0x7c908000     C:\WINDOWS\system32\kernel32.dll
0x77da0000 - 0x77e4a000     C:\WINDOWS\system32\ADVAPI32.dll
0x77e50000 - 0x77ee3000     C:\WINDOWS\system32\RPCRT4.dll
0x77fc0000 - 0x77fd1000     C:\WINDOWS\system32\Secur32.dll
0x7e360000 - 0x7e3f1000     C:\WINDOWS\system32\USER32.dll
0x77ef0000 - 0x77f39000     C:\WINDOWS\system32\GDI32.dll
0x76330000 - 0x7634d000     C:\WINDOWS\system32\IMM32.DLL
0x62e10000 - 0x62e19000     C:\WINDOWS\system32\LPK.DLL
0x75790000 - 0x757fb000     C:\WINDOWS\system32\USP10.dll
0x7c340000 - 0x7c396000     C:\Programme\Java\jre6\bin\msvcr71.dll
0x6d7f0000 - 0x6daa0000     C:\Programme\Java\jre6\bin\client\jvm.dll
0x76af0000 - 0x76b1e000     C:\WINDOWS\system32\WINMM.dll
0x6d7a0000 - 0x6d7ac000     C:\Programme\Java\jre6\bin\verify.dll
0x6d320000 - 0x6d33f000     C:\Programme\Java\jre6\bin\java.dll
0x6d7e0000 - 0x6d7ef000     C:\Programme\Java\jre6\bin\zip.dll
0x6d000000 - 0x6d14c000     C:\Programme\Java\jre6\bin\awt.dll
0x72f70000 - 0x72f96000     C:\WINDOWS\system32\WINSPOOL.DRV
0x77be0000 - 0x77c38000     C:\WINDOWS\system32\msvcrt.dll
0x774b0000 - 0x775ee000     C:\WINDOWS\system32\ole32.dll
0x773a0000 - 0x774a3000     C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.6028_x-ww_61e65202\COMCTL32.dll
0x77f40000 - 0x77fb6000     C:\WINDOWS\system32\SHLWAPI.dll
0x5b0f0000 - 0x5b128000     C:\WINDOWS\system32\uxtheme.dll
0x746a0000 - 0x746ec000     C:\WINDOWS\system32\MSCTF.dll
0x75250000 - 0x7527e000     C:\WINDOWS\system32\msctfime.ime
0x7e670000 - 0x7ee91000     C:\WINDOWS\system32\shell32.dll
0x6d230000 - 0x6d27f000     C:\Programme\Java\jre6\bin\fontmanager.dll
0x10000000 - 0x10013000     C:\WINDOWS\system32\btmmhook.dll
0x6d600000 - 0x6d613000     C:\Programme\Java\jre6\bin\net.dll
0x71a10000 - 0x71a27000     C:\WINDOWS\system32\WS2_32.dll
0x71a00000 - 0x71a08000     C:\WINDOWS\system32\WS2HELP.dll
0x6d620000 - 0x6d629000     C:\Programme\Java\jre6\bin\nio.dll
0x03520000 - 0x0352f000     C:\Programme\Java\jre6\bin\ownWinSys.dll
0x035b0000 - 0x035bc000     C:\Programme\WIDCOMM\Bluetooth Software\btkeyind.dll
0x03230000 - 0x03246000     C:\Programme\Java\jre6\bin\javaxcomm.dll
0x03f40000 - 0x03f4e000     C:\Code\Java\Programme\FinalTest\MaxonMotor.dll
0x03f50000 - 0x042db000     C:\Code\Java\Programme\FinalTest\EposCmd.dll
0x76320000 - 0x76325000     C:\WINDOWS\system32\MSIMG32.dll
0x76350000 - 0x7639a000     C:\WINDOWS\system32\COMDLG32.dll
0x770f0000 - 0x7717b000     C:\WINDOWS\system32\OLEAUT32.dll
0x61880000 - 0x618ba000     C:\WINDOWS\system32\OLEACC.dll
0x4eba0000 - 0x4ed4b000     C:\WINDOWS\WinSxS\x86_Microsoft.Windows.GdiPlus_6595b64144ccf1df_1.0.6002.22791_x-ww_c8dff154\gdiplus.dll
0x77bd0000 - 0x77bd8000     C:\WINDOWS\system32\VERSION.dll
0x6d440000 - 0x6d465000     C:\Programme\Java\jre6\bin\jpeg.dll
0x04730000 - 0x04762000     C:\WINDOWS\system32\ftd2xx.dll
0x778f0000 - 0x779e4000     C:\WINDOWS\system32\SETUPAPI.dll
0x76bf0000 - 0x76c1e000     C:\WINDOWS\system32\WINTRUST.dll
0x77a50000 - 0x77ae6000     C:\WINDOWS\system32\CRYPT32.dll
0x77af0000 - 0x77b02000     C:\WINDOWS\system32\MSASN1.dll
0x76c50000 - 0x76c78000     C:\WINDOWS\system32\IMAGEHLP.dll
0x6d1a0000 - 0x6d1c3000     C:\Programme\Java\jre6\bin\dcpr.dll
0x76bb0000 - 0x76bbb000     C:\WINDOWS\system32\PSAPI.DLL

VM Arguments:
jvm_args: -Djava.library.path=C:\Code\Java\Programme\FinalTest;C:\Code\Java\Programme\FinalTest -Dfile.encoding=Cp1252 
java_command: finaltest.FrameGWF
Launcher Type: SUN_STANDARD

Environment Variables:
PATH=C:/Programme/Java/jre6/bin/client;C:/Programme/Java/jre6/bin;C:/Programme/Java/jre6/lib/i386;C:\jet7.6-pro\bin;C:\Programme\ExcelsiorJET\bin;C:\Programme\WinAVR-20080610\bin;C:\Programme\WinAVR-20080610\utils\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Programme\Intel\DMIX;C:\Programme\Gemeinsame Dateien\Roxio Shared\DLLShared;c:\Programme\Microsoft SQL Server\100\Tools\Binn\;c:\Programme\Microsoft SQL Server\100\DTS\Binn\;
USERNAME=Peloso
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 2, GenuineIntel



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

OS: Windows XP Build 2600 Service Pack 3

CPU:total 2 (2 cores per cpu, 1 threads per core) family 6 model 15 stepping 2, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3

Memory: 4k page, physical 2079984k(1194376k free), swap 4022172k(3230168k free)

vm_info: Java HotSpot(TM) Client VM (20.12-b01) for windows-x86 JRE (1.6.0_37-b06), built on Sep 24 2012 12:44:35 by "java_re" with MS VC++ 7.1 (VS2003)

time: Thu Oct 25 14:59:01 2012
elapsed time: 14 seconds
4

1 回答 1

0

这是不可能压制的,不。真的没有一个很好的方法来干净地处理它,因为它发生在你的代码之外。它可能是各种各样的事情,例如过时的驱动程序文件、硬件不兼容等。

不过,堆栈跟踪中有一些见解。堆栈的顶部说

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  finaltest.MaxonMotorCmd.closeAllDevices()Z+0
j  finaltest.MaxonMotor.close()Z+8

所以看起来该closeAllDevices方法正在导致这种情况发生。您应该通过该方法并确保正确停止设备并正常关闭它。

请注意,这也发生在事件分派线程上(如线程列表中的 => 所示 =>0x02ec8800 JavaThread "AWT-EventQueue-0" [_thread_in_native, id=660, stack(0x03280000,0x032d0000)])。通常,您不想从 EDT 进行任何繁重的工作(例如关闭电机)。

于 2012-10-25T14:23:25.803 回答