« Return to Thread: Method Pointers

Re: Method Pointers

by Per Bothner :: Rate this Message:

| View in Thread

On 03/25/2012 03:37 PM, Brian Goetz wrote:
>> OK, so this is simply an implementation hack, which happens to improve
>> performance, and has the side effect of probably confusing new users,
>> rather than a deliberate, unreliable design feature?
>
> Which is almost identical to something we do in javac -- fold together
> identical string literals within a class into the same constant pool
> entry, resulting in strings appearing to be == accidentally.  We don't
> do it to confuse the users, but it may have that effect anyway.

"Same class" is misleading, since we fold together identical string literals
*regardless* of class due to load-time interning.  (jdk 1.0 didn't, but
I think interning of string literals started with 1.1.)

(Which of doesn't change your real point, since only string literals
and explicitly interned strings have == work, but people might be
confused by what you wrote.)
--
        --Per Bothner
per@...   http://per.bothner.com/

 « Return to Thread: Method Pointers