-
Bug
-
Resolution: Fixed
-
P3
-
1.2.0, 1.2.2
-
1.2.2
-
sparc
-
solaris_2.5.1
Name: akC57697 Date: 01/10/99
This bug was found by St.Petersburg Java SQE team (by Sergey Scherbakov).
The method HTMLWriter.textAreaContent(AttributeSet attr) throws
unexpected NullPointerException.
The javadoc specification says:
protected void textAreaContent(AttributeSet attr)
throws BadLocationException,
IOException
Throws:
IOException - on any I/O error
BadLocationException - if pos represents an invalid location
within the document.
The example:
-------------------------------------------------------------
import javax.swing.text.html.*;
import javax.swing.text.*;
import java.io.*;
class StubHTMLWriter extends HTMLWriter {
StubHTMLWriter(Writer w, HTMLDocument doc) {
super(w, doc);
}
StubHTMLWriter(Writer w, HTMLDocument doc, int pos, int len) {
super(w, doc, pos, len);
}
public void textAreaContent(AttributeSet attr)
throws BadLocationException, IOException {
super.textAreaContent(attr);
}
}
public class testcont {
public static void main(String argv[]) {
String magic="Test string";
String test="<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2
Final//EN\"><HTML><HEAD><TITLE>Test</TITLE></HEAD><BODY><FORM><TEXTAREA
NAME=test>+magic+</TEXTAREA></FORM></BODY></HTML>";
StubHTMLWriter hw = null;
StringWriter sw = null;
Element e = null;
HTMLEditorKit c = new HTMLEditorKit();
HTMLDocument doc = new HTMLDocument();
try {
c.read(new StringReader(test),doc,0);
} catch (Exception e1) {
System.err.println( "Unexpected exception " + e1 );
}
e = doc.getDefaultRootElement().getElement(1).
getElement(0).getElement(0);
sw = new StringWriter();
hw = new StubHTMLWriter(sw, doc);
AttributeSet attr = e.getAttributes();
System.err.println("Element : "+e);
System.err.println("AttributeSet : "+attr);
try {
hw.textAreaContent(attr);
} catch (Exception e2) {
System.err.println( "Unexpected exception: " + e2 );
}
System.err.println(sw.toString());
}
}
-------------------------------------------------------------
Output:
Element : LeafElement(textarea) 5,6
AttributeSet : LeafElement(textarea) 5,6
Unexpected exception: java.lang.NullPointerException
======================================================================
- duplicates
-
JDK-4204991 javax.swing.text.html.HTMLWriter.text does not work correctly
-
- Closed
-