Sometime when looking through code, I see many methods specify an annotation:
@SuppressWarnings(\"unchecked\")
What does this mean?
One trick is to create an interface that extends a generic base interface...
public interface LoadFutures extends Map> {}
Then you can check it with instanceof before the cast...
Object obj = context.getAttribute(FUTURES);
if (!(obj instanceof LoadFutures)) {
String format = "Servlet context attribute \"%s\" is not of type "
+ "LoadFutures. Its type is %s.";
String msg = String.format(format, FUTURES, obj.getClass());
throw new RuntimeException(msg);
}
return (LoadFutures) obj;