Prepares for java 11. (#180)
* Prepares for java 11. * Removes unused import.
This commit is contained in:
parent
59461c9d13
commit
c7c4719c45
4
pom.xml
4
pom.xml
@ -49,7 +49,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<version>3.8.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
@ -86,7 +86,7 @@
|
||||
<plugin>
|
||||
<groupId>com.github.siom79.japicmp</groupId>
|
||||
<artifactId>japicmp-maven-plugin</artifactId>
|
||||
<version>0.10.0</version>
|
||||
<version>0.14.0</version>
|
||||
<configuration>
|
||||
<newVersion>
|
||||
<file>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* ice4j, the OpenSource Java Solution for NAT and Firewall Traversal.
|
||||
*
|
||||
* Copyright @ 2015 Atlassian Pty Ltd
|
||||
* Copyright @ 2018 - present 8x8, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -18,7 +18,9 @@
|
||||
package org.ice4j.socket.jdk8;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.nio.channels.*;
|
||||
import java.util.logging.*;
|
||||
|
||||
import org.ice4j.socket.*;
|
||||
|
||||
@ -35,12 +37,30 @@ class DelegatingServerSocketChannel<T extends ServerSocketChannel>
|
||||
extends BaseDelegatingServerSocketChannel<T>
|
||||
implements SelChImpl
|
||||
{
|
||||
/**
|
||||
* The {@link Logger} used by the {@link DelegatingServerSocketChannel}
|
||||
* class and its instances for logging output.
|
||||
*/
|
||||
private static final java.util.logging.Logger classLogger
|
||||
= java.util.logging.Logger.getLogger(
|
||||
DelegatingServerSocketChannel.class.getName());
|
||||
|
||||
/**
|
||||
* The view of {@link #delegate} as a <tt>SelChImpl</tt> interface instance
|
||||
* required by {@link Selector} and related functionality.
|
||||
*/
|
||||
protected final SelChImpl delegateAsSelChImpl;
|
||||
|
||||
/**
|
||||
* The translateAndSetInterestOps method available in java 8.
|
||||
*/
|
||||
private final Method translateAndSetInterestOpsMethod;
|
||||
|
||||
/**
|
||||
* The translateInterestOps method available in java 11.
|
||||
*/
|
||||
private final Method translateInterestOpsMethod;
|
||||
|
||||
/**
|
||||
* Initializes a new {@code DelegatingServerSocketChannel} instance which is
|
||||
* to delegate (its method calls) to a specific {@code ServerSocketChannel}.
|
||||
@ -54,6 +74,37 @@ class DelegatingServerSocketChannel<T extends ServerSocketChannel>
|
||||
|
||||
delegateAsSelChImpl
|
||||
= (delegate instanceof SelChImpl) ? (SelChImpl) delegate : null;
|
||||
|
||||
Method method;
|
||||
try
|
||||
{
|
||||
method = SelChImpl.class.getMethod(
|
||||
"translateAndSetInterestOps",
|
||||
Integer.TYPE, SelectionKeyImpl.class);
|
||||
}
|
||||
catch(NoSuchMethodException e)
|
||||
{
|
||||
method = null;
|
||||
|
||||
classLogger.log(
|
||||
Level.SEVERE,
|
||||
"Cannot find method translateAndSetInterestOps", e);
|
||||
}
|
||||
translateAndSetInterestOpsMethod = method;
|
||||
|
||||
try
|
||||
{
|
||||
method = SelChImpl.class.getMethod(
|
||||
"translateInterestOps", Integer.TYPE);
|
||||
}
|
||||
catch(NoSuchMethodException e)
|
||||
{
|
||||
method = null;
|
||||
|
||||
classLogger.log(
|
||||
Level.SEVERE, "Cannot find method translateInterestOps", e);
|
||||
}
|
||||
translateInterestOpsMethod = method;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,10 +146,49 @@ class DelegatingServerSocketChannel<T extends ServerSocketChannel>
|
||||
*
|
||||
* Forwards to {@link #delegate}.
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unused")
|
||||
public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk)
|
||||
{
|
||||
delegateAsSelChImpl.translateAndSetInterestOps(ops, sk);
|
||||
try
|
||||
{
|
||||
if (translateAndSetInterestOpsMethod != null)
|
||||
{
|
||||
translateAndSetInterestOpsMethod.invoke(
|
||||
delegateAsSelChImpl, ops, sk);
|
||||
}
|
||||
}
|
||||
catch(IllegalAccessException | InvocationTargetException e)
|
||||
{
|
||||
classLogger.log(
|
||||
Level.SEVERE,
|
||||
"Cannot execute method translateAndSetInterestOpsMethod", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* Forwards to {@link #delegate}.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public int translateInterestOps(int ops)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (translateInterestOpsMethod != null)
|
||||
{
|
||||
return (Integer) translateInterestOpsMethod.invoke(
|
||||
delegateAsSelChImpl, ops);
|
||||
}
|
||||
}
|
||||
catch(IllegalAccessException | InvocationTargetException e)
|
||||
{
|
||||
classLogger.log(
|
||||
Level.SEVERE,
|
||||
"Cannot execute method translateInterestOpsMethod", e);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* ice4j, the OpenSource Java Solution for NAT and Firewall Traversal.
|
||||
*
|
||||
* Copyright @ 2015 Atlassian Pty Ltd
|
||||
* Copyright @ 2018 - present 8x8, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -18,7 +18,9 @@
|
||||
package org.ice4j.socket.jdk8;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.nio.channels.*;
|
||||
import java.util.logging.*;
|
||||
|
||||
import org.ice4j.socket.*;
|
||||
|
||||
@ -34,12 +36,30 @@ class DelegatingSocketChannel<T extends SocketChannel>
|
||||
extends BaseDelegatingSocketChannel<T>
|
||||
implements SelChImpl
|
||||
{
|
||||
/**
|
||||
* The {@link Logger} used by the {@link DelegatingSocketChannel}
|
||||
* class and its instances for logging output.
|
||||
*/
|
||||
private static final java.util.logging.Logger classLogger
|
||||
= java.util.logging.Logger.getLogger(
|
||||
DelegatingSocketChannel.class.getName());
|
||||
|
||||
/**
|
||||
* The view of {@link #delegate} as a <tt>SelChImpl</tt> interface instance
|
||||
* required by {@link Selector} and related functionality.
|
||||
*/
|
||||
protected final SelChImpl delegateAsSelChImpl;
|
||||
|
||||
/**
|
||||
* The translateAndSetInterestOps method available in java 8.
|
||||
*/
|
||||
private final Method translateAndSetInterestOpsMethod;
|
||||
|
||||
/**
|
||||
* The translateInterestOps method available in java 11.
|
||||
*/
|
||||
private final Method translateInterestOpsMethod;
|
||||
|
||||
/**
|
||||
* Initializes a new {@code DelegatingSocketChannel} instance which is to
|
||||
* delegate (its method calls) to a specific {@code SocketChannel}.
|
||||
@ -53,6 +73,37 @@ class DelegatingSocketChannel<T extends SocketChannel>
|
||||
|
||||
delegateAsSelChImpl
|
||||
= (delegate instanceof SelChImpl) ? (SelChImpl) delegate : null;
|
||||
|
||||
Method method;
|
||||
try
|
||||
{
|
||||
method = SelChImpl.class.getMethod(
|
||||
"translateAndSetInterestOps",
|
||||
Integer.TYPE, SelectionKeyImpl.class);
|
||||
}
|
||||
catch(NoSuchMethodException e)
|
||||
{
|
||||
method = null;
|
||||
|
||||
classLogger.log(
|
||||
Level.SEVERE,
|
||||
"Cannot find method translateAndSetInterestOps", e);
|
||||
}
|
||||
translateAndSetInterestOpsMethod = method;
|
||||
|
||||
try
|
||||
{
|
||||
method = SelChImpl.class.getMethod(
|
||||
"translateInterestOps", Integer.TYPE);
|
||||
}
|
||||
catch(NoSuchMethodException e)
|
||||
{
|
||||
method = null;
|
||||
|
||||
classLogger.log(
|
||||
Level.SEVERE, "Cannot find method translateInterestOps", e);
|
||||
}
|
||||
translateInterestOpsMethod = method;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,10 +145,49 @@ class DelegatingSocketChannel<T extends SocketChannel>
|
||||
*
|
||||
* Forwards to {@link #delegate}.
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unused")
|
||||
public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk)
|
||||
{
|
||||
delegateAsSelChImpl.translateAndSetInterestOps(ops, sk);
|
||||
try
|
||||
{
|
||||
if (translateAndSetInterestOpsMethod != null)
|
||||
{
|
||||
translateAndSetInterestOpsMethod.invoke(
|
||||
delegateAsSelChImpl, ops, sk);
|
||||
}
|
||||
}
|
||||
catch(IllegalAccessException | InvocationTargetException e)
|
||||
{
|
||||
classLogger.log(
|
||||
Level.SEVERE,
|
||||
"Cannot execute method translateAndSetInterestOpsMethod", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* Forwards to {@link #delegate}.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public int translateInterestOps(int ops)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (translateInterestOpsMethod != null)
|
||||
{
|
||||
return (Integer) translateInterestOpsMethod.invoke(
|
||||
delegateAsSelChImpl, ops);
|
||||
}
|
||||
}
|
||||
catch(IllegalAccessException | InvocationTargetException e)
|
||||
{
|
||||
classLogger.log(
|
||||
Level.SEVERE,
|
||||
"Cannot execute method translateInterestOpsMethod", e);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user