-
Bug
-
Resolution: Cannot Reproduce
-
P3
-
None
-
1.2.2, 1.3.0
-
x86
-
windows_nt, windows_2000
Exception happens when text style, format, size and color are changed, then Look and Feel are changed.
Steps to Reproduce:
0- this issue is on WinNT/Netscape 4.5 browser
1- with the latest j2sdk build O, go to word applet link:
http://javaweb.eng.sun.com/~nancys/BrowserKestrelFCSO/Suite/QLhtml/7/8.html
2- scroll down to the 2nd applet, type some text, highlight, then change the alignment, size, color and font
3-change the look and feel from the Options menu.
4- may need to change the look and feel a couple of times
Result-exception below
javax.swing.text.StateInvariantError: Can't get line text
at javax.swing.text.WrappedPlainView.loadText(Unknown Source)
at javax.swing.text.WrappedPlainView.calculateBreakPosition(Unknown Source)
at javax.swing.text.WrappedPlainView$WrappedLine.calculateLineCount(Unknown Source)
at javax.swing.text.WrappedPlainView$WrappedLine.getPreferredSpan(Unknown Source)
at javax.swing.text.View.getMinimumSpan(Unknown Source)
at javax.swing.text.BoxView.calculateMajorAxisRequirements(Unknown Source)
at javax.swing.text.BoxView.checkRequests(Unknown Source)
at javax.swing.text.BoxView.getPreferredSpan(Unknown Source)
at javax.swing.text.WrappedPlainView.getPreferredSpan(Unknown Source)
at javax.swing.plaf.basic.BasicTextUI$RootView.getPreferredSpan(Unknown Source)
at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at javax.swing.JTextArea.getPreferredSize(Unknown Source)
at javax.swing.text.JTextComponent.getPreferredScrollableViewportSize(Unknown Source)
at javax.swing.JTextArea.getPreferredScrollableViewportSize(Unknown Source)
at javax.swing.ViewportLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at javax.swing.ScrollPaneLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at javax.swing.BoxLayout.checkRequests(Unknown Source)
at javax.swing.BoxLayout.minimumLayoutSize(Unknown Source)
at java.awt.Container.minimumSize(Unknown Source)
at java.awt.Container.getMinimumSize(Unknown Source)
at javax.swing.BoxLayout.checkRequests(Unknown Source)
at javax.swing.BoxLayout.layoutContainer(Unknown Source)
at java.awt.Container.layout(Unknown Source)
at java.awt.Container.doLayout(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validate(Unknown Source)
at javax.swing.JLayeredPane.addImpl(Unknown Source)
at java.awt.Container.add(Unknown Source)
at javax.swing.JRootPane.setContentPane(Unknown Source)
at javax.swing.JApplet.setContentPane(Unknown Source)
at DialogCreator.init(DialogCreator.java:54)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
zelony@eng 1999-11-11
***********************************
checked this bug in j2sdk1.3fcsP build and it still happens.
zelony@eng 1999-11-30
Name: tb29552 Date: 12/03/2000
JRE 1.2.2-006
The code below will make the JVM (Java.exe) crash under Windows 2000.
The following error is displayed in Windows:
--------------------------------------------------------------------------
"The instruction at 0x50264282 referenced memory at 0x0385e020. The memory
could not be 'read'".
(Unhandled exception in Java.exe (AWT.DLL) 0xc0000005 access violation)
Sometimes the following Java exception is generated (instead of crashing):
--------------------------------------------------------------------------
Exception occurred during event dispatching:
javax.swing.text.StateInvariantError: Can't get line text
at javax.swing.text.WrappedPlainView.loadText(WrappedPlainView.java,
Compiled Code)
at javax.swing.text.WrappedPlainView.calculateBreakPosition
(WrappedPlainView.java, Compiled Code)
at javax.swing.text.WrappedPlainView$WrappedLine.calculateLineCount
(WrappedPlainView.java, Compiled Code)
at javax.swing.text.WrappedPlainView$WrappedLine.getPreferredSpan
(WrappedPlainView.java, Compiled Code)
at javax.swing.text.View.getMinimumSpan(View.java, Compiled Code)
at javax.swing.text.BoxView.calculateMajorAxisRequirements
(BoxView.java, Compiled Code)
at javax.swing.text.BoxView.checkRequests(BoxView.java, Compiled Code)
at javax.swing.text.BoxView.layout(BoxView.java, Compiled Code)
at javax.swing.text.BoxView.setSize(BoxView.java, Compiled Code)
at javax.swing.text.WrappedPlainView.setSize(WrappedPlainView.java,
Compiled Code)
at javax.swing.plaf.basic.BasicTextUI$RootView.paint(BasicTextUI.java,
Compiled Code)
at javax.swing.plaf.basic.BasicTextUI.paintSafely(BasicTextUI.java,
Compiled Code)
at javax.swing.plaf.basic.BasicTextUI.paint(BasicTextUI.java, Compiled
Code)
at javax.swing.plaf.basic.BasicTextUI.update(BasicTextUI.java, Compiled
Code)
at javax.swing.JComponent.paintComponent(JComponent.java, Compiled Code)
at javax.swing.JComponent.paint(JComponent.java, Compiled Code)
at javax.swing.JComponent.paintChildren(JComponent.java, Compiled Code)
at javax.swing.JComponent.paint(JComponent.java, Compiled Code)
at javax.swing.JViewport.paint(JViewport.java, Compiled Code)
at javax.swing.JComponent.paintChildren(JComponent.java, Compiled Code)
at javax.swing.JComponent.paint(JComponent.java, Compiled Code)
at javax.swing.JComponent.paintChildren(JComponent.java, Compiled Code)
at javax.swing.JComponent.paint(JComponent.java, Compiled Code)
at javax.swing.JComponent.paintChildren(JComponent.java, Compiled Code)
at javax.swing.JComponent.paint(JComponent.java, Compiled Code)
at javax.swing.JComponent.paintChildren(JComponent.java, Compiled Code)
at javax.swing.JComponent.paint(JComponent.java, Compiled Code)
at javax.swing.JLayeredPane.paint(JLayeredPane.java, Compiled Code)
at javax.swing.JComponent.paintChildren(JComponent.java, Compiled Code)
at javax.swing.JComponent.paint(JComponent.java, Compiled Code)
at java.awt.Container.paint(Container.java, Compiled Code)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java,
Compiled Code)
at java.awt.Component.dispatchEventImpl(Component.java, Compiled Code)
at java.awt.Container.dispatchEventImpl(Container.java, Compiled Code)
at java.awt.Window.dispatchEventImpl(Window.java, Compiled Code)
at java.awt.Component.dispatchEvent(Component.java, Compiled Code)
at java.awt.EventQueue.dispatchEvent(EventQueue.java, Compiled Code)
at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java,
Compiled Code)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:92)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:83)
The source code below has been extracted from my project which is a program
that scans a directory for text files, cleans the text, and loads them into a
Sybase database.
The program below is run with the following java memory options:
java -Xms15m -Xmx15m
NOTE: The crash can sometimes take a long time to occur, but with a small
amount of memory it happens a lot more frequently. This is useful because
otherwise it may take hours or days before a crash occurs. The crash seems to
be linked with the redrawing of the JTextAreas contained in the JFrame. When I
run my project for TESTING this crashing problem I use the memory settings
above. Occasionally a java.lang.outOfMemory
(java.awt.image.Raster.createPackedRaster(Raster.java, Compiled Code)) occurs
when trying to redraw the JFrame when very little memory is available, but this
does not stop the program from running and will not happen if there is amnple
memory available. I am also getting this crash when the memory settings a much
higher e.g. 130MB but it takes a lot longer to crash. Interestingly, there does
not appear to a problem with single textArea.setText("string") calls. It seems
as though multiple setText calls cause this problem, especially in low memory
conditions.
SOURCE CODE SAMPLE:
-------------------
From your main method create two new threads.
In each thread create a new JFrame with testFrame class below.
In each thread the run() method must repeatedly call appendToLogArea(string,
true) every quarter of a second, with a string with of about 60 characters.
After a random period of time Java.exe will crash.
Clicking between the frames to force a redraw increases the chance of a crash.
public class WireFeederService implements Runnable
{
TestFrame testFrame = new TestFrame();
/**
The thread run() method
*/
public void run()
{
int logLines = 0;
while(logLines < 10000)
{
testFrame.appendToLogArea("this is a test string", true);
Thread.sleep(250);
logLines++;
}
}
}
public class TestFrame extends JFrame
{
GridBagLayout gridBagLayout1 = new GridBagLayout();
JPanel jPanel1 = new JPanel();
JMenuBar jMenuBar1 = new JMenuBar();
JMenu serviceMenu = new JMenu(); // service menu
JMenuItem checkMItem = new JMenuItem();
JMenuItem suspendMItem = new JMenuItem();
JMenuItem resetMItem = new JMenuItem();
JMenu logMenu = new JMenu(); // log menu
JMenuItem clearMItem = new JMenuItem();
JMenuItem reprocessMItem = new JMenuItem();
JLabel logLabel = new JLabel();
JLabel errorsLabel = new JLabel();
JScrollPane logScrollPane = new JScrollPane();
JScrollPane logErrorScrollPane = new JScrollPane();
JTextArea logTextArea = new JTextArea();
JTextArea logErrorsTextArea = new JTextArea();
public testFrame()
{
try
{
jbInit();
}
catch(Exception e)
{
e.printStackTrace();
}
// Show Window
setVisible(true);
}
private void jbInit() throws Exception
{
jPanel1.setLayout(gridBagLayout1);
logLabel.setText("Log");
logLabel.setFont(new java.awt.Font("SansSerif", 0, 9));
errorsLabel.setText("Error log");
errorsLabel.setFont(new java.awt.Font("SansSerif", 0, 9));
logScrollPane.setVerticalScrollBarPolicy
(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
logScrollPane.setAutoscrolls(true);
logScrollPane.setMinimumSize(new Dimension(100, 60));
logScrollPane.setPreferredSize(new Dimension(100, 60));
logScrollPane.getViewport().add(logTextArea);
logErrorScrollPane.setVerticalScrollBarPolicy
(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
logErrorScrollPane.setAutoscrolls(true);
logErrorScrollPane.setMinimumSize(new Dimension(100, 60));
logErrorScrollPane.setPreferredSize(new Dimension(100, 60));
logErrorScrollPane.getViewport().add(logErrorsTextArea);
logTextArea.setLineWrap(true);
logTextArea.setTabSize(3);
logTextArea.setEditable(false);
logErrorsTextArea.setLineWrap(true);
logErrorsTextArea.setTabSize(3);
logErrorsTextArea.setEditable(false);
this.getContentPane().add(jPanel1, BorderLayout.CENTER);
// the gridbag parameters will need to be adjusted
jPanel1.add(logLabel, new GridBagConstraints(0, 7, 2, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets
(5, 5, 0, 0), 0, 0));
jPanel1.add(logScrollPane, new GridBagConstraints(0, 8, 2, 1, 1.0, 1.0
,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 6,
0, 6), 0, 0));
jPanel1.add(errorsLabel, new GridBagConstraints(0, 9, 2, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets
(5, 5, 0, 0), 0, 0));
jPanel1.add(logErrorScrollPane, new GridBagConstraints(0, 10, 2, 1,
1.0, 1.0
,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 6,
0, 6), 0, 0));
}
/**
Add a log message to the Log JTextArea.
*/
public void appendToLogArea(String infoString, boolean logError)
{
String logString = "";
/**
If number of lines in logTextArea is > 250 delete
*/
if (logTextArea.getLineCount() > 250)
{
logTextArea.setText("");
}
/**
If number of lines in logErrorsTextArea is > 250 delete
*/
if (logErrorsTextArea.getLineCount() > 250)
{
logErrorsTextArea.setText("");
}
/**
Append new log message to text area and scroll to last line
*/
logTextArea.append(logString + "\n");
// scroll to bottom of log so user can see latest entries
logTextArea.setCaretPosition(logTextArea.getText().length());
if (logError)
{
// append error message to error text area
logErrorsTextArea.append(logString + "\n");
logErrorsTextArea.setCaretPosition(logErrorsTextArea.getText
().length());
}
}
}
(Review ID: 113161)
======================================================================