-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
9
FULL PRODUCT VERSION :
java version "9-ea"
Java(TM) SE Runtime Environment (build 9-ea+152)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+152, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux dstathink 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
There is a testcase as part of Apache POI which generates HTML using javax.xml.transform.Transfomer. This test-case ran fine up to JDK 9ea-148, but started to fail in JDK9 ea-152 due to a small change in generated blanks as part of the generated HTML text.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use the provided test-case to reproduce the problem.
Note: For some strange reason, when I do some changes to the test-case, e.g. refactor the test into multiple modules, then the error goes away. Very strange and indicates that this might actually be some deeper compiler-error.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect the generated HTML/XML from javax.xml.transform.Transfomer. to stay the same between Java releases, but it seems the latest JDK 9 build breaks this.
ACTUAL -
Previously the contents " " lead to a blank being included in the output, but now it is not generated any more.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.StringWriter;
import static org.junit.Assert.assertEquals;
/**
* Test-Class which reproduces a difference in the text produced by java.xml.transform.Transformer
* starting with JDK 9 ea-152 (still working in JDK 9 ea-148!)
*
* We use a Transformer to create a simple HTML structure and noticed that there is a slight
* difference in produced text, i.e. a blank that was rendered before is now omitted.
*/
public class TestJDK9 {
@Test
public void testTransformBlank() throws Exception {
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element note = document.createElement( "div" );
document.appendChild( note );
note.appendChild(document.createElement("a"));
note.appendChild(document.createTextNode(" "));
note.appendChild(document.createElement("span"));
Transformer transformer = TransformerFactory.newInstance()
.newTransformer();
transformer.setOutputProperty( OutputKeys.INDENT, "yes");
transformer.setOutputProperty( OutputKeys.METHOD, "html");
StringWriter stringWriter = new StringWriter();
transformer.transform(
new DOMSource(document),
new StreamResult( stringWriter ));
assertEquals( "Had: " + stringWriter.toString(),
"<div>\n" +
"<a></a> <span></span>\n" +
"</div>\n", stringWriter.toString());
}
}
---------- END SOURCE ----------
java version "9-ea"
Java(TM) SE Runtime Environment (build 9-ea+152)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+152, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux dstathink 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
There is a testcase as part of Apache POI which generates HTML using javax.xml.transform.Transfomer. This test-case ran fine up to JDK 9ea-148, but started to fail in JDK9 ea-152 due to a small change in generated blanks as part of the generated HTML text.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use the provided test-case to reproduce the problem.
Note: For some strange reason, when I do some changes to the test-case, e.g. refactor the test into multiple modules, then the error goes away. Very strange and indicates that this might actually be some deeper compiler-error.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect the generated HTML/XML from javax.xml.transform.Transfomer. to stay the same between Java releases, but it seems the latest JDK 9 build breaks this.
ACTUAL -
Previously the contents " " lead to a blank being included in the output, but now it is not generated any more.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.StringWriter;
import static org.junit.Assert.assertEquals;
/**
* Test-Class which reproduces a difference in the text produced by java.xml.transform.Transformer
* starting with JDK 9 ea-152 (still working in JDK 9 ea-148!)
*
* We use a Transformer to create a simple HTML structure and noticed that there is a slight
* difference in produced text, i.e. a blank that was rendered before is now omitted.
*/
public class TestJDK9 {
@Test
public void testTransformBlank() throws Exception {
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element note = document.createElement( "div" );
document.appendChild( note );
note.appendChild(document.createElement("a"));
note.appendChild(document.createTextNode(" "));
note.appendChild(document.createElement("span"));
Transformer transformer = TransformerFactory.newInstance()
.newTransformer();
transformer.setOutputProperty( OutputKeys.INDENT, "yes");
transformer.setOutputProperty( OutputKeys.METHOD, "html");
StringWriter stringWriter = new StringWriter();
transformer.transform(
new DOMSource(document),
new StreamResult( stringWriter ));
assertEquals( "Had: " + stringWriter.toString(),
"<div>\n" +
"<a></a> <span></span>\n" +
"</div>\n", stringWriter.toString());
}
}
---------- END SOURCE ----------