I am executing a junit test case

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

No correct solution


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

Try this, it worked for me.

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.

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

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

Apply and Run...

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
  • Start eclipse
  • Rebuild your project

I just recently found solution for this issue that was posted by 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."

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.

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

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:

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. Once I deleted the main[] code from the new activity templatye the error went away.


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 .class files, and if that does not fix the problem try refetching any external libraries that your code depends on.

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

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

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).

Go to Run As -> Run Configurations->classpath->BootStrap Entries Click on Advance, then Add Library and select JRE System Library as a first entry. 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

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top