« Return to Thread: Java integration: Swing string problem

Re: Java integration: Swing string problem

by Marcin Mielżyński-2 :: Rate this Message:

Reply to Author | View in Thread

Hugh Winkler pisze:

> So to clarify, I'm thinking that when JRuby passes one of these
> ByteLists back to java, it could call String.intern on it before
> passing it. The following test passes. I suspect if we call intern()
> on the ByteList copy, it would make the Swing calls succeed.
>
> public class Main {
>
>     public static final String ORIGINAL="something";
>
>     public static void main(String[] args) {
>         char[] bytes = {'s','o','m','e','t','h','i','n','g'};
>         String copy = new String(bytes);
>         String interned = copy.intern();
>         assert(copy.equals(ORIGINAL));
>         assert(copy != ORIGINAL);
>         assert(interned == ORIGINAL);
>     }
> }
>  
Interning arbitrary strings is evil, we should avoid this as much as
possible.


Marcin.

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

 « Return to Thread: Java integration: Swing string problem