简体   繁体   English

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

[英]Fatal error by Java runtime environment

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 任何人都可以建议解决方案

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. 那是因为我们正在使用Android的JUnit存根实现。 Go to Run -> Run As -> Run configurations again and in the recently created JUnit configuration Classpath's Bootstrap Entries remove Android Library 转到运行 - >运行方式 - >再次运行配置,在最近创建的JUnit配置中,Classpath的Bootstrap条目删除Android库
  2. Then Add Library, using Advanced... button, and add JRE System Library and JUnit 3 然后使用Advanced ...按钮添加库,并添加JRE System Library和JUnit 3
  3. Apply and Run 申请并运行

Try this, it worked for me. 试试这个,它对我有用。

Go to Run As -> Run Configurations... and select the configuration you are using. 转至运行方式 - > 运行配置...并选择您正在使用的配置。
Select the Class Path tab and select BootStrap Entries . 选择Class Path选项卡,然后选择BootStrap Entries
Click on Advance , then Add Library and select JRE System Library . 单击Advance ,然后单击Add Library并选择JRE System Library
Bring it up and make it the first entry in the BootstrapEntries List. 提出它并使其成为BootstrapEntries列表中的第一个条目。

Apply and Run... 申请并运行...

You'll need to take this up with Sun -- looks like a JVM bug to me. 你需要对Sun采取这种做法 - 对我来说看起来像一个JVM错误。 If it's reproducible, you should be able to run java in such a way as to generate more details (eg -verbose, etc). 如果它是可重现的,您应该能够以生成更多细节的方式运行java(例如-verbose等)。 If you can reduce it to a minimal case that triggers the bug (source code always helps!), that also goes a very long way. 如果你可以将它减少到触发bug的最小情况(源代码总是有帮助的!),这也是一个很长的路要走。

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的旧补丁级别)。

Another possible explanation: hardware failure. 另一种可能的解释:硬件故障。 Ruled out if you can reproduce the error on different machines. 如果您可以在不同的计算机上重现错误,则排除在外。

I resolved this by 我解决了这个问题

  • Quit eclipse 退出日食
  • Delete the bin and gen directories in your project 删除项目中的bingen目录
  • Start eclipse 开始日食
  • Rebuild your project 重建您的项目

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 Test项目,示例测试类如下所示:

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 Test项目转换JUnit Test项目:

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

I have had a similar problem, I found it was because I had generated a new activity with a main[] stub entry. 我遇到了类似的问题,我发现这是因为我使用main []存根条目生成了一个新活动。 Once I deleted the main[] code from the new activity templatye the error went away. 一旦我从新活动templatye中删除了main []代码,错误便消失了。

YMMV 因人而异

Go to Run As -> Run Configurations->classpath->BootStrap Entries Click on Advance, then Add Library and select JRE System Library as a first entry. 转至运行方式 - >运行配置 - >类路径 - > BootStrap条目单击高级,然后单击添加库并选择JRE系统库作为第一个条目。 Apply and Run... 申请并运行...

I am not sure whether you were able to reach the solution for your problem or not but your question just popped up while I was searching for the solution for the same problem I am facing. 我不确定您是否能够为您的问题找到解决方案,但是当我在寻找我面临的同样问题的解决方案时,您的问题刚刚出现。 And I got one solution from the stack itself, so just thought to share a link with you if that aids you by any means. 我从堆栈本身得到了一个解决方案,所以只要想与你分享一个链接,如果这无论如何都有助于你。 The link is as below: 链接如下:

Can't run JUnit 4 test case in Eclipse Android project 无法在Eclipse Android项目中运行JUnit 4测试用例

This could be a JVM bug; 这可能是一个JVM错误; see @Zac's answer. 看@Zac的回答。 But it could also be that your junit test case is causing a corrupted bytecode file to be loaded. 但也可能是你的junit测试用例导致加载了损坏的字节码文件。 Try rebuilding all your .class files, and if that does not fix the problem try refetching any external libraries that your code depends on. 尝试重建所有.class文件,如果这不能解决问题,请尝试重新获取代码所依赖的任何外部库。

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报告错误并希望他们有一天会修复它(除非你想给他们钱以更快地修复它)。

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应用程序的主要活动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM