diff --git a/core/java/src/net/i2p/I2PAppContext.java b/core/java/src/net/i2p/I2PAppContext.java index b59a405860e38cfba0110f5f954bfd53ee9275c1..bae35726049b7725aded3c82035cb1804c6d10a9 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 458b9a892dea8a5480a4cdaf70bca768f633ca3d..818cb598350ed28d27738f665689b9cb3120549d 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 f44b897a3b3d2399269f289250fdd26bdd68c7e2..bcdd0b4eaec5f63404bd12c557de2253139d653f 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 4eddcc30ec85f3dbd91a9387e4244713150caec3..e110889be83868781d98097115c048b1f0cb8256 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 46e551e495a5919e19bc0283ff4c8705a04abc75..6ee2b1e114d8ea21fefc5cf6fe0eeb088c845ec0 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 5a38c9e7fa1e17726d70351886ec97f7870d4dd0..be9e598c215f1f41a41367f49bc90ee3ef0f2217 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 ab77680149d7380150d2cbd7dad3e05f1ef4ab70..f38fe6bbfaf43fadb784b81cb50ff387fa456a71 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 d32a4f5a5a1617abc7e3a886e5e41e8cc02c92f2..e73399b19c73491d209c790600fff931765226d0 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 aff0b61f68e7a79b7f0a2d9923ca1b62af3fae66..f2be244051bc0a327144e6ae4666afb5794efd3c 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. */