RFR [12] 8209454: [error-prone] TypeParameterUnusedInFormals in jdk.net
Daniel Fuchs
daniel.fuchs at oracle.com
Tue Oct 2 08:42:22 UTC 2018
Yes! Thanks chris, that looks better to me
(and less mysterious) :-)
best regards,
-- daniel
On 02/10/2018 09:11, Chris Hegarty wrote:
>
>> On 1 Oct 2018, at 16:38, Daniel Fuchs <daniel.fuchs at oracle.com> wrote:
>>
>> Hi Chris,
>>
>> I believe you should get rid of the parameter U: I do not
>> see it's purpose in this class. I suggest simplifying into:
>>
>> <T> T checkValueType(Object value, Class<T>) { }
>
> Good suggestion. So the full diff is:
>
> --- a/src/jdk.net/share/classes/jdk/net/ExtendedSocketOptions.java
> +++ b/src/jdk.net/share/classes/jdk/net/ExtendedSocketOptions.java
> @@ -206,7 +206,7 @@
>
> 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);
> @@ -254,7 +254,7 @@
> }
>
> @SuppressWarnings("unchecked")
> - private static <T> T checkValueType(Object value, Class<?> type) {
> + private static <T> T checkValueType(Object value, Class<T> type) {
> if (!type.isAssignableFrom(value.getClass())) {
> String s = "Found: " + value.getClass() + ", Expected: " + type;
> throw new IllegalArgumentException(s);
>
>
> -Chris.
>
More information about the net-dev
mailing list