bug-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug classpath/26460] JEditorPane: small bug, testcase and easy bugfix i


From: mark at gcc dot gnu dot org
Subject: [Bug classpath/26460] JEditorPane: small bug, testcase and easy bugfix included
Date: 4 Mar 2006 09:44:18 -0000


------- Comment #1 from mark at gcc dot gnu dot org  2006-03-04 09:44 -------
(In reply to comment #0)
> this is the testcase that shows the bug:

Thanks. I turned it into a full Mauve test and added some other corner cases.
(gnu.testlet.javax.swing.JEditorPane.setText)

> The reason is in javax.swing.JEditorPane
> at line 929:
> if (t == null || t == "")
>         return;
> 
> but should be:
> 
> if (t == null || t.equals(""))
>         return;
> 
> pretty simple error, but has a big inpact.

Right. Thanks. Fixed as you suggested. 

2006-03-04  Mark Wielaard  <address@hidden>

        Fixes bug #26460 reported by Beat Wolf <address@hidden>.
        * javax/swing/JEditorPane.java (setText): Check for empty String
        with equals(), not equality (==).

> I did a quick search and found that java.util.Locale at line 550 there is also
> this == "" problem. didnt test it, but there is a big chance that this could
> lead to a bug.
> Here the code of java.util.Locale:
>     if (language == "")
>       return "";

In this (special) case that is correct. Locale makes sure that its String
fields are interned. (See the constructor and the readObject method.) All
methods using this "trick" should have a comment explaining it:
// We know all strings are interned so we can use '==' for better performance.


-- 

mark at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |0.21


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26460





reply via email to

[Prev in Thread] Current Thread [Next in Thread]