< prev index next >
src/jdk.net/share/classes/jdk/net/ExtendedSocketOptions.java
Print this page
@@ -204,11 +204,11 @@
if (fd == null || !fd.valid())
throw new SocketException("socket closed");
if (option == SO_FLOW_SLA) {
assert flowSupported;
- SocketFlow flow = checkValueType(value, option.type());
+ SocketFlow flow = checkValueType(value, SocketFlow.class);
setFlowOption(fd, flow);
} else if (option == TCP_QUICKACK) {
setQuickAckOption(fd, (boolean) value);
} else if (option == TCP_KEEPCOUNT) {
setTcpkeepAliveProbes(fd, (Integer) value);
@@ -252,16 +252,16 @@
}
});
}
@SuppressWarnings("unchecked")
- private static <T> T checkValueType(Object value, Class<?> type) {
+ private static <T, U extends T> U checkValueType(Object value, Class<T> type) {
if (!type.isAssignableFrom(value.getClass())) {
String s = "Found: " + value.getClass() + ", Expected: " + type;
throw new IllegalArgumentException(s);
}
- return (T) value;
+ return (U) value;
}
private static final JavaIOFileDescriptorAccess fdAccess =
SharedSecrets.getJavaIOFileDescriptorAccess();
< prev index next >