来自 Java 的 MATLAB 函数导致运行时错误 (EXCEPTION_ACCESS_VIOLATION)

MATLAB function from Java causes Runtime Error (EXCEPTION_ACCESS_VIOLATION)

我正在为 Java 使用 MATLAB 引擎 API,到目前为止,evalfeval[=24= 等基础知识] 功能可以正常工作。我什至用这些画了一个直方图。但是 PutVariable 方法使我有 "EXCEPTION_ACCESS_VIOLATION".

代码是:

package connecter;

import java.util.*;  
import java.util.concurrent.ExecutionException;

import com.mathworks.engine.*;

public class MainClass {

    public static void main(String[] args) throws IllegalArgumentException, IllegalStateException, InterruptedException, MatlabExecutionException, MatlabSyntaxException, ExecutionException {

        MatlabEngine matEng = MatlabEngine.startMatlab();
        matEng.putVariable("x", 3.0);
}

控制台给了我以下信息:

# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000001b224d20b95, pid=1904, tid=8768
#
# JRE version: Java(TM) SE Runtime Environment (12.0.2+10) (build 12.0.2+10)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (12.0.2+10, mixed mode, sharing, tiered, compressed oops, g1 gc, windows-amd64)
# Problematic frame:
# v  ~StubRoutines::atomic_add_long
#
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# [Filepath]\hs_err_pid1904.log
Could not load hsdis-amd64.dll; library not loadable; PrintAssembly is disabled
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
#

到目前为止,我已经搜索了无数线程,但到目前为止没有任何效果。我正在使用 JavaSE-12,MATLAB 是 R2019b。

你做得对。这是 Matlab 和/或 JDK 中的错误。您在这里无能为力。联系 MathWorks 的支持人员和您的 JDK 供应商,让他们知道发生了什么,并与您的 IT 部门联系,看看您是否有可能会扰乱他们的奇怪机器配置。

并尝试 运行 对抗不同的 JDK,比如低得多的主要版本,例如 JDK 8. Matlab 使用旧的 JDK 版本,所以更有可能接受测试并与他们对抗。