-
Bug
-
Resolution: Fixed
-
P2
-
8
-
b14
-
generic
-
generic
-
Verified
From javax.swing.text.html.HTMLDocument.insertAfterStart(Element, String) spec:
"If either elem or htmlText parameter is null, no changes are made to the document."
But if elem is null, insertAfterStart throws NullPointerException. Please, see mini-test below.
Conformance test api/javax_swing/text/html/HTMLDocument/indexTGF.html#SetInsert[insertAfterStart_elemIsNull] fails due to this issue.
jdk: 1.8.0_b07
os: generic
/*********************************/
import javax.swing.*;
import javax.swing.text.BadLocationException;
import javax.swing.text.Element;
import javax.swing.text.html.HTML;
import javax.swing.text.html.HTMLDocument;
import java.io.IOException;
public class HTMLDocument_insertAfterStart_elemIsNull {
private static final String TEST_HTML = "<!DOCTYPE TEST_HTML PUBLIC \"-//W3C//DTD TEST_HTML 4.01 Transitional//EN\" "
+ "\"http://www.w3.org/TR/html4/loose.dtd\">"
+ "<html>"
+ " <head>"
+ " <title>Simple HTMLDocument</title>"
+ " </head>"
+ " <body>"
+ " <div id = \"top\">"
+ " <div id = \"left\"></div>"
+ " <div id = \"center\">"
+ " <div id = \"bottom\"></div>"
+ " </div>"
+ " <div id = \"right\"></div>"
+ " </div>"
+ " </body>"
+ "</html>";
public static void main(String[] args) throws IOException, BadLocationException {
JEditorPane editorPane = new JEditorPane();
editorPane.setContentType("text/html");
editorPane.setText(TEST_HTML);
HTMLDocument doc = (HTMLDocument) editorPane.getDocument();
doc.insertAfterStart(null, "<div id=\"inserted\">");
}
}
"If either elem or htmlText parameter is null, no changes are made to the document."
But if elem is null, insertAfterStart throws NullPointerException. Please, see mini-test below.
Conformance test api/javax_swing/text/html/HTMLDocument/indexTGF.html#SetInsert[insertAfterStart_elemIsNull] fails due to this issue.
jdk: 1.8.0_b07
os: generic
/*********************************/
import javax.swing.*;
import javax.swing.text.BadLocationException;
import javax.swing.text.Element;
import javax.swing.text.html.HTML;
import javax.swing.text.html.HTMLDocument;
import java.io.IOException;
public class HTMLDocument_insertAfterStart_elemIsNull {
private static final String TEST_HTML = "<!DOCTYPE TEST_HTML PUBLIC \"-//W3C//DTD TEST_HTML 4.01 Transitional//EN\" "
+ "\"http://www.w3.org/TR/html4/loose.dtd\">"
+ "<html>"
+ " <head>"
+ " <title>Simple HTMLDocument</title>"
+ " </head>"
+ " <body>"
+ " <div id = \"top\">"
+ " <div id = \"left\"></div>"
+ " <div id = \"center\">"
+ " <div id = \"bottom\"></div>"
+ " </div>"
+ " <div id = \"right\"></div>"
+ " </div>"
+ " </body>"
+ "</html>";
public static void main(String[] args) throws IOException, BadLocationException {
JEditorPane editorPane = new JEditorPane();
editorPane.setContentType("text/html");
editorPane.setText(TEST_HTML);
HTMLDocument doc = (HTMLDocument) editorPane.getDocument();
doc.insertAfterStart(null, "<div id=\"inserted\">");
}
}