Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 12314

Summary: VM crash when step in String constructor
Product: [Eclipse Project] JDT Reporter: David Wegener <dpwegener>
Component: DebugAssignee: Darin Wright <darin.eclipse>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: eclipse
Version: 2.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows NT   
Whiteboard:

Description David Wegener CLA 2002-03-26 15:31:11 EST
Build 20020321 Stable
While trying to step into the String constructor, I receive an Application 
Error: The instruction at "0x504cd71f" referenced memory at "0x00000000". The 
memory could not be "read".  The error occurs in the VM being debugged, so 
Eclipse isn't crashing.

I am able to reproduce this problem and even have a simple example that 
displays the problem.  The problem occurs when debugging on the Sun jdk1.2.2 
fullversion:JDK-1.2.2_008

Here is the example code.  Run the DebugStringTest class with a breakpoint set 
in the insertString() method of the DebugTestDocument class.  When the frame is 
displayed, enter a character, step into while on the line marked in the 
source.  This will attempt to step into the String constructor.  This is where 
I get the error.

---------------------------------------------------
package debug.test;

import javax.swing.JFrame;
import javax.swing.JTextField;

import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;

public class DebugStringTest extends JFrame {
	private JTextField testField;
	/**
	 * Constructor for DebugStringTest.
	 */
	public DebugStringTest() {
		testField = new JTextField();
		testField.setDocument(new DebugTestDocument());
		testField.setPreferredSize(new Dimension(150,50));
		Container content = getContentPane();
		content.setLayout((new FlowLayout(FlowLayout.LEFT)));
		content.add(testField);
	}

	/**
	 * Constructor for DebugStringTest.
	 * @param title
	 */
	public DebugStringTest(String title) {
		super(title);
	}

	public static void main(String[] args) {
		DebugStringTest test = new DebugStringTest();
		test.pack();
		test.show();
		
	}
}


--------------------------------------------------------



package debug.test;

import javax.swing.text.PlainDocument;
import javax.swing.text.AbstractDocument.Content;

public class DebugTestDocument extends PlainDocument {
	/**
 * This method was created in VisualAge.
 * @param offs int
 * @param str java.lang.String
 * @param a AttributeSet
 * @exception javax.swing.text.BadLocationException The exception description.
 */
public void insertString( int offs, String str, javax.swing.text.AttributeSet 
a ) throws javax.swing.text.BadLocationException {
	if( str == null ) {
		return;
	}
	
	char[] upper = str.toCharArray();
	for( int i = 0; i < upper.length; i++ ) {
		upper[i] = Character.toUpperCase( upper[i] );
	}
	super.insertString( offs, new String(upper), a);  //<--- breakpoint 
here, then step into
	
}


	/**
	 * Constructor for DebugTestDocument.
	 */
	public DebugTestDocument() {
		super();
	}

	/**
	 * Constructor for DebugTestDocument.
	 * @param arg0
	 */
	protected DebugTestDocument(Content arg0) {
		super(arg0);
	}

}
Comment 1 Darin Wright CLA 2002-03-26 18:33:36 EST
Joe, I think you saw this before, but I could not find the bug report. I 
believe this is a VM bug, and if so, we cannot fix.
Comment 2 Joe Szurszewski CLA 2002-03-26 18:47:20 EST
Yes, this is the same problem I had reported.  The bug was given to J9, and 
they actually fixed it in the class library (internal bugzilla).  The 
fundamental problem is the ordering of statements in the String constructor, in 
particular the order of setting the length and the content.  Given that the 
only way to fix this is make a change in the class library, this probably won't 
happen for Sun VMs.  Marking as WONTFIX.