Inconsistencies in TreeSet Interface

Rob McKenna rob.mckenna at oracle.com
Mon Oct 15 13:56:44 UTC 2018


Hi Kishor,

core-libs-dev at openjdk.java.net may be a better venue for this topic.

    -Rob

On 13/10/18 19:56, Kishor Gollapalliwar wrote:
> Hello Everyone,
> 
> Introduction : I’m an enthusiast java developer. I’m a newbie in this
> group, hence please ignore my nuisance and guide me towards right direction.
> 
> ## Problems Statement
> 
> Treeset#add method documentations : “adds the specified element e to this
> set if the set contains no element e2 such that (e==null ? e2==null :
> e.equals(e2))”
> 
> Inconsistencies:
> 
> > If we try to add “null” value, it will throws NullPointerException, hence
> > e and e2 can not be null.
> 
> 
> 
> > And e.compareTo(e2) ==0 || compare(e, e2)==0, it will not add to
> > collection.
> 
> 
> Request you to help me understand if behavior of Treeset#add method is as
> expected, and differ with set interface documentation. We may have to
> consider to update method documentations, if behavior is expected.
> 
> For more details I have attached the sample java application.
> 
> I’ve tested the behavior on Orack JDK 8u181 (64 bit) and Open JDK 8u181.
> 
> Thanks & Regards,
> *Kishor Golapelliwar,*
> The ability to convert ideas to things is the secret to outward success.


More information about the jdk8u-dev mailing list