The Eclipse compiler seems to choke on the following code, which is some generics-related issue. Consider the following:
private Set<ActionState> stateHistory = new TreeSet<ActionState>();
Now, I know a TreeSet will be stored in natural ascending order, but just consider the case where you might try to do this:
@Transient
public ActionState getCurrentState() {
if (stateHistory == null || stateHistory.size() == 0) {
return null;
}
return Collections.max(stateHistory);
}
Eclipse chokes with the error:
Bound mismatch: The generic method max(Collection< ? extends T>) of type Collections is not
applicable for the arguments (Collection< ? extends ActionState>) since the type ActionState is not
a valid substitute for the bounded parameter>
This is confusing, as ActionState implements Comparable.
If I change the offending line to read:
return ((TreeSet<ActionState>)stateHistory).last();
It works fine. It looks like it may be a bug in Eclipse’s compiler, as colleagues using IntelliJ IDEA have no such problems.