views:

849

answers:

7

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

+3  A: 

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.

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

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

Zac Thompson
A: 

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.

Stephen C
A corrupted byte code? Causing a JVM crash?Have you actually SEEN that happen?
Thorbjørn Ravn Andersen
No. But it is plausible, and not that difficult to check for ... while he is waiting for Sun to respond.
Stephen C
A: 

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

Thorbjørn Ravn Andersen
+1  A: 

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

Michael Borgwardt
A: 

I resolved this by

  • Quit eclipse
  • Delete the bin and gen directories in your project
  • Start eclipse
  • Rebuild your project
Nick Craig-Wood
+1  A: 

Hi

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.

Fredrik
This worked for me at least................ Thanks ........... +1 to you
viv
A: 

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");
    }   
}
volody