I'm using Guava-05-snapshot, with Sun's JDK 1.6 The code blows up executing this snippet:
List<String> badpasswords = Lists.newArrayList( Password.badWords);
Collections.sort(badpasswords);
ImmutableList<String> tmp = ImmutableList.copyOf(badpasswords);
Specifically on the ImmutableList.copyOf() call. This code has worked for months, using the old Google-Collections code.
java.lang.NoSuchMethodError: com.google.common.collect.ImmutableList.copyOf(Ljava/util/Collection;)Lcom/google/common/collect/ImmutableList;
The Password.badWords
is an ImmutableSet<String>
and the creation of the writable array and the sort work perfectly. But attempts to convert the Array into an ImmutableList
fail.
Guava is a fully compatible superset of Google Collections -- we did not change anything in an incompatible way. (This is tested by running the entire Google Collections test suite (which is extensive) against the lastest guava jar.)
I believe you have a copy of google-collect-*.jar still makings its way into your classpath. Either explicitly, or because some other jar included it without repackaging it. You just have to find it and remove it.
In Google Collections, there was an ImmutableList.copyOf(Iterable)
method, and there was no public ImmutableList.copyOf(Collection)
method. Which is fine, because a collection is also an iterable. In Guava, we've added the Collection overload. This is completely compatible, as all source that used to compile still can, and any source previously compiled will simply still reference the original method.
The problem comes in if you compile against Guava but then run against Google Collections. I believe that is likely what is happening.