加载本机库时JVM崩溃

时间:2016-08-11 07:44:59

标签: java jvm java-native-interface

我正在使用java工作在CD刻录机上,其中(使用JNI)我必须加载一些本机库(DLL)。好吧,我知道要使用" System.loadLibrary(libName)"来加载本机库,必须将库设置为" java.library.path"之一。路径,但是如果使用" System.load(libPath)"没有必要这样做。

所以,我曾经使用" System.load(libPath)"来加载我所有的本机库。并且除了一个"BurnerCaller.dll"导致JVM崩溃以及下面的错误消息之外,它对所有这些都有效。

# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (0xe0434352), pid=2280, tid=0x00000000000013a8
#
# JRE version: Java(TM) SE Runtime Environment (8.0_92-b14) (build 1.8.0_92-b14)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.92-b14 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [KERNELBASE.dll+0xaa7d]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Program Files\Java\MainWorkspace\NewAman\hs_err_pid2280.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.

Here是详细的结果错误。

奇怪的是当且仅当我把这个库放到" bin "当前正在运行的JREJDK(我的应用程序用来运行)的目录,它就像一个魅力。

任何帮助将不胜感激,提前谢谢。

1 个答案:

答案 0 :(得分:0)

  1. 尝试其他JDK(Oracle JDK,Open JDK,版本6,7,8)。确保dll位(32对64)与JDK位相匹配
  2. 调试本机代码
  3. 它看起来像纯粹的原生问题,你应该使用原生工具。

    如果你有BurnerCaller.dll的源代码,你可以附加(Visual Studio,WinDbg)\ debug \ fix it。至少你会看到本机崩溃的堆栈跟踪。 如果你没有源 - 只需将它放在java bin 目录中,这是最简单的方法。

    当系统加载程序加载一个库时,它会为这个库调用DllMain,看起来就像它周围的bug一样。