Description of problem: when you call the setContentType function of a JEditorPane it results in a NullPointer exception. Version-Release number of selected component (if applicable): 1.5.0-gcj-1.5.0.0-14.fc7 How reproducible: always Steps to Reproduce: 1. create file with contents: ---------------------------- import javax.swing.JEditorPane; public class SetContentTypeTest { public static void main(String[] args){ JEditorPane jpane = new JEditorPane(); jpane.setContentType("text/html"); } } ---------------------------- 2. compile the file 3. run the file Actual results: $ java SetContentTypeTest Exception in thread "main" java.lang.NullPointerException at java.io.InputStreamReader.read(libgcj.so.8rh) at gnu.javax.swing.text.html.css.CSSScanner.read(libgcj.so.8rh) at gnu.javax.swing.text.html.css.CSSScanner.nextToken(libgcj.so.8rh) at gnu.javax.swing.text.html.css.CSSParser.peekToken(libgcj.so.8rh) at gnu.javax.swing.text.html.css.CSSParser.parseStylesheet(libgcj.so.8rh) at gnu.javax.swing.text.html.css.CSSParser.parse(libgcj.so.8rh) at javax.swing.text.html.StyleSheet.loadRules(libgcj.so.8rh) at javax.swing.text.html.HTMLEditorKit.getStyleSheet(libgcj.so.8rh) at javax.swing.text.html.HTMLEditorKit.createDefaultDocument(libgcj.so.8rh) at javax.swing.JEditorPane.setEditorKit(libgcj.so.8rh) at javax.swing.JEditorPane.setContentType(libgcj.so.8rh) at SetContentTypeTest.main(SetContentTypeTest.java:7) Expected results: nothing bad happens Additional info: this doesn't happen with the latest classpath version
Hello! I've run your test program with cacao + classpath HEAD and it works. I'm on a Fedora 6 and I've tested it with the system gcj (4.1.1 20070105) and with sun java 6u1 and it works too. I think this can be either a regression introduced classpath and then fixed or a gcj-1.5 issue.
Yes, the problem is this code: try { styleSheet = new StyleSheet(); Class c = HTMLEditorKit.class; InputStream in = c.getResourceAsStream(DEFAULT_CSS); InputStreamReader r = new InputStreamReader(in); styleSheet.loadRules(r, null); r.close(); } catch (IOException ex) { // No style available. } DEFAULT_CSS is "default.css" which not being compiled into libgcj (but is built into GNU Classpath's glibj.zip). The exception is silently eaten and manifests later as a NullPointerException. I'm working on a fix.
I committed my fix to redhat/gcc-4_1-branch. It will be included in the next Rawhide gcc build, at which point I'll close this bug report.
thanks, i grabbed the build from koji and it works fine.
The fix hit Rawhide. Closing.