Closed GoogleCodeExporter closed 9 years ago
quibble: I don't think it should introduce bugs since it should fail to
compile. It
fails to compile, right?
Note: we hate this too, so the new APIs for ImmutableList etc. use different
method
names (of/copyOf). Also we're removing the varargs overloads for all the
collection
factory methods except newArrayList() and newHashSet() and if we were smart we'd
probably remove them all.
Original comment by kevin...@gmail.com
on 5 Jan 2009 at 4:34
The code attached compiles in eclipse, but the test fails.
(The tree iterator (walk) would imho also be a nice addition to the library)
Original comment by jvdne...@gmail.com
on 6 Jan 2009 at 12:27
Attachments:
In this code, you're using raw types and suppressing warnings. I don't claim
anything
will work right if you do this. Please provide an example that is warning-free
if one
exists, and please don't make me hunt down a third-party library to compile it.
Thanks.
Original comment by kevin...@gmail.com
on 6 Jan 2009 at 4:56
Sorry. You're right.
Attached is an example that illustrates the problem properly (although I get
the
feeling we're already spending more time on it than it's worth).
I'm using Lists.newArrayList, because Lists.newLinkedList appears to be safe.
(sorry about that as well,
http://mvnrepository.com/artifact/com.google.collections/google-collections/0.8
is
unexpectedly not the same as google-collect-snapshot-20080820.zip from this
project
site)
I'm merely trying to say that I didn't get any warnings or errors with this
code.
Original comment by jvdne...@gmail.com
on 6 Jan 2009 at 5:59
Attachments:
thank you, this example is much better. Clearly, a class Foo that implements
Iterable<Foo> is going to cause problems for these methods.
I'm reopening this issue to consider removing the varargs newArrayList and
newHashSet
methods. They really are not that useful. However, we may also just choose to
put a
small warning about this situation in their javadoc. I lean toward the former.
Original comment by kevin...@gmail.com
on 6 Jan 2009 at 6:09
Original comment by kevin...@gmail.com
on 17 Mar 2009 at 6:37
Original comment by kevin...@gmail.com
on 17 Sep 2009 at 5:59
Original comment by fry@google.com
on 26 Jan 2011 at 9:49
Original comment by kevinb@google.com
on 13 Jul 2011 at 6:18
Original comment by fry@google.com
on 16 Feb 2012 at 7:17
Original comment by kevinb@google.com
on 2 Mar 2012 at 6:51
Original comment by kevinb@google.com
on 11 May 2012 at 8:55
Original comment by kevinb@google.com
on 30 May 2012 at 7:51
Original comment by kevinb@google.com
on 22 Jun 2012 at 6:16
Java 8 introduces some new weirdness with the varargs Lists.newArrayList(). If
you call Lists.newArrayList(null), then javac7 would resolve the varargs
method. javac8 reports an error:
error: reference to newArrayList is ambiguous
Lists.newArrayList(null);
^
both method <E#1>newArrayList(Iterable<? extends E#1>) in Lists and method <E#2>newArrayList(Iterator<? extends E#2>) in Lists match
where E#1,E#2 are type-variables:
E#1 extends Object declared in method <E#1>newArrayList(Iterable<? extends E#1>)
E#2 extends Object declared in method <E#2>newArrayList(Iterator<? extends E#2>)
Original comment by cus...@google.com
on 21 Mar 2014 at 4:34
This issue has been migrated to GitHub.
It can be found at https://github.com/google/guava/issues/<id>
Original comment by cgdecker@google.com
on 1 Nov 2014 at 4:16
Original comment by cgdecker@google.com
on 1 Nov 2014 at 4:19
Original comment by cgdecker@google.com
on 3 Nov 2014 at 9:10
Original issue reported on code.google.com by
jvdne...@gmail.com
on 5 Jan 2009 at 4:20