RFR: 8027470: AnnotationSupport uses == rather than .equals to compare Class objects
andreas.lundblad at oracle.com
Fri Nov 15 12:40:23 UTC 2013
On Thu, Nov 14, 2013 at 07:21:38PM -0800, Joseph Darcy wrote:
> 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.
Thank you for getting back on this matter. First of all, I agree with you that 'equals' is in a sense more future proof than plain '=='.
Strictly speaking though, can't one say that todays docs implicitly specify that j.l.Class.equals *must* be identity-based (since it does not explicitly refine the spec of Object.equals)? If so, wouldn't it be a breaking change to add a j.l.Class.equals which refines this by specifying something else?
(Side note, At the moment I neighter consider this review as accepted nor rejected, and assume that the patch won't make it into 8 regardless.)
More information about the core-libs-dev