RFR 7065380 : Allow Collections.sort to sort Collections.singletonList() result

Jason Mehrens jason_mehrens at hotmail.com
Mon Mar 12 19:08:25 UTC 2012


>>I'm not really confident about proposing "assertions as lint detection" rather than adding explicit checks. We wouldn't (and don't) use optional assertions for array bounds checking. This has clearly been the right choice. I'm still considering my >>feelings about whether to be hardline and suggest we add the checks to Arrays.sort



>>
>>Thoughts anyone?
 
Add wiggle room to the throws CCE javadocs to suggest detection doesn't occur for all cases.
 
Reading over the bug report again, the justification example is flawed.  The caller only knows it is safe to call sort when the documentation for 'generate' states that the returned list is mutable.  If the returned list is mutable, it is not a Collections$SingletonList.  If 'generate' returns an unmodifiable list the call has to make a mutable copy.  If the caller has to create a copy, the caller could perform the size check first.
 
Close as Not a bug??
 
Jason 		 	   		  


More information about the core-libs-dev mailing list