From 4e6ddfcea3f3130701baafa5f812157ba8671f3e Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Sat, 17 Oct 2015 14:01:08 +0000 Subject: [PATCH] lint core --- core/java/src/net/i2p/I2PAppContext.java | 4 +++- core/java/src/net/i2p/client/I2PSession.java | 13 +++++++------ .../net/i2p/client/impl/I2CPMessageProducer.java | 2 +- .../src/net/i2p/client/impl/I2PSessionImpl2.java | 15 ++++++++------- .../net/i2p/client/impl/I2PSessionMuxedImpl.java | 9 +++++---- .../src/net/i2p/client/naming/NamingService.java | 2 +- core/java/src/net/i2p/data/SDSCache.java | 3 +-- core/java/src/net/i2p/util/PortMapper.java | 2 +- core/java/src/net/i2p/util/SimpleTimer2.java | 4 ++-- 9 files changed, 29 insertions(+), 25 deletions(-) diff --git a/core/java/src/net/i2p/I2PAppContext.java b/core/java/src/net/i2p/I2PAppContext.java index b59a405860..bae3572604 100644 --- a/core/java/src/net/i2p/I2PAppContext.java +++ b/core/java/src/net/i2p/I2PAppContext.java @@ -84,6 +84,7 @@ public class I2PAppContext { private RandomSource _random; private KeyGenerator _keyGenerator; protected KeyRing _keyRing; // overridden in RouterContext + @SuppressWarnings("deprecation") private SimpleScheduler _simpleScheduler; private SimpleTimer _simpleTimer; private SimpleTimer2 _simpleTimer2; @@ -532,7 +533,7 @@ public class I2PAppContext { * @return set of Strings containing the names of defined system properties */ @SuppressWarnings({ "unchecked", "rawtypes" }) - public Set<String> getPropertyNames() { + public Set<String> getPropertyNames() { // clone to avoid ConcurrentModificationException Set<String> names = new HashSet<String>((Set<String>) (Set) ((Properties) System.getProperties().clone()).keySet()); // TODO-Java6: s/keySet()/stringPropertyNames()/ if (_overrideProps != null) @@ -940,6 +941,7 @@ public class I2PAppContext { * @since 0.9 to replace static instance in the class * @deprecated in 0.9.20, use simpleTimer2() */ + @SuppressWarnings("deprecation") public SimpleScheduler simpleScheduler() { if (!_simpleSchedulerInitialized) initializeSimpleScheduler(); diff --git a/core/java/src/net/i2p/client/I2PSession.java b/core/java/src/net/i2p/client/I2PSession.java index 458b9a892d..818cb59835 100644 --- a/core/java/src/net/i2p/client/I2PSession.java +++ b/core/java/src/net/i2p/client/I2PSession.java @@ -18,6 +18,7 @@ import net.i2p.data.Destination; import net.i2p.data.Hash; import net.i2p.data.PrivateKey; import net.i2p.data.SessionKey; +import net.i2p.data.SessionTag; import net.i2p.data.SigningPrivateKey; /** @@ -98,7 +99,7 @@ public interface I2PSession { * objects that were sent along side the given keyUsed. * @return success */ - public boolean sendMessage(Destination dest, byte[] payload, SessionKey keyUsed, Set tagsSent) throws I2PSessionException; + public boolean sendMessage(Destination dest, byte[] payload, SessionKey keyUsed, Set<SessionTag> tagsSent) throws I2PSessionException; /** * End-to-End Crypto is disabled, tags and keys are ignored. @@ -106,7 +107,7 @@ public interface I2PSession { * @param tagsSent UNUSED, IGNORED. * @return success */ - public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set tagsSent) throws I2PSessionException; + public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set<SessionTag> tagsSent) throws I2PSessionException; /** * End-to-End Crypto is disabled, tags and keys are ignored. @@ -116,7 +117,7 @@ public interface I2PSession { * @return success * @since 0.7.1 */ - public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set tagsSent, long expire) throws I2PSessionException; + public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set<SessionTag> tagsSent, long expire) throws I2PSessionException; /** * See I2PSessionMuxedImpl for proto/port details. @@ -133,7 +134,7 @@ public interface I2PSession { * @return success * @since 0.7.1 */ - public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set tagsSent, + public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set<SessionTag> tagsSent, int proto, int fromPort, int toPort) throws I2PSessionException; /** @@ -152,7 +153,7 @@ public interface I2PSession { * @return success * @since 0.7.1 */ - public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set tagsSent, long expire, + public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set<SessionTag> tagsSent, long expire, int proto, int fromPort, int toPort) throws I2PSessionException; /** @@ -171,7 +172,7 @@ public interface I2PSession { * @return success * @since 0.8.4 */ - public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set tagsSent, long expire, + public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set<SessionTag> tagsSent, long expire, int proto, int fromPort, int toPort, int flags) throws I2PSessionException; /** diff --git a/core/java/src/net/i2p/client/impl/I2CPMessageProducer.java b/core/java/src/net/i2p/client/impl/I2CPMessageProducer.java index f44b897a3b..bcdd0b4eae 100644 --- a/core/java/src/net/i2p/client/impl/I2CPMessageProducer.java +++ b/core/java/src/net/i2p/client/impl/I2CPMessageProducer.java @@ -132,7 +132,7 @@ class I2CPMessageProducer { * @param newKey unused - no end-to-end crypto */ public void sendMessage(I2PSessionImpl session, Destination dest, long nonce, byte[] payload, SessionTag tag, - SessionKey key, Set tags, SessionKey newKey, long expires) throws I2PSessionException { + SessionKey key, Set<SessionTag> tags, SessionKey newKey, long expires) throws I2PSessionException { sendMessage(session, dest, nonce, payload, expires, 0); } diff --git a/core/java/src/net/i2p/client/impl/I2PSessionImpl2.java b/core/java/src/net/i2p/client/impl/I2PSessionImpl2.java index 4eddcc30ec..e110889be8 100644 --- a/core/java/src/net/i2p/client/impl/I2PSessionImpl2.java +++ b/core/java/src/net/i2p/client/impl/I2PSessionImpl2.java @@ -29,6 +29,7 @@ import net.i2p.client.SendMessageStatusListener; import net.i2p.data.DataHelper; import net.i2p.data.Destination; import net.i2p.data.SessionKey; +import net.i2p.data.SessionTag; import net.i2p.data.i2cp.MessageId; import net.i2p.data.i2cp.MessageStatusMessage; import net.i2p.util.Log; @@ -210,17 +211,17 @@ class I2PSessionImpl2 extends I2PSessionImpl { throw new UnsupportedOperationException("Use MuxedImpl"); } /** @throws UnsupportedOperationException always, use MuxedImpl */ - public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set tagsSent, + public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set<SessionTag> tagsSent, int proto, int fromport, int toport) throws I2PSessionException { throw new UnsupportedOperationException("Use MuxedImpl"); } /** @throws UnsupportedOperationException always, use MuxedImpl */ - public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set tagsSent, long expire, + public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set<SessionTag> tagsSent, long expire, int proto, int fromport, int toport) throws I2PSessionException { throw new UnsupportedOperationException("Use MuxedImpl"); } /** @throws UnsupportedOperationException always, use MuxedImpl */ - public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set tagsSent, long expire, + public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set<SessionTag> tagsSent, long expire, int proto, int fromport, int toport, int flags) throws I2PSessionException { throw new UnsupportedOperationException("Use MuxedImpl"); } @@ -253,7 +254,7 @@ class I2PSessionImpl2 extends I2PSessionImpl { * @param tagsSent unused - no end-to-end crypto */ @Override - public boolean sendMessage(Destination dest, byte[] payload, SessionKey keyUsed, Set tagsSent) throws I2PSessionException { + public boolean sendMessage(Destination dest, byte[] payload, SessionKey keyUsed, Set<SessionTag> tagsSent) throws I2PSessionException { return sendMessage(dest, payload, 0, payload.length, keyUsed, tagsSent, 0); } @@ -261,7 +262,7 @@ class I2PSessionImpl2 extends I2PSessionImpl { * @param keyUsed unused - no end-to-end crypto * @param tagsSent unused - no end-to-end crypto */ - public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set tagsSent) + public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set<SessionTag> tagsSent) throws I2PSessionException { return sendMessage(dest, payload, offset, size, keyUsed, tagsSent, 0); } @@ -272,7 +273,7 @@ class I2PSessionImpl2 extends I2PSessionImpl { * @param keyUsed unused - no end-to-end crypto * @param tagsSent unused - no end-to-end crypto */ - public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set tagsSent, long expires) + public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set<SessionTag> tagsSent, long expires) throws I2PSessionException { if (_log.shouldLog(Log.DEBUG)) _log.debug("sending message"); synchronized (_stateLock) { @@ -339,7 +340,7 @@ class I2PSessionImpl2 extends I2PSessionImpl { * @param keyUsed unused - no end-to-end crypto * @param tagsSent unused - no end-to-end crypto */ - protected boolean sendBestEffort(Destination dest, byte payload[], SessionKey keyUsed, Set tagsSent, long expires) + protected boolean sendBestEffort(Destination dest, byte payload[], SessionKey keyUsed, Set<SessionTag> tagsSent, long expires) throws I2PSessionException { return sendBestEffort(dest, payload, expires, 0); } diff --git a/core/java/src/net/i2p/client/impl/I2PSessionMuxedImpl.java b/core/java/src/net/i2p/client/impl/I2PSessionMuxedImpl.java index 46e551e495..6ee2b1e114 100644 --- a/core/java/src/net/i2p/client/impl/I2PSessionMuxedImpl.java +++ b/core/java/src/net/i2p/client/impl/I2PSessionMuxedImpl.java @@ -19,6 +19,7 @@ import net.i2p.client.SendMessageStatusListener; import net.i2p.data.DataHelper; import net.i2p.data.Destination; import net.i2p.data.SessionKey; +import net.i2p.data.SessionTag; import net.i2p.data.i2cp.MessagePayloadMessage; import net.i2p.util.Log; @@ -163,7 +164,7 @@ class I2PSessionMuxedImpl extends I2PSessionImpl2 { */ @Override public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, - SessionKey keyUsed, Set tagsSent, long expires) + SessionKey keyUsed, Set<SessionTag> tagsSent, long expires) throws I2PSessionException { return sendMessage(dest, payload, offset, size, keyUsed, tagsSent, 0, PROTO_UNSPECIFIED, PORT_UNSPECIFIED, PORT_UNSPECIFIED); } @@ -173,7 +174,7 @@ class I2PSessionMuxedImpl extends I2PSessionImpl2 { * @param tagsSent unused - no end-to-end crypto */ @Override - public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set tagsSent, + public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set<SessionTag> tagsSent, int proto, int fromport, int toport) throws I2PSessionException { return sendMessage(dest, payload, offset, size, keyUsed, tagsSent, 0, proto, fromport, toport); } @@ -192,7 +193,7 @@ class I2PSessionMuxedImpl extends I2PSessionImpl2 { */ @Override public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, - SessionKey keyUsed, Set tagsSent, long expires, + SessionKey keyUsed, Set<SessionTag> tagsSent, long expires, int proto, int fromPort, int toPort) throws I2PSessionException { return sendMessage(dest, payload, offset, size, keyUsed, tagsSent, 0, proto, fromPort, toPort, 0); @@ -213,7 +214,7 @@ class I2PSessionMuxedImpl extends I2PSessionImpl2 { */ @Override public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, - SessionKey keyUsed, Set tagsSent, long expires, + SessionKey keyUsed, Set<SessionTag> tagsSent, long expires, int proto, int fromPort, int toPort, int flags) throws I2PSessionException { payload = prepPayload(payload, offset, size, proto, fromPort, toPort); diff --git a/core/java/src/net/i2p/client/naming/NamingService.java b/core/java/src/net/i2p/client/naming/NamingService.java index 5a38c9e7fa..be9e598c21 100644 --- a/core/java/src/net/i2p/client/naming/NamingService.java +++ b/core/java/src/net/i2p/client/naming/NamingService.java @@ -536,7 +536,7 @@ public abstract class NamingService { String impl = context.getProperty(PROP_IMPL, DEFAULT_IMPL); try { Class<?> cls = Class.forName(impl); - Constructor<?> con = cls.getConstructor(new Class[] { I2PAppContext.class }); + Constructor<?> con = cls.getConstructor(I2PAppContext.class); instance = (NamingService)con.newInstance(new Object[] { context }); } catch (Exception ex) { Log log = context.logManager().getLog(NamingService.class); diff --git a/core/java/src/net/i2p/data/SDSCache.java b/core/java/src/net/i2p/data/SDSCache.java index ab77680149..f38fe6bbfa 100644 --- a/core/java/src/net/i2p/data/SDSCache.java +++ b/core/java/src/net/i2p/data/SDSCache.java @@ -46,7 +46,6 @@ import net.i2p.util.SystemVersion; public class SDSCache<V extends SimpleDataStructure> { //private static final Log _log = I2PAppContext.getGlobalContext().logManager().getLog(SDSCache.class); - private static final Class[] conArg = new Class[] { byte[].class }; private static final double MIN_FACTOR = 0.20; private static final double MAX_FACTOR = 5.0; private static final double FACTOR; @@ -74,7 +73,7 @@ public class SDSCache<V extends SimpleDataStructure> { _cache = new LHMCache<Integer, WeakReference<V>>(size); _datalen = len; try { - _rvCon = rvClass.getConstructor(conArg); + _rvCon = rvClass.getConstructor(byte[].class); } catch (NoSuchMethodException e) { throw new RuntimeException("SDSCache init error", e); } diff --git a/core/java/src/net/i2p/util/PortMapper.java b/core/java/src/net/i2p/util/PortMapper.java index d32a4f5a5a..e73399b19c 100644 --- a/core/java/src/net/i2p/util/PortMapper.java +++ b/core/java/src/net/i2p/util/PortMapper.java @@ -111,7 +111,7 @@ public class PortMapper { * @since 0.9.20 */ public void renderStatusHTML(Writer out) throws IOException { - List<String> services = new ArrayList(_dir.keySet()); + List<String> services = new ArrayList<String>(_dir.keySet()); out.write("<h2>Port Mapper</h2><table><tr><th>Service<th>Host<th>Port\n"); Collections.sort(services); for (String s : services) { diff --git a/core/java/src/net/i2p/util/SimpleTimer2.java b/core/java/src/net/i2p/util/SimpleTimer2.java index aff0b61f68..f2be244051 100644 --- a/core/java/src/net/i2p/util/SimpleTimer2.java +++ b/core/java/src/net/i2p/util/SimpleTimer2.java @@ -122,7 +122,7 @@ public class SimpleTimer2 { } } - private ScheduledFuture schedule(TimedEvent t, long timeoutMs) { + private ScheduledFuture<?> schedule(TimedEvent t, long timeoutMs) { return _executor.schedule(t, timeoutMs, TimeUnit.MILLISECONDS); } @@ -248,7 +248,7 @@ public class SimpleTimer2 { private final SimpleTimer2 _pool; private int _fuzz; protected static final int DEFAULT_FUZZ = 3; - private ScheduledFuture _future; // _executor.remove() doesn't work so we have to use this + private ScheduledFuture<?> _future; // _executor.remove() doesn't work so we have to use this // ... and I expect cancelling this way is more efficient /** state of the current event. All access should be under lock. */ -- GitLab