1
使用SCO OpenServer 5.0.7操作系統。 我的JVM是版本1.4,也有我的1.5Java虛擬機崩潰
當我想要在GUI文本字段中輸入範圍0x80 - 0x9f中的字符時,我的JVM將CPU加載到100%,並且唯一的方法是停止它是殺死jvm進程。
當我在java控制檯應用程序中輸入相同範圍內的字符時,它都很好。
我猜jvm如何插入控制檯標準輸入和GUI關鍵事件。
有沒有人有想法,我該如何解決這個問題?
我不說話,它是一個程序流程。這裏是一個崩潰非標準例如:
// 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崩潰的關鍵事件作出的時刻,所以我無法從我的計劃之內debugg它。
嘗試使用'jstack'來查看JVM掛起哪些代碼。 – 2010-05-25 13:56:45
在沒有看到任何代碼的情況下很難提供任何幫助。這可能是一個JVM漏洞 - 或者可能是你有一個bug。如果您可以發佈一個簡短但完整的程序來演示問題,那將有所幫助。 – 2010-05-25 13:57:05