-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.2.2
-
sparc
-
solaris_2.5.1
Name: akC57697 Date: 01/22/99
This bug was found by St.Petersburg Java SQE team (by Sergey Scherbakov).
In JDK 1.2.2 method HTMLWriter.text(elem) throws NullPointerException.
In JDK 1.2 all OK.
The example:
-------------------------------------------------------
import javax.swing.text.html.*;
import javax.swing.text.*;
import java.io.*;
public class Test {
public static void main(String argv[]) {
String
test="<HTML><TITLE></TITLE><BODY>string1234567890</BODY></HTML>";
HTMLEditorKit c = new HTMLEditorKit();
HTMLDocument doc = new HTMLDocument();
try {
c.read(new StringReader(test),doc,0);
} catch (Exception e1) {
System.out.println( "Exception in StringReader: " + e1 );
}
Element e = doc.getDefaultRootElement().getElement(1).
getElement(0).getElement(0);
StringWriter sw = new StringWriter();
StubHTMLWriter hw = new StubHTMLWriter(sw, doc);
try {
hw.text(e);
} catch (Exception e1) {
e1.printStackTrace(System.out);
System.out.println("Unexpected exception in text(elem): " +
e1);
}
System.out.println(sw.toString());
}
}
class StubHTMLWriter extends HTMLWriter {
StubHTMLWriter(Writer w, HTMLDocument doc) {
super(w, doc);
}
public void text(Element elem)
throws BadLocationException, IOException {
super.text(elem);
}
}
-------------------------------------------------------
Output :
(JDK 1.2.2)
java.lang.NullPointerException
at javax.swing.text.GapContent.getChars(Compiled Code)
at javax.swing.text.AbstractDocument.getText(Compiled Code)
at javax.swing.text.html.HTMLWriter.text(Compiled Code)
at StubHTMLWriter.text(Compiled Code)
at test.main(Compiled Code)
Unexpected exception in text(elem): java.lang.NullPointerException
(JDK 1.2)
string1234567890
======================================================================
- duplicates
-
JDK-4202014 JDK1.2.2 swing.text.HTMLWriter.textAreaContent() throws NPE
- Resolved