Java虚拟机崩溃 [英] Java Virtual Machine crashes

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

问题描述

使用SCO OpenServer 5.0.7操作系统。
我的JVM是版本1.4,并且我有1.5

Im using SCO OpenServer 5.0.7 operating system. My JVM is version 1.4 and also I have 1.5

当我尝试在GUI文本字段中输入0x80 - 0x9f的字符时,我的JVM

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.

当我在java控制台应用程序中输入相同范围的字符时,它会将CPU加载到100%,并且停止它的唯一方法是终止jvm进程。

When I input character in same range in java console application, It is all fine.

我猜想有一个不同的jvm interpetating控制台stdin和GUI键事件。

I'm guessing there is a diffrence how jvm interpetating console stdin and GUI key events.

有人有一个想法,我该如何解决这个问题?

Does anybody have an idea, how can I fix this problem?

我不是beleave,这是一个程序流。这是一个崩溃的标准示例:

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

问题是,jvm当时崩溃

The problem is that, jvm crashes at the moment the key event is made, so I cannot debugg it from within my program.

推荐答案

这两个环境之间可能存在差异,考虑默认 Charset 。我注意到NetBeans,Eclipse和许多控制台可以设置为平台默认以外的其他。它不会伤害检查:

There might be a disparity between the two environments with regard to the default Charset. I've noticed that NetBeans, Eclipse and many consoles can be set to something other than the platform default. It couldn't hurt to check:

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

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

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