eclipse 内部错误 (javaClasses.cpp:129)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12273118/
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
Internal Error (javaClasses.cpp:129)
提问by Fran b
I'm trying run a test with JUnit 4 and Robolectric on Eclipse but all time I receive this error:
我正在尝试在 Eclipse 上使用 JUnit 4 和 Robolectric 运行测试,但我一直收到此错误:
Invalid layout of java.lang.String at value
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (javaClasses.cpp:129), pid=3546, tid=140317899335424
# fatal error: Invalid layout of preloaded class
#
# JRE version: 7.0_07-b10
# Java VM: Java HotSpot(TM) 64-Bit Server VM (23.3-b01 mixed mode linux-amd64 compressed oops)
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
My test is very easy. It's only for check all work:
我的考试很简单。它仅用于检查所有工作:
@RunWith(RobolectricTestRunner.class)
public class FormatTest {
@Test
public void getFormatElapsedTimeOnSecondsTest(){
assertEquals("3seg","3seg");
}
}
Java installed on my system is:
我的系统上安装的 Java 是:
java version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)
I don't understand what happen.
我不明白发生了什么。
回答by Jeff Schultz
This may not be your issue but I was able to get past this by using the Run As -> Android Application.
这可能不是您的问题,但我能够通过使用 Run As -> Android Application 来解决这个问题。
However, I'm not sure if you are using android or not. Possibly check the Run configuration for other issues.
但是,我不确定您是否使用 android。可能检查运行配置是否有其他问题。
回答by Limentaris
You need to correct your run configuration.
您需要更正运行配置。
If you want to run an JUnit test with
如果要运行 JUnit 测试
"right click on test class in the package explorer"->"Run As"->"JUnit Test"
on an android project, you need to set the "Android JUnit Test Launcher" as launcher. You have do use that android launcher even if your launch configuration has the type "JUnit".
在 android 项目上,您需要将“Android JUnit 测试启动器”设置为启动器。即使您的启动配置具有“JUnit”类型,您也确实使用了该 android 启动器。
You can find it under:
你可以在下面找到它:
"right click on test class in the package explorer"->"Properties"->"Run/Debug Settings"->"Edit..."
Example:
示例:
Test:
测试:
import junit.framework.TestCase;
public class ExampleTest extends TestCase{
public ExampleTest(String name){
super(name);
}
protected void setUp() throws Exception{
super.setUp();
}
protected void tearDown() throws Exception{
super.tearDown();
}
public void testFoo(){
fail("Not yet implemented");
}
}
}
Create run configuration:
创建运行配置:
"Run"->"Run Configurations..."->"Right click on JUnit"->"New"->"Set project and Test class"->"Select Android JUnit Test Launcher"->"Run"
Notice: If you are using an x86 jdk you will get the following error if your Launcher is set to "Eclipse JUnit Launcher":
注意:如果您使用的是 x86 jdk,如果您的 Launcher 设置为“Eclipse JUnit Launcher”,您将收到以下错误:
Invalid layout of java.lang.String at value
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (javaClasses.cpp:129), pid=3844, tid=4828
# fatal error: Invalid layout of preloaded class
#
# JRE version: 7.0_17-b02
# Java VM: Java HotSpot(TM) Client VM (23.7-b01 mixed mode windows-x86 )
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
回答by Cas Knook
For me was the solution: Run -> Run Configurations... ->at tab Test click Select Preferred Launcherand select Use configuration specific settingswith selection Android JUnit Test Launcher.
对我来说是解决方案:Run -> Run Configurations... ->在选项卡 Test 单击Select Preferred Launcher并选择Use configuration specific settingswith selection Android JUnit Test Launcher。
Delete all entries under JUnit (left column of Run Configurations dialog; RightMouse - Delete).
删除 JUnit 下的所有条目(运行配置对话框的左列;RightMouse - 删除)。
Then Run as -> JUnit Testand optionally select Use configuration specific settings with Android JUnit Test Launcher.
然后Run as -> JUnit Test并可选地选择Use configuration specific settings with Android JUnit Test Launcher。
回答by Alex Sales
Right click java class with main, run configurations then go to classpath tab, remove the android library there. then run.
右键单击带有 main 的 java 类,运行配置然后转到类路径选项卡,删除那里的 android 库。然后运行。
I hope this helps.
我希望这有帮助。
回答by alknows
It goes easier. Got to Run->Configuration and look for JUnit and Android JUnit Tests. Delete your config if it is there. Then the next time you click on Run it will ask about the configuration. You choose first JUnit and then in the next dialog activate "Use configuration specific settings" and then choose Android JUnit Test Laucher.
它变得更容易。转到运行->配置并查找 JUnit 和 Android JUnit 测试。如果存在,请删除您的配置。然后下次单击“运行”时,它会询问有关配置的信息。您首先选择 JUnit,然后在下一个对话框中激活“使用配置特定设置”,然后选择 Android JUnit Test Laucher。
回答by Arpana
Same issue encountered to me as well and reason was I added main(String s[]) method in my android project.
我也遇到了同样的问题,原因是我在我的 android 项目中添加了 main(String s[]) 方法。
So just remove main(String s[]) method from project and run as Android Application.
所以只需从项目中删除 main(String s[]) 方法并作为 Android 应用程序运行。