Hi all,

On 2013-11-16, Remi Forax wrote:
> On 11/15/2013 04:21 AM, Joseph Darcy wrote:
> >Hello,
> >
> >Catching up on email, the specification of java.lang.Class does
> >not explicitly promise that its notion of equality must be
> >identity for all time. Therefore, while not required for today's
> >implementations, I would prefer that new code we write in the JDK
> >use equals rather than == when comparing classes.
> >
> >Cheers,
> >
> >-Joe
> 
> The JLS requires implicitly that Class object are interned.
> JLS7 8.4.3.6 says that synchronized on a static method is equivalent to
>   synchronized(Class.forName("CurrentClass"))
> so == is fine.
> 

Also the VM spec $5.3 notes that

"A well-behaved class loader should maintain three properties:

    Given the same name, a good class loader should always return the
    same Class object."

(Granted "the same" might not be formal, and this is a recommendation.)

cheers
/Joel

Reply via email to