harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vasily Zakharov (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-3453) [classlib][swing] JEditorPane.registerEditorKitForContentType(String, String, null) doesn't throw NPE
Date Fri, 23 Mar 2007 13:38:32 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-3453?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12483597

Vasily Zakharov commented on HARMONY-3453:

Yes, I agree. It seems we've come to consensus. My propositions are as follows:

1. Rewrite registration information storage to use Map from content types to instances of
a special class storing class name and classloader. Swing is not thread-safe, so we may not
care of the synchronization, and HashMap should be faster than Hashtable.

2. Add caching of the resolved EditorKit instances to avoid resolving through classloader
multiple times. Probably the best idea is to add a 3rd field to a special class mentioned
in (1), to avoid another Map lookup in case the EditorKit instance is not yet resolved for
the particular content type.

3. Implement all the above as a patch to HARMONY-3454, where it truly belongs.

4. Do not throw NPE as RI does, and close this issue as a non-bug-difference.

Do you agree? Any additional comments, suggestions? May I proceed with making a patch?

> [classlib][swing] JEditorPane.registerEditorKitForContentType(String, String, null) doesn't
throw NPE
> -----------------------------------------------------------------------------------------------------
>                 Key: HARMONY-3453
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3453
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib, Non-bug differences from RI
>            Reporter: Vasily Zakharov
>         Assigned To: Alexey Petrenko
>            Priority: Minor
> Consider the following test:
> import javax.swing.JEditorPane;
> public class Test {
>     public static void main(String args[]) throws Exception {
>         System.out.println(JEditorPane.createEditorKitForContentType("testContentType1"));
>         try {
>             JEditorPane.registerEditorKitForContentType("testContentType1", "MyEditorKit",
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>         System.out.println(JEditorPane.createEditorKitForContentType("testContentType1"));
>         JEditorPane.registerEditorKitForContentType("testContentType2", "MyEditorKit");
>         System.out.println(JEditorPane.createEditorKitForContentType("testContentType2"));
>     }
> }
> public class MyEditorKit extends javax.swing.text.DefaultEditorKit {
> }
> Output on RI:
> null
> java.lang.NullPointerException
>         at java.util.Hashtable.put(Unknown Source)
>         at javax.swing.JEditorPane.registerEditorKitForContentType(Unknown Source)
>         at TestNPE.main(TestNPE.java:8)
> MyEditorKit@1a46e30
> MyEditorKit@3e25a5
> Output on Harmony:
> null
> null
> null
> The specification says nothing about passing null classloader.
> The NPE occurs on RI, and doesn't occur on Harmony, it seems that RI uses Hashtable (that
doesn't permit null keys/vaues) to store registered classloaders, and Harmony uses ArrayList.
> Also, as one may see, RI, besides throwing NPE, also registers the specified content
type anyway (compare createEditorKitForContentType results before and after registration attempt).
In my opinion, this behaviour is clearly a bug in RI. So my suggestion is to consider this
issue a non-bug difference.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message