Java 运行时环境导致的致命错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2543106/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 09:05:20  来源:igfitidea点击:

Fatal error by Java runtime environment

javaruntime-error

提问by siri

I am executing a junit test case

我正在执行一个junit测试用例

I got the following error,

我收到以下错误,

A fatal error has been detected by the Java Runtime Environment:

Internal Error (classFileParser.cpp:3174), pid=2680, tid=2688

  Error: ShouldNotReachHere()

  JRE version: 6.0_18-b07

  Java VM: Java HotSpot(TM) Client VM (16.0-b13 mixed mode windows-x86 )

Can any body please suggest the solution to resolve

任何机构都可以提出解决方案

回答by Zac Thompson

You'll need to take this up with Sun -- looks like a JVM bug to me. If it's reproducible, you should be able to run java in such a way as to generate more details (e.g. -verbose, etc). If you can reduce it to a minimal case that triggers the bug (source code always helps!), that also goes a very long way.

您需要向 Sun 解决这个问题——对我来说这看起来像是一个 JVM 错误。如果它是可重现的,您应该能够以生成更多详细信息的方式运行 java(例如 -verbose 等)。如果您可以将其减少到触发错误的最小情况(源代码总是有帮助的!),那也有很长的路要走。

http://java.sun.com/developer/technicalArticles/bugreport_howto/index.html

http://java.sun.com/developer/technicalArticles/bugreport_howto/index.html

http://bugreport.sun.com/bugreport/crash.jsp

http://bugreport.sun.com/bugreport/crash.jsp

In the meantime, you might want to try it with a different JVM implementation (maybe even an older patch level of the Sun JRE).

同时,您可能想尝试使用不同的 JVM 实现(甚至可能是 Sun JRE 的旧补丁级别)。

回答by Stephen C

This could be a JVM bug; see @Zac's answer. But it could also be that your junit test case is causing a corrupted bytecode file to be loaded. Try rebuilding all your .classfiles, and if that does not fix the problem try refetching any external libraries that your code depends on.

这可能是一个 JVM 错误;请参阅@Zac 的回答。但也可能是您的 junit 测试用例导致加载损坏的字节码文件。尝试重建您的所有.class文件,如果这不能解决问题,请尝试重新获取您的代码所依赖的任何外部库。

回答by Thorbj?rn Ravn Andersen

Do you run on a supported platform (Windows, one of a few Linux versions?) If not, that is the first to try.

您是否在受支持的平台上运行(Windows,几个 Linux 版本之一?)如果不是,那就是第一个尝试。

If you ARE on a supported platform, then downgrade to _17 and see if THAT helps.

如果您在受支持的平台上,请降级到 _17,看看是否有帮助。

Then make a bug report to Sun and hope they will fix it someday (unless you want to give them money for fixing it faster).

然后向 Sun 提交错误报告,希望他们有一天会修复它(除非您想给他们钱以加快修复速度)。

回答by Michael Borgwardt

Another possible explanation: hardware failure. Ruled out if you can reproduce the error on different machines.

另一种可能的解释:硬件故障。排除是否可以在不同机器上重现该错误。

回答by Nick Craig-Wood

I resolved this by

我解决了这个问题

  • Quit eclipse
  • Delete the binand gendirectories in your project
  • Start eclipse
  • Rebuild your project
  • 退出日食
  • 删除项目中的bingen目录
  • 开始日食
  • 重建你的项目

回答by Fredrik

I got the same problem, but with alot of googling I found the answer! See this page

我遇到了同样的问题,但是通过大量的谷歌搜索我找到了答案!看这个页面

Quote from the link:

引自链接:



# An unexpected error has been detected by Java Runtime Environment:
#
#  Internal Error (classFileParser.cpp:2924), pid=5364, tid=6644
#  Error: ShouldNotReachHere
  1. That's because we are using Android's JUnit stub implementation. Go to Run -> Run As -> Run configurations again and in the recently created JUnit configuration Classpath's Bootstrap Entries remove Android Library
  2. Then Add Library, using Advanced... button, and add JRE System Library and JUnit 3
  3. Apply and Run
  1. 那是因为我们正在使用 Android 的 JUnit 存根实现。转到运行 -> 运行方式 -> 再次运行配置,并在最近创建的 JUnit 配置类路径的 Bootstrap Entries 中删除 Android 库
  2. 然后添加库,使用高级...按钮,并添加 JRE 系统库和 JUnit 3
  3. 应用并运行


Try this, it worked for me.

试试这个,它对我有用。

回答by volody

I just recently found solution for this issue that was posted by devdanke:

我最近刚刚找到了devdanke发布的这个问题的解决方案:

"As of 11-July-2010 and Android 2.1, the work around I use is to segregate tests into different classes. Any test(s) that don't call any Android APIs go into their own classes. For each of these classes, I remove the reference to Android in their Run Configurations, Classpath tab."

“从 2010 年 7 月 11 日和 Android 2.1 开始,我使用的工作是将测试隔离到不同的类中。任何不调用任何 Android API 的测试都进入它们自己的类。对于这些类中的每一个,我在他们的运行配置,类路径选项卡中删除了对 Android 的引用。”

The problem with having it configured class by class is then is not possible to run all tests in project. Better approach is creating 2 test projects with different sets of libraries.

逐类配置它的问题是不可能在项目中运行所有测试。更好的方法是使用不同的库集创建 2 个测试项目。

Standard Android JUnit Test project can be created following link, and sample test class looks like:

可以通过以下链接创建标准的 Android JUnit 测试项目,示例测试类如下所示:

import android.test.AndroidTestCase;
public class ConverterTest extends AndroidTestCase {
    public void testConvert() {
        assertEquals("one", "one");
    }   
}

Then JUnit Test project can be converted from Android JUnit Test project by removing Android Library from project build path, and adding JRE System Library, and JUnit 3 library, and sample test class looks like:

然后可以通过从项目构建路径中删除 Android 库,并添加 JRE 系统库和 JUnit 3 库,从 Android JUnit 测试项目转换 JUnit 测试项目,示例测试类如下所示:

import junit.framework.TestCase;
public class ConverterTest extends TestCase{
    public void testConvert() {
        assertEquals("one", "one");
    }   
}

回答by fsommar

Another possible reason (for future references): I had accidentally copied in a main method in my code, causing Eclipse to recognize the project as a java application, thus launching it with that configuration.

另一个可能的原因(供以后参考):我不小心在我的代码中复制了一个 main 方法,导致 Eclipse 将项目识别为 Java 应用程序,从而使用该配置启动它。

To solve it I went into Run > Run Configurations... and then changed from my presumed main in java application to the main activity of my android application simply by choosing it in the left column.

为了解决这个问题,我进入了 Run > Run Configurations... 然后从我在 java 应用程序中假定的 main 更改为我的 android 应用程序的 main Activity,只需在左栏中选择它即可。

回答by Jeff Dyer

I have had a similar problem, I found it was because I had generated a new activity with a main[] stub entry. Once I deleted the main[] code from the new activity templatye the error went away.

我遇到了类似的问题,我发现这是因为我生成了一个带有 main[] 存根条目的新活动。一旦我从新的活动模板中删除了 main[] 代码,错误就消失了。

YMMV

青年会

回答by isuru chathuranga

Go to Run As-> Run Configurations...and select the configuration you are using.
Select the Class Pathtab and select BootStrap Entries.
Click on Advance, then Add Libraryand select JRE System Library.
Bring it up and make it the first entry in the BootstrapEntries List.

Apply and Run...

转到Run As-> Run Configurations...并选择您正在使用的配置。
选择Class Path选项卡并选择BootStrap Entries
单击Advance,然后单击Add Library并选择JRE System Library
将其调出并使其成为 BootstrapEntries 列表中的第一个条目。

应用并运行...