Java ShouldNotReachHere错误 [英] Java ShouldNotReachHere error

查看:191
本文介绍了Java ShouldNotReachHere错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试改变源码的背景颜色,但是java给我内部致命的错误消息。你能告诉我我做错了什么

  import java.awt。*; 
import java.awt.event。*;
import javax.swing。*;

class ButtonPanel扩展JPanel
{
private JButton yellowButton = new JButton(Yellow);

public ButtonPanel()//构造函数
{

// setLayout是在该构造函数中调用的JPanel中的一个方法
setLayout(new FlowLayout (FlowLayout.LEFT));
add(yellowButton);
actions actionsSpecified = new actions();

yellowButton.addActionListener(actionsSpecified);
}
}

类操作实现ActionListener
{
// actionPerformed是一个muse被覆盖的接口
public void actionPerformed(ActionEvent evt)
{
//知道事件从哪里生成(从按钮,滚动条等)
JButton source =(JButton)evt.getSource();

颜色colorYellow = Color.yellow;
source.setBackground(colorYellow);

/ *颜色color = getContentPane()。getBackground();
if(source == yellowButton)
color = Color.yellow;
else if(source == blueButton)
color = Color.blue;
else if(source == redButton)
color = Color.red;
setBackground(color);
repaint(); * /
}
}


类ButtonFrame扩展JFrame
{
public ButtonFrame()
{
setTitle(ButtonTest);
setSize(300,200);
addWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});

容器contentPane = getContentPane();
contentPane.add(new ButtonPanel());
}
}

class ButtonTest
{
public static void main(String [] args)
{
JFrame框架= new ButtonFrame();
frame.show();
}
}

错误消息--------- -----------------------------------


#Java Runtime Environment检测到一个致命错误:

#Internal Error(classFileParser.cpp:3375),pid = 1156 ,tid = 6332
#错误:ShouldNotReachHere()

#JRE版本:6.0_23-b05
#Java VM:Java HotSpot(TM)64位服务器虚拟机19.0-b09混合模式windows-amd64压缩oops)
#更多信息的错误报告文件保存为:
#C:\Program Files(x86)\eclipse\android-sdk- windows\samples\android-8\Snake\hs_err_pid1156.log

#如果你想提交一个错误报告,请访问:
#http:// java .sun.com / webapps / bugreport / crash.jsp

这里是日志-------------------------------------------------- ---------------

 
#一个致命的错误已经由Jav检测一个运行时环境:

#内部错误(classFileParser.cpp:3375),pid = 1156,tid = 6332
#错误:ShouldNotReachHere()

#JRE版本:6.0_23-b05
#Java VM:Java HotSpot(TM)64位服务器虚拟机(19.0-b09混合模式windows-amd64压缩的oops)
#如果你想提交一个错误报告,请访问:
#http://java.sun.com/webapps/bugreport/crash.jsp


--------- ------ THREAD ---------------

当前线程(0x00000000005fb800):JavaThread未知线程[_thread_in_vm,id = 6332,stack( 0x0000000002590000,0x0000000002690000)]

堆栈:[0x0000000002590000,0x0000000002690000]
[错误报告(打印堆栈边界)时发生错误,id 0xc0000005]


--------------- PROCESS ---------------

Java线程:(=>当前线程)

其他线程:

=> 0x00000000005fb800(退出)JavaThread未知线程[_thread_in_vm,id = 6332,堆栈(0x0000000002590000,0x0000000002690000)]

VM状态:不在safepoint(未完全初始化)

VM当前由线程拥有的Mutex / Monitor:$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ b 0x0000000000400000 - 0x000000000042e000 C:\Program Files\Java\jre6\bin\javaw.exe
0x0000000077850000 - 0x00000000779f9000 C:\Windows\SYSTEM32\\\
tdll.dll
0x0000000077420000 - 0x000000007753f000 C:\Windows\system32\kernel32.dll
0x000007fefe010000 - 0x000007fefe07b000 C:\Windows\system32\KERNELBASE.dll
0x000007feff600000 - 0x000007feff6db000 C:\Windows\system32\\ \\ ADVAPI32.dll
0x000007feffa40000 - 0x000007feffadf000 C:\Windows\system32\msvcrt.dll
0x000007feff6e0000 - 0x000007feff6ff000 C:\Windows \SYSTEM32\sechost.dll
0x000007feff2f0000 - 0x000007feff41d000 C:\Windows\system32\RPCRT4.dll
0x0000000077750000 - 0x000000007784a000 C:\Windows\system32\USER32.dll
0x000007feff590000 - 0x000007feff5f7000 C:\Windows\system32\GDI32.dll
0x000007feffa30000 - 0x000007feffa3e000 C:\Windows\system32\LPK.dll
0x000007feff780000 - 0x000007feff849000 C:\Windows \system32\USP10.dll
0x000007feff2c0000 - 0x000007feff2ee000 C:\Windows\system32\IMM32.DLL
0x000007fefe170000 - 0x000007fefe279000 C:\Windows\system32\MSCTF.dll
0x000007fefdc90000 - 0x000007fefdcaf000 C:\Windows\system32\\\
vinitx.dll
0x000000006d7f0000 - 0x000000006dee0000 C:\Program Files\Java\jre6\bin\server\jvm.dll
0x000007fefb930000 - 0x000007fefb96b000 C:\Windows\system32\WINMM .dll
0x000000006d760000 - 0x000000006d76e000 C:\Program Files\Java\jre6\bin\verify.dll
0x000000006d3b0000 - 0x000000006d3d7000 C:\Program Files\Java\jre6\ bin \java.dll
0x000000006d310000 - 0x000000006d31a000 C:\Program Files\Java\jre6\bin\hpi.dll
0x0000000077a20000 - 0x0000000077a27000 C:\Windows\system32\ PSAPI.DLL
0x000000006d7b0000 - 0x000000006d7c2000 C:\Program Files\Java\jre6\bin\zip.dll

VM参数:
jvm_args:-Dfile。 encoding = Cp1252 -Xbootclasspath:C:\Program Files(x86)\eclipse\android-sdk-windows\platforms\android-8\android.jar
java_command:dalvik.system.TouchDex
启动器类型:SUN_STANDARD

环境变量:
CLASSPATH =; C:\Program文件(x86)\Java\jre6\lib\ext\QTJava .zip
PATH = C:/ Program Files / Java / jdk1.6.0_23 / bin /../ jre / bin / server; C:/ Program Files / Java / jdk1.6.0_23 / bin /../ jre / bin; C:/ Program Files / Java / jdk1.6.0_23 / bin / .. / jre / lib / amd64; C:\Program Files\Common Files\Microsoft Shared\Windows Live; C:\Program Files\Java\jdk1.6.0_23\bin; C:\Windows \system32; C:\Windows; C:\Windows\System32\Wbem; C:\Windows\System32\WindowsPowerShell\v1.0\; c:\Program Files\WIDCOMM \Bluetooth Software\; c:\Program Files\WIDCOMM\Bluetooth Software\syswow64; C:\Program Files(x86)\QuickTime\QTSystem\; C:\Program Files(x86 )\蚀;
USERNAME =
OS = Windows_NT
PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 37 Stepping 5,GenuineIntel



------ --------- SYSTEM ---------------

操作系统:Windows 7 Build 7601 Service Pack 1

CPU:总共4个(每个CPU 2个核心,每个核心2个线程)家族6模型37步骤5,cmov,cx8,fxsr,mmx,sse,sse2,sse3,ssse3,sse4.1,sse4.2,popcnt,ht

内存:4k页面,物理3920176k(1115300k免费),交换7838504k(4088064k免费)

vm_info:Java HotSpot(TM)64位服务器虚拟机(19.0-b09)对于Windows-amd64 JRE(1.6.0_23-b05),建立于2010年11月13日02:43:42由VC ++ 8.0(VS2005)的java_re

时间:Fri Jun 10 16:11 :50 2011
经过时间:0秒


解决方案

许多示例使用此模式启动Swing应用程序。你可能想尝试一下。整个目的是在Swing Thread中创建Swing组件。

  public static void main(String [] args){
//为事件调度线程安排作业:
//创建并显示此应用程序的GUI。
javax.swing.SwingUtilities.invokeLater(new Runnable(){
public void run(){
JFrame frame = new ButtonFrame();
frame.show();
}
});
}

编辑:仔细查看问题后。您不能在Android / Dalvik平台上运行Swing。正如其他人已经评论的那样,如果在Sun JVM上运行,那么您似乎在Android模拟器下运行它。这是行不通的。



如果您尝试在Android上运行,请更新您的标签以包含Android。


I am trying to change the background color of the source but java gives me internal fatal error occurred message. can you tell me what I am doing wrong.

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;

    class ButtonPanel extends JPanel 
    {  
        private JButton yellowButton = new JButton("Yellow");

        public ButtonPanel()//constructor
        {  

              //setLayout is a method in JPanel that is called in this constructor
              setLayout (new FlowLayout(FlowLayout.LEFT));
              add(yellowButton);
              actions actionsSpecified = new actions();

              yellowButton.addActionListener(actionsSpecified);
           }
        }

    class actions implements ActionListener
    {
        //actionPerformed is an interface that muse be overriden
        public void actionPerformed(ActionEvent evt)
        {  
            // knows where the event is generated from(from a button, scrollbar etc...)
              JButton source = (JButton) evt.getSource();

              Color colorYellow = Color.yellow;
              source.setBackground(colorYellow);

           /*Color color = getContentPane().getBackground();
           if (source == yellowButton) 
              color = Color.yellow;
           else if (source == blueButton) 
              color = Color.blue;
           else if (source == redButton) 
              color = Color.red;
           setBackground(color);
           repaint();*/
        }
    }


    class ButtonFrame extends JFrame
    {  
            public ButtonFrame()
            {  
                setTitle("ButtonTest");
                setSize(300, 200);
                addWindowListener(new WindowAdapter()
                 {  public void windowClosing(WindowEvent e)
                    {  
                     System.exit(0);
                    }
                 } );

              Container contentPane = getContentPane();
              contentPane.add(new ButtonPanel());
          }
    }

    class ButtonTest
    {  
        public static void main(String[] args)
        {  
            JFrame frame = new ButtonFrame();
            frame.show();  
        }
    }

Error message --------------------------------------------

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (classFileParser.cpp:3375), pid=1156, tid=6332
#  Error: ShouldNotReachHere()
#
# JRE version: 6.0_23-b05
# Java VM: Java HotSpot(TM) 64-Bit Server VM (19.0-b09 mixed mode windows-amd64 compressed oops)
# An error report file with more information is saved as:
# C:\Program Files (x86)\eclipse\android-sdk-windows\samples\android-8\Snake\hs_err_pid1156.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#

here is the log -----------------------------------------------------------------

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (classFileParser.cpp:3375), pid=1156, tid=6332
#  Error: ShouldNotReachHere()
#
# JRE version: 6.0_23-b05
# Java VM: Java HotSpot(TM) 64-Bit Server VM (19.0-b09 mixed mode windows-amd64 compressed oops)
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#

---------------  T H R E A D  ---------------

Current thread (0x00000000005fb800):  JavaThread "Unknown thread" [_thread_in_vm, id=6332, stack(0x0000000002590000,0x0000000002690000)]

Stack: [0x0000000002590000,0x0000000002690000]
[error occurred during error reporting (printing stack bounds), id 0xc0000005]


---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )

Other Threads:

=>0x00000000005fb800 (exited) JavaThread "Unknown thread" [_thread_in_vm, id=6332, stack(0x0000000002590000,0x0000000002690000)]

VM state:not at safepoint (not fully initialized)

VM Mutex/Monitor currently owned by a thread: None

Dynamic libraries:
0x0000000000400000 - 0x000000000042e000     C:\Program Files\Java\jre6\bin\javaw.exe
0x0000000077850000 - 0x00000000779f9000     C:\Windows\SYSTEM32\ntdll.dll
0x0000000077420000 - 0x000000007753f000     C:\Windows\system32\kernel32.dll
0x000007fefe010000 - 0x000007fefe07b000     C:\Windows\system32\KERNELBASE.dll
0x000007feff600000 - 0x000007feff6db000     C:\Windows\system32\ADVAPI32.dll
0x000007feffa40000 - 0x000007feffadf000     C:\Windows\system32\msvcrt.dll
0x000007feff6e0000 - 0x000007feff6ff000     C:\Windows\SYSTEM32\sechost.dll
0x000007feff2f0000 - 0x000007feff41d000     C:\Windows\system32\RPCRT4.dll
0x0000000077750000 - 0x000000007784a000     C:\Windows\system32\USER32.dll
0x000007feff590000 - 0x000007feff5f7000     C:\Windows\system32\GDI32.dll
0x000007feffa30000 - 0x000007feffa3e000     C:\Windows\system32\LPK.dll
0x000007feff780000 - 0x000007feff849000     C:\Windows\system32\USP10.dll
0x000007feff2c0000 - 0x000007feff2ee000     C:\Windows\system32\IMM32.DLL
0x000007fefe170000 - 0x000007fefe279000     C:\Windows\system32\MSCTF.dll
0x000007fefdc90000 - 0x000007fefdcaf000     C:\Windows\system32\nvinitx.dll
0x000000006d7f0000 - 0x000000006dee0000     C:\Program Files\Java\jre6\bin\server\jvm.dll
0x000007fefb930000 - 0x000007fefb96b000     C:\Windows\system32\WINMM.dll
0x000000006d760000 - 0x000000006d76e000     C:\Program Files\Java\jre6\bin\verify.dll
0x000000006d3b0000 - 0x000000006d3d7000     C:\Program Files\Java\jre6\bin\java.dll
0x000000006d310000 - 0x000000006d31a000     C:\Program Files\Java\jre6\bin\hpi.dll
0x0000000077a20000 - 0x0000000077a27000     C:\Windows\system32\PSAPI.DLL
0x000000006d7b0000 - 0x000000006d7c2000     C:\Program Files\Java\jre6\bin\zip.dll

VM Arguments:
jvm_args: -Dfile.encoding=Cp1252 -Xbootclasspath:C:\Program Files (x86)\eclipse\android-sdk-windows\platforms\android-8\android.jar 
java_command: dalvik.system.TouchDex
Launcher Type: SUN_STANDARD

Environment Variables:
CLASSPATH=.;C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip
PATH=C:/Program Files/Java/jdk1.6.0_23/bin/../jre/bin/server;C:/Program Files/Java/jdk1.6.0_23/bin/../jre/bin;C:/Program Files/Java/jdk1.6.0_23/bin/../jre/lib/amd64;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files\Java\jdk1.6.0_23\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;c:\Program Files\WIDCOMM\Bluetooth Software\;c:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\eclipse;
USERNAME=
OS=Windows_NT
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 37 Stepping 5, GenuineIntel



---------------  S Y S T E M  ---------------

OS: Windows 7 Build 7601 Service Pack 1

CPU:total 4 (2 cores per cpu, 2 threads per core) family 6 model 37 stepping 5, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, ht

Memory: 4k page, physical 3920176k(1115300k free), swap 7838504k(4088064k free)

vm_info: Java HotSpot(TM) 64-Bit Server VM (19.0-b09) for windows-amd64 JRE (1.6.0_23-b05), built on Nov 13 2010 02:43:42 by "java_re" with MS VC++ 8.0 (VS2005)

time: Fri Jun 10 16:11:50 2011
elapsed time: 0 seconds

解决方案

Many examples use this pattern for launching a Swing app. You might want to try it. The whole purpose is to create the Swing components inside the Swing Thread.

public static void main(String[] args) {
    //Schedule a job for the event-dispatching thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
             JFrame frame = new ButtonFrame();
             frame.show(); 
        }
    });
}

EDIT: After looking through the question more carefully. You cannot run Swing on the Android/Dalvik platform. As other people have commented it works fine if running on a Sun JVM, You seem to be running it under the Android emulator. That will not work.

Please update your tags to include Android if you are trying to run this on Android.

这篇关于Java ShouldNotReachHere错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆