Lambdas and serialization

Alex Blewitt alex.blewitt at gmail.com
Wed Nov 10 06:29:11 PST 2010


That can't be right. Consider a PersonComparator which just compares first names. There may be two Alexs, but that doesn't mean they are the same Person. 

Sent from my iPhone 4

On 10 Nov 2010, at 13:16, Llewellyn Falco <isidore at setgame.com> wrote:

> I just realized this is a mistake!
> 
> Comparable will not work properly without the Equals method
> being overridden.
> 
> Namely, if you have two object a, b you will get
> a.compareTo(b) == 0
> but
> a.equals(b) == false
> 
> depending on your implementation this will fail!
> 
> Llewellyn Falco
> http:\\bit.ly\lambdas
> 
> On Wed, Oct 27, 2010 at 4:00 AM, Maurizio Cimadamore <
> maurizio.cimadamore at oracle.com> wrote:
> 
>> 
>> btw: what happens with comparator? it's not a SAM (2 methods - compare,
>>> equals), but seems to be a very wanted case for lambdas?
>>> 
>>> 
>>> 
>> The definition of SAM does not take into account methods inherithed from
>> java.lang.Object. Which means that Comparator<T> really has just one
>> relevant target method and therefore can be used as the target of a SAM
>> conversion.
>> 
>> Maurizio
>> 
> 


More information about the lambda-dev mailing list