ACMNexus / google-collections

Automatically exported from code.google.com/p/google-collections
Apache License 2.0
0 stars 0 forks source link

Remove or commit to ImmutableSorted{Map,Set}FauxverideShim.copyOf() #284

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
(Note that of() and builder() don't have this problem and can remain.)

I'm omitting the background on this issue; interested observers can read
ImmutableSortedSetFauxverideShim's source.

IntelliJ 8 refuses to compile calls to, e.g., copyOf(strings).  OpenJDK may
refuse to compile ImmutableSortedSet itself.

I simultaneously love and hate our
ImmutableSortedSetFauxverideShim.copyOf() shenanigans, but ultimately the
decision is "Which is worse?"

1) People can call copyOf() on non-Comparable types, and it may fail at
runtime.
2) IntelliJ and possibly future javacs will fail to even compile calls to
copyOf().

Falling back to (1) would be kind of a shame, but it's no worse than, e.g.,
TreeSet.  I propose that we do that.  Objections?

Original issue reported on code.google.com by cpov...@google.com on 30 Oct 2009 at 5:54

GoogleCodeExporter commented 8 years ago
Note: IntelliJ doesn't actually compile anything. It tries to highlight things 
in red 
that it thinks are bad syntax, but it has numerous bugs and already flags quite 
a few 
things our library as being errors.  So we can set aside the issue of IntelliJ 
when 
pondering this.

Original comment by kevin...@gmail.com on 30 Oct 2009 at 6:05

GoogleCodeExporter commented 8 years ago
The shim copyOf() methods are gone, and the sorted collections' copyOf() 
methods now
accept non-Comparable parameters.  Like TreeSet/TreeMap, they can now throw
ClassCastException.  We're no longer taking advantage of a contested spec
interpretation, so OpenJDK 7 should compile the code now.

Original comment by cpov...@google.com on 9 Nov 2009 at 10:47