gpt4 book ai didi

java - jmockit、openJDK 和 UnsatisfiedLinkError

转载 作者:搜寻专家 更新时间:2023-11-01 02:30:55 25 4
gpt4 key购买 nike

当尝试在 OpenJDK 6 上使用 JMockit 运行测试时,我遇到了错误:

[junit] Exception in thread "main" java.lang.ExceptionInInitializerError
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:353)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:1052)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:906)
[junit] Caused by: java.lang.IllegalStateException: Native library for Attach API not available in this JRE
[junit] at mockit.internal.startup.JDK6AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(JDK6AgentLoader.java:81)
[junit] at mockit.internal.startup.JDK6AgentLoader.loadAgent(JDK6AgentLoader.java:54)
[junit] at mockit.internal.startup.AgentInitialization.initializeAccordingToJDKVersion(AgentInitialization.java:21)
[junit] at mockit.internal.startup.Startup.initializeIfNeeded(Startup.java:200)
[junit] at mockit.internal.startup.Startup.initializeIfPossible(Startup.java:215)
[junit] at junit.framework.TestResult.<clinit>(TestResult.java:19)
[junit] ... 3 more
[junit] Caused by: java.lang.UnsatisfiedLinkError: sun.tools.attach.LinuxVirtualMachine.isLinuxThreads()Z
[junit] at sun.tools.attach.LinuxVirtualMachine.isLinuxThreads(Native Method)
[junit] at sun.tools.attach.LinuxVirtualMachine.<clinit>(LinuxVirtualMachine.java:364)
[junit] at mockit.internal.startup.JDK6AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(JDK6AgentLoader.java:71)
[junit] ... 8 more

我查看了文件夹/usr/local/openjdk6/jre/lib/amd64/并在那里找到了 libattach.so

但是添加 -Djava.library.path=/usr/local/openjdk6/jre/lib/amd64 并没有解决问题。我还能尝试什么?

最佳答案

尝试添加 <jdk6home>/lib/tools.jar到类路径,之前 jmockit.jar。如果这不能解决问题,请传递 -javaagent:jmockit.jar作为 JVM 初始化参数绝对应该。

关于java - jmockit、openJDK 和 UnsatisfiedLinkError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9565497/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com