Bug 237304 - JEditorPane.setContentType NullPointer
JEditorPane.setContentType NullPointer
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: Thomas Fitzsimmons
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2007-04-20 13:56 EDT by Sander Hoentjen
Modified: 2007-11-30 17:12 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-05-14 19:45:59 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Sander Hoentjen 2007-04-20 13:56:38 EDT
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
Comment 1 Mario Torre 2007-04-29 14:07:37 EDT
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.
Comment 2 Thomas Fitzsimmons 2007-04-30 17:42:59 EDT
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.
Comment 3 Thomas Fitzsimmons 2007-05-03 17:39:00 EDT
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.
Comment 4 Sander Hoentjen 2007-05-09 10:53:24 EDT
thanks, i grabbed the build from koji and it works fine.
Comment 5 Thomas Fitzsimmons 2007-05-14 19:45:59 EDT
The fix hit Rawhide.  Closing.

Note You need to log in before you can comment on or make changes to this bug.