Updated explanation of a potentially unexpected cast to refer to the JDK bug that necessitates it

This commit is contained in:
Andrew Phillips 2012-01-05 15:31:44 -05:00
parent 0ac7ee69ab
commit d3ab85918e

View File

@ -96,6 +96,7 @@ public class EC2ListNodesStrategy implements ListNodesStrategy {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public Future<Set<? extends Reservation<? extends RunningInstance>>> apply(String from) { public Future<Set<? extends Reservation<? extends RunningInstance>>> apply(String from) {
// see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7126754
return castToSpecificTypedFuture(client.getInstanceServices().describeInstancesInRegion(from)); return castToSpecificTypedFuture(client.getInstanceServices().describeInstancesInRegion(from));
} }
@ -104,7 +105,6 @@ public class EC2ListNodesStrategy implements ListNodesStrategy {
return concat(concat(reservations)); return concat(concat(reservations));
} }
// "hide" this cast (i.e. do not perform inline) from the Java 7 compiler - see http://stackoverflow.com/questions/8637937/why-does-a-generic-cast-of-a-list-extends-set-to-listset-succeed-on-sun
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private static <T> Future<T> castToSpecificTypedFuture(Future<? extends T> input) { private static <T> Future<T> castToSpecificTypedFuture(Future<? extends T> input) {
return (Future<T>) input; return (Future<T>) input;