简体   繁体   English

Java虚拟机崩溃

[英]Java Virtual Machine crashes

Im using SCO OpenServer 5.0.7 operating system. 我使用的是SCO OpenServer 5.0.7操作系统。 My JVM is version 1.4 and also I have 1.5 我的JVM是1.4版,我也有1.5版

When I'm trying to input a character in range 0x80 - 0x9f in GUI Text field, my JVM loads the CPU up to 100%, and the only way to stop It is to kill the jvm process. 当我试图在GUI Text字段中输入范围0x80-0x9f的字符时,我的JVM最多将CPU加载到100%,而停止的唯一方法是杀死jvm进程。

When I input character in same range in java console application, It is all fine. 当我在Java控制台应用程序中的相同范围内输入字符时,一切都很好。

I'm guessing there is a diffrence how jvm interpetating console stdin and GUI key events. 我猜jvm如何干扰控制台stdin和GUI键事件。

Does anybody have an idea, how can I fix this problem? 有人知道吗,我该如何解决这个问题?

I dont beleave, It is a program flow. 我不相信,这是一个程序流程。 Here is a standart example which crashes: 这是一个崩溃的标准示例:

// TextForm.java

import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JTextField;

import java.awt.Insets;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.BorderLayout;
import java.awt.Container;

import java.awt.event.*;

public class TextForm extends JPanel {

   private final JTextField[] tf;

   // Create a form with the given labels, tooltips, and sizes
   public TextForm (String[] labels, String[] tips, int[] widths) {
      tf = new JTextField[labels.length];

      setLayout (new GridBagLayout());
      final GridBagConstraints gbc = new GridBagConstraints();
      gbc.anchor = GridBagConstraints.WEST;
      gbc.insets = new Insets (3,3,3,3);

      // Add labels and fields as specified
      for (int i=0; i<labels.length; i++) {
         final JLabel l = new JLabel (labels[i]);

         // Create an accessibility-friendly field
         tf[i] = new JTextField (widths[i]);
         tf[i].setToolTipText (tips[i]); // sets accessible desc too!
         l.setLabelFor (tf[i]);          // sets accessibleName for tf[i]!

         // lay out label & field
         gbc.gridy = i;
         gbc.gridx = 0;
         add(l, gbc);
         gbc.gridx = 1;
         add(tf[i], gbc);
    }
  }

   // Get the contents of one of the TFs.
   public String getEnteredText(int index) {
      return tf[index].getText();
   }

   // A simple example program
   public static void main(String[] args) {
      final String[] labels = { "First Name", "Middle Initial", "Last Name", "Age" };
      final String[] descs = { "First Name","Middle Initial", "Last Name", "Age" };

      final int[] widths = { 15, 1, 15, 3 };

      final TextForm form = new TextForm(labels, descs, widths);

      // A button that dumps the field contents
      final JButton dump = new JButton("Dump");
      class DumpListener implements ActionListener {
         public void actionPerformed(ActionEvent ev) {
            System.out.println(form.getEnteredText(0));
            System.out.println(form.getEnteredText(1));
            System.out.println(form.getEnteredText(2));
            System.out.println(form.getEnteredText(3));
         }
      }
      dump.addActionListener (new DumpListener());

      final JFrame f = new JFrame("Text Form");
   //   frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); // Requires Java 1.3
      final Container c = f.getContentPane();
      c.setLayout (new BorderLayout());
      c.add(form, BorderLayout.CENTER);
      c.add(dump, BorderLayout.SOUTH);
      f.pack();
      f.setVisible(true);
  }
}

The problem is that, jvm crashes at the moment the key event is made, so I cannot debugg it from within my program. 问题在于,jvm在发生键事件时崩溃,因此我无法在程序中对其进行调试。

There might be a disparity between the two environments with regard to the default Charset . 关于默认Charset ,两种环境之间可能存在差异。 I've noticed that NetBeans, Eclipse and many consoles can be set to something other than the platform default. 我注意到,可以将NetBeans,Eclipse和许多控制台设置为平台默认值以外的其他值。 It couldn't hurt to check: 检查一下不会有什么坏处:

System.out.println(System.getProperty("file.encoding"));
System.out.println(Charset.defaultCharset().name());

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

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