From 89dcceefeec31af9ca5b044dbc4cffa919f14f4b Mon Sep 17 00:00:00 2001 From: str4d <str4d@mail.i2p> Date: Wed, 20 Nov 2013 04:02:28 +0000 Subject: [PATCH] Core: type arguments, unused imports --- core/java/src/net/i2p/I2PAppContext.java | 4 +-- core/java/src/net/i2p/app/ClientApp.java | 2 -- .../net/i2p/client/ClientWriterRunner.java | 2 +- .../i2p/client/I2PSessionDemultiplexer.java | 2 +- .../src/net/i2p/client/I2PSessionImpl.java | 13 ++++---- .../src/net/i2p/client/I2PSessionImpl2.java | 10 +++--- .../net/i2p/client/I2PSessionMuxedImpl.java | 3 +- .../java/src/net/i2p/client/MessageState.java | 10 +++--- .../client/RequestLeaseSetMessageHandler.java | 2 +- .../src/net/i2p/client/SessionIdleTimer.java | 1 - .../client/naming/BlockfileNamingService.java | 18 +++++----- .../i2p/client/naming/DummyNamingService.java | 2 +- .../client/naming/EepGetNamingService.java | 8 ++--- .../client/naming/HostsTxtNamingService.java | 4 +-- .../i2p/client/naming/MetaNamingService.java | 8 ++--- .../net/i2p/client/naming/NamingService.java | 10 +++--- .../naming/SingleFileNamingService.java | 12 +++---- core/java/src/net/i2p/crypto/CertUtil.java | 3 -- .../src/net/i2p/crypto/CryptixAESEngine.java | 1 - .../net/i2p/crypto/CryptixAESKeyCache.java | 2 +- core/java/src/net/i2p/crypto/DSAEngine.java | 2 -- core/java/src/net/i2p/crypto/ECConstants.java | 3 -- .../src/net/i2p/crypto/ElGamalAESEngine.java | 33 +++++++++---------- .../src/net/i2p/crypto/HMACGenerator.java | 2 +- .../java/src/net/i2p/crypto/KeyStoreUtil.java | 3 -- .../src/net/i2p/crypto/SHA256Generator.java | 2 +- core/java/src/net/i2p/crypto/SU3File.java | 6 +--- core/java/src/net/i2p/crypto/SigUtil.java | 8 ++--- .../crypto/TransientSessionKeyManager.java | 26 +++++++-------- .../src/net/i2p/crypto/TrustedUpdate.java | 4 +-- core/java/src/net/i2p/crypto/YKGenerator.java | 2 +- core/java/src/net/i2p/data/DataHelper.java | 6 ++-- core/java/src/net/i2p/data/Destination.java | 3 +- core/java/src/net/i2p/data/Hash.java | 2 +- core/java/src/net/i2p/data/LeaseSet.java | 12 +++---- core/java/src/net/i2p/data/PublicKey.java | 2 +- core/java/src/net/i2p/data/RouterInfo.java | 6 ++-- core/java/src/net/i2p/data/SDSCache.java | 4 +-- .../src/net/i2p/data/SigningPublicKey.java | 2 +- .../i2p/data/i2cp/CreateLeaseSetMessage.java | 1 - .../i2p/data/i2cp/CreateSessionMessage.java | 1 - .../net/i2p/data/i2cp/DestLookupMessage.java | 1 - .../net/i2p/data/i2cp/DestReplyMessage.java | 1 - .../i2p/data/i2cp/DestroySessionMessage.java | 1 - .../data/i2cp/ReconfigureSessionMessage.java | 1 - .../net/i2p/data/i2cp/ReportAbuseMessage.java | 1 - .../i2p/data/i2cp/RequestLeaseSetMessage.java | 2 +- .../i2cp/RequestVariableLeaseSetMessage.java | 2 +- .../src/net/i2p/stat/BufferedStatLog.java | 4 +-- core/java/src/net/i2p/update/Checker.java | 3 -- core/java/src/net/i2p/util/Addresses.java | 4 +-- core/java/src/net/i2p/util/ByteCache.java | 6 ++-- core/java/src/net/i2p/util/Clock.java | 2 +- .../src/net/i2p/util/ConcurrentHashSet.java | 4 +-- core/java/src/net/i2p/util/EepGet.java | 6 ++-- .../src/net/i2p/util/EventDispatcher.java | 2 +- .../src/net/i2p/util/EventDispatcherImpl.java | 8 ++--- core/java/src/net/i2p/util/FileUtil.java | 6 ++-- core/java/src/net/i2p/util/I2PAppThread.java | 6 ++-- .../src/net/i2p/util/I2PSSLSocketFactory.java | 2 -- core/java/src/net/i2p/util/I2PThread.java | 6 ++-- .../net/i2p/util/InternalServerSocket.java | 4 +-- .../src/net/i2p/util/LogConsoleBuffer.java | 8 ++--- core/java/src/net/i2p/util/LogManager.java | 8 ++--- .../src/net/i2p/util/NativeBigInteger.java | 7 ++-- core/java/src/net/i2p/util/PortMapper.java | 2 +- .../net/i2p/util/ReusableGZIPInputStream.java | 2 +- .../i2p/util/ReusableGZIPOutputStream.java | 2 +- core/java/src/net/i2p/util/SSLEepGet.java | 4 --- .../src/net/i2p/util/SimpleByteCache.java | 7 ++-- core/java/src/net/i2p/util/SimpleTimer.java | 12 +++---- core/java/src/net/i2p/util/Translate.java | 4 +-- .../src/net/i2p/util/TranslateReader.java | 4 +-- .../net/metanotion/io/block/BlockFile.java | 8 ++--- .../io/block/index/BSkipLevels.java | 4 +-- .../metanotion/io/block/index/BSkipList.java | 4 +-- 76 files changed, 174 insertions(+), 221 deletions(-) diff --git a/core/java/src/net/i2p/I2PAppContext.java b/core/java/src/net/i2p/I2PAppContext.java index 5760948b39..9a45598f4b 100644 --- a/core/java/src/net/i2p/I2PAppContext.java +++ b/core/java/src/net/i2p/I2PAppContext.java @@ -201,7 +201,7 @@ public class I2PAppContext { _overrideProps = new I2PProperties(); if (envProps != null) _overrideProps.putAll(envProps); - _shutdownTasks = new ConcurrentHashSet(32); + _shutdownTasks = new ConcurrentHashSet<Runnable>(32); _portMapper = new PortMapper(this); /* @@ -535,7 +535,7 @@ public class I2PAppContext { * * @return set of Strings containing the names of defined system properties */ - public Set getPropertyNames() { + public Set<String> getPropertyNames() { // clone to avoid ConcurrentModificationException Set names = new HashSet(((Properties) System.getProperties().clone()).keySet()); if (_overrideProps != null) diff --git a/core/java/src/net/i2p/app/ClientApp.java b/core/java/src/net/i2p/app/ClientApp.java index 545659917f..3f611454d3 100644 --- a/core/java/src/net/i2p/app/ClientApp.java +++ b/core/java/src/net/i2p/app/ClientApp.java @@ -1,7 +1,5 @@ package net.i2p.app; -import net.i2p.I2PAppContext; - /** * If a class started via clients.config implements this interface, * it will be used to manage the client, instead of starting with main() diff --git a/core/java/src/net/i2p/client/ClientWriterRunner.java b/core/java/src/net/i2p/client/ClientWriterRunner.java index 9edf52f543..d25f741c5c 100644 --- a/core/java/src/net/i2p/client/ClientWriterRunner.java +++ b/core/java/src/net/i2p/client/ClientWriterRunner.java @@ -33,7 +33,7 @@ class ClientWriterRunner implements Runnable { public ClientWriterRunner(OutputStream out, I2PSessionImpl session) { _out = new BufferedOutputStream(out); _session = session; - _messagesToWrite = new LinkedBlockingQueue(MAX_QUEUE_SIZE); + _messagesToWrite = new LinkedBlockingQueue<I2CPMessage>(MAX_QUEUE_SIZE); Thread t = new I2PAppThread(this, "I2CP Client Writer " + __Id.incrementAndGet(), true); t.start(); } diff --git a/core/java/src/net/i2p/client/I2PSessionDemultiplexer.java b/core/java/src/net/i2p/client/I2PSessionDemultiplexer.java index a132a1ac3d..1f07a32fc9 100644 --- a/core/java/src/net/i2p/client/I2PSessionDemultiplexer.java +++ b/core/java/src/net/i2p/client/I2PSessionDemultiplexer.java @@ -27,7 +27,7 @@ public class I2PSessionDemultiplexer implements I2PSessionMuxedListener { public I2PSessionDemultiplexer(I2PAppContext ctx) { _log = ctx.logManager().getLog(I2PSessionDemultiplexer.class); - _listeners = new ConcurrentHashMap(); + _listeners = new ConcurrentHashMap<Integer, I2PSessionMuxedListener>(); } /** unused */ diff --git a/core/java/src/net/i2p/client/I2PSessionImpl.java b/core/java/src/net/i2p/client/I2PSessionImpl.java index 2d88ce6542..465ff8a69a 100644 --- a/core/java/src/net/i2p/client/I2PSessionImpl.java +++ b/core/java/src/net/i2p/client/I2PSessionImpl.java @@ -47,7 +47,6 @@ import net.i2p.util.I2PAppThread; import net.i2p.util.I2PSSLSocketFactory; import net.i2p.util.LHMCache; import net.i2p.util.Log; -import net.i2p.util.SimpleScheduler; import net.i2p.util.SimpleTimer; import net.i2p.util.VersionComparator; @@ -99,7 +98,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa protected Map<Long, MessagePayloadMessage> _availableMessages; /** hashes of lookups we are waiting for */ - protected final LinkedBlockingQueue<LookupWaiter> _pendingLookups = new LinkedBlockingQueue(); + protected final LinkedBlockingQueue<LookupWaiter> _pendingLookups = new LinkedBlockingQueue<LookupWaiter>(); protected final Object _bwReceivedLock = new Object(); protected volatile int[] _bwLimits; @@ -145,7 +144,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa /** * @since 0.8.9 */ - private static final Map<Hash, Destination> _lookupCache = new LHMCache(16); + private static final Map<Hash, Destination> _lookupCache = new LHMCache<Hash, Destination>(16); /** SSL interface (only) @since 0.8.3 */ protected static final String PROP_ENABLE_SSL = "i2cp.SSL"; @@ -196,7 +195,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa _fastReceive = Boolean.parseBoolean(_options.getProperty(I2PClient.PROP_FAST_RECEIVE)); if (hasDest) { _producer = new I2CPMessageProducer(context); - _availableMessages = new ConcurrentHashMap(); + _availableMessages = new ConcurrentHashMap<Long, MessagePayloadMessage>(); _myDestination = new Destination(); _privateKey = new PrivateKey(); _signingPrivateKey = new SigningPrivateKey(); @@ -593,7 +592,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa * message. Just copy all unclaimed ones and check 30 seconds later. */ private class VerifyUsage implements SimpleTimer.TimedEvent { - private final List<Long> toCheck = new ArrayList(); + private final List<Long> toCheck = new ArrayList<Long>(); public void timeReached() { if (isClosed()) @@ -623,8 +622,8 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa private volatile boolean _alive; public AvailabilityNotifier() { - _pendingIds = new ArrayList(2); - _pendingSizes = new ArrayList(2); + _pendingIds = new ArrayList<Long>(2); + _pendingSizes = new ArrayList<Integer>(2); } public void stopNotifying() { diff --git a/core/java/src/net/i2p/client/I2PSessionImpl2.java b/core/java/src/net/i2p/client/I2PSessionImpl2.java index eb537815ed..487d53e279 100644 --- a/core/java/src/net/i2p/client/I2PSessionImpl2.java +++ b/core/java/src/net/i2p/client/I2PSessionImpl2.java @@ -63,7 +63,7 @@ class I2PSessionImpl2 extends I2PSessionImpl { */ public I2PSessionImpl2(I2PAppContext ctx, InputStream destKeyStream, Properties options) throws I2PSessionException { super(ctx, destKeyStream, options); - _sendingStates = new HashSet(32); + _sendingStates = new HashSet<MessageState>(32); // default is BestEffort _noEffort = "none".equals(getOptions().getProperty(I2PClient.PROP_RELIABILITY, "").toLowerCase(Locale.US)); @@ -449,8 +449,8 @@ class I2PSessionImpl2 extends I2PSessionImpl { long inSync = 0; synchronized (_sendingStates) { inSync = _context.clock().now(); - for (Iterator iter = _sendingStates.iterator(); iter.hasNext();) { - state = (MessageState) iter.next(); + for (Iterator<MessageState> iter = _sendingStates.iterator(); iter.hasNext();) { + state = iter.next(); if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "State " + state.getMessageId() + " / " + state.getNonce()); if (state.getNonce() == nonce) { if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Found a matching state"); @@ -523,8 +523,8 @@ class I2PSessionImpl2 extends I2PSessionImpl { if (_sendingStates == null) // only null if overridden by I2PSimpleSession return; synchronized (_sendingStates) { - for (Iterator iter = _sendingStates.iterator(); iter.hasNext();) { - MessageState state = (MessageState) iter.next(); + for (Iterator<MessageState> iter = _sendingStates.iterator(); iter.hasNext();) { + MessageState state = iter.next(); state.cancel(); } if (_log.shouldLog(Log.INFO)) _log.info(getPrefix() + "Disconnecting " + _sendingStates.size() + " states"); diff --git a/core/java/src/net/i2p/client/I2PSessionMuxedImpl.java b/core/java/src/net/i2p/client/I2PSessionMuxedImpl.java index 383a59b817..89a9161b0f 100644 --- a/core/java/src/net/i2p/client/I2PSessionMuxedImpl.java +++ b/core/java/src/net/i2p/client/I2PSessionMuxedImpl.java @@ -16,7 +16,6 @@ import net.i2p.data.Destination; import net.i2p.data.SessionKey; import net.i2p.data.i2cp.MessagePayloadMessage; import net.i2p.util.Log; -import net.i2p.util.SimpleScheduler; /** * I2PSession with protocol and ports @@ -297,7 +296,7 @@ class I2PSessionMuxedImpl extends I2PSessionImpl2 { private final AtomicBoolean stopping = new AtomicBoolean(false); public MuxedAvailabilityNotifier() { - _msgs = new LinkedBlockingQueue(); + _msgs = new LinkedBlockingQueue<MsgData>(); } @Override diff --git a/core/java/src/net/i2p/client/MessageState.java b/core/java/src/net/i2p/client/MessageState.java index 326fec9898..7425ed56dd 100644 --- a/core/java/src/net/i2p/client/MessageState.java +++ b/core/java/src/net/i2p/client/MessageState.java @@ -41,7 +41,7 @@ class MessageState { _log = ctx.logManager().getLog(MessageState.class); _nonce = nonce; _prefix = prefix + "[" + _stateId + "]: "; - _receivedStatus = new HashSet(); + _receivedStatus = new HashSet<Integer>(); _created = ctx.clock().now(); //ctx.statManager().createRateStat("i2cp.checkStatusTime", "how long it takes to go through the states", "i2cp", new long[] { 60*1000 }); } @@ -150,8 +150,8 @@ class MessageState { if (_log.shouldLog(Log.DEBUG)) _log.debug(_prefix + "isSuccess(" + wantedStatus + "): " + _receivedStatus); - for (Iterator iter = _receivedStatus.iterator(); iter.hasNext();) { - Integer val = (Integer) iter.next(); + for (Iterator<Integer> iter = _receivedStatus.iterator(); iter.hasNext();) { + Integer val = iter.next(); int recv = val.intValue(); switch (recv) { case MessageStatusMessage.STATUS_SEND_BEST_EFFORT_FAILURE: @@ -210,8 +210,8 @@ class MessageState { if (_log.shouldLog(Log.DEBUG)) _log.debug(_prefix + "isFailure(" + wantedStatus + "): " + _receivedStatus); - for (Iterator iter = _receivedStatus.iterator(); iter.hasNext();) { - Integer val = (Integer) iter.next(); + for (Iterator<Integer> iter = _receivedStatus.iterator(); iter.hasNext();) { + Integer val = iter.next(); int recv = val.intValue(); switch (recv) { case MessageStatusMessage.STATUS_SEND_BEST_EFFORT_FAILURE: diff --git a/core/java/src/net/i2p/client/RequestLeaseSetMessageHandler.java b/core/java/src/net/i2p/client/RequestLeaseSetMessageHandler.java index eea6d294d5..620f571f4d 100644 --- a/core/java/src/net/i2p/client/RequestLeaseSetMessageHandler.java +++ b/core/java/src/net/i2p/client/RequestLeaseSetMessageHandler.java @@ -48,7 +48,7 @@ class RequestLeaseSetMessageHandler extends HandlerImpl { protected RequestLeaseSetMessageHandler(I2PAppContext context, int messageType) { super(context, messageType); // not clear why there would ever be more than one - _existingLeaseSets = new ConcurrentHashMap(4); + _existingLeaseSets = new ConcurrentHashMap<Destination, LeaseInfo>(4); } public void handleMessage(I2CPMessage message, I2PSessionImpl session) { diff --git a/core/java/src/net/i2p/client/SessionIdleTimer.java b/core/java/src/net/i2p/client/SessionIdleTimer.java index cf5c8c0291..d01273f930 100644 --- a/core/java/src/net/i2p/client/SessionIdleTimer.java +++ b/core/java/src/net/i2p/client/SessionIdleTimer.java @@ -10,7 +10,6 @@ import java.util.Properties; import net.i2p.I2PAppContext; import net.i2p.data.DataHelper; import net.i2p.util.Log; -import net.i2p.util.SimpleScheduler; import net.i2p.util.SimpleTimer; /** diff --git a/core/java/src/net/i2p/client/naming/BlockfileNamingService.java b/core/java/src/net/i2p/client/naming/BlockfileNamingService.java index d1fd7530a3..9194d81aa1 100644 --- a/core/java/src/net/i2p/client/naming/BlockfileNamingService.java +++ b/core/java/src/net/i2p/client/naming/BlockfileNamingService.java @@ -133,9 +133,9 @@ public class BlockfileNamingService extends DummyNamingService { */ public BlockfileNamingService(I2PAppContext context) { super(context); - _lists = new ArrayList(); - _invalid = new ArrayList(); - _negativeCache = new LHMCache(NEGATIVE_CACHE_SIZE); + _lists = new ArrayList<String>(); + _invalid = new ArrayList<InvalidEntry>(); + _negativeCache = new LHMCache<String, String>(NEGATIVE_CACHE_SIZE); BlockFile bf = null; RAIFile raf = null; boolean readOnly = false; @@ -468,7 +468,7 @@ public class BlockfileNamingService extends DummyNamingService { private static List<String> getFilenames(String list) { StringTokenizer tok = new StringTokenizer(list, ","); - List<String> rv = new ArrayList(tok.countTokens()); + List<String> rv = new ArrayList<String>(tok.countTokens()); while (tok.hasMoreTokens()) rv.add(tok.nextToken()); return rv; @@ -847,20 +847,20 @@ public class BlockfileNamingService extends DummyNamingService { " limit=" + limit + " skip=" + skip); synchronized(_bf) { if (_isClosed) - return Collections.EMPTY_MAP; + return Collections.emptyMap(); try { SkipList sl = _bf.getIndex(listname, _stringSerializer, _destSerializer); if (sl == null) { if (_log.shouldLog(Log.WARN)) _log.warn("No skiplist found for lookup in " + listname); - return Collections.EMPTY_MAP; + return Collections.emptyMap(); } SkipIterator iter; if (beginWith != null) iter = sl.find(beginWith); else iter = sl.iterator(); - Map<String, Destination> rv = new HashMap(); + Map<String, Destination> rv = new HashMap<String, Destination>(); for (int i = 0; i < skip && iter.hasNext(); i++) { // don't bother validating here iter.next(); @@ -886,10 +886,10 @@ public class BlockfileNamingService extends DummyNamingService { return rv; } catch (IOException ioe) { _log.error("DB lookup error", ioe); - return Collections.EMPTY_MAP; + return Collections.emptyMap(); } catch (RuntimeException re) { _log.error("DB lookup error", re); - return Collections.EMPTY_MAP; + return Collections.emptyMap(); } finally { deleteInvalid(); } diff --git a/core/java/src/net/i2p/client/naming/DummyNamingService.java b/core/java/src/net/i2p/client/naming/DummyNamingService.java index 62695d9ed1..e3279ab963 100644 --- a/core/java/src/net/i2p/client/naming/DummyNamingService.java +++ b/core/java/src/net/i2p/client/naming/DummyNamingService.java @@ -31,7 +31,7 @@ class DummyNamingService extends NamingService { * Classes should take care to call removeCache() for any entries that * are invalidated. */ - private static final Map<String, Destination> _cache = new LHMCache(CACHE_MAX_SIZE); + private static final Map<String, Destination> _cache = new LHMCache<String, Destination>(CACHE_MAX_SIZE); /** * The naming service should only be constructed and accessed through the diff --git a/core/java/src/net/i2p/client/naming/EepGetNamingService.java b/core/java/src/net/i2p/client/naming/EepGetNamingService.java index 2bb4c18305..69af4e5ca1 100644 --- a/core/java/src/net/i2p/client/naming/EepGetNamingService.java +++ b/core/java/src/net/i2p/client/naming/EepGetNamingService.java @@ -50,10 +50,10 @@ public class EepGetNamingService extends DummyNamingService { super(context); } - private List getURLs() { + private List<String> getURLs() { String list = _context.getProperty(PROP_EEPGET_LIST, DEFAULT_EEPGET_LIST); StringTokenizer tok = new StringTokenizer(list, ","); - List rv = new ArrayList(tok.countTokens()); + List<String> rv = new ArrayList<String>(tok.countTokens()); while (tok.hasMoreTokens()) rv.add(tok.nextToken()); return rv; @@ -70,13 +70,13 @@ public class EepGetNamingService extends DummyNamingService { if (hostname.length() == BASE32_HASH_LENGTH + 8 && hostname.endsWith(".b32.i2p")) return null; - List URLs = getURLs(); + List<String> URLs = getURLs(); if (URLs.isEmpty()) return null; // prevent lookup loops - this cannot be the only lookup service for (int i = 0; i < URLs.size(); i++) { - String url = (String)URLs.get(i); + String url = URLs.get(i); if (url.startsWith("http://" + hostname + "/")) { _log.error("Lookup loop: " + hostname); return null; diff --git a/core/java/src/net/i2p/client/naming/HostsTxtNamingService.java b/core/java/src/net/i2p/client/naming/HostsTxtNamingService.java index baa371e766..7887e4acae 100644 --- a/core/java/src/net/i2p/client/naming/HostsTxtNamingService.java +++ b/core/java/src/net/i2p/client/naming/HostsTxtNamingService.java @@ -52,7 +52,7 @@ public class HostsTxtNamingService extends MetaNamingService { private List<String> getFilenames() { String list = _context.getProperty(PROP_HOSTS_FILE, DEFAULT_HOSTS_FILE); StringTokenizer tok = new StringTokenizer(list, ","); - List<String> rv = new ArrayList(tok.countTokens()); + List<String> rv = new ArrayList<String>(tok.countTokens()); while (tok.hasMoreTokens()) rv.add(tok.nextToken()); return rv; @@ -97,6 +97,6 @@ public class HostsTxtNamingService extends MetaNamingService { if (name.equals(file) || name.endsWith('/' + file) || name.endsWith('\\' + file)) return ns.getNames(options); } - return new HashSet(0); + return new HashSet<String>(0); } } diff --git a/core/java/src/net/i2p/client/naming/MetaNamingService.java b/core/java/src/net/i2p/client/naming/MetaNamingService.java index 86e7775b58..03e0ef7f9b 100644 --- a/core/java/src/net/i2p/client/naming/MetaNamingService.java +++ b/core/java/src/net/i2p/client/naming/MetaNamingService.java @@ -35,7 +35,7 @@ public class MetaNamingService extends DummyNamingService { super(context); String list = _context.getProperty(PROP_NAME_SERVICES, DEFAULT_NAME_SERVICES); StringTokenizer tok = new StringTokenizer(list, ","); - _services = new CopyOnWriteArrayList(); + _services = new CopyOnWriteArrayList<NamingService>(); while (tok.hasMoreTokens()) { try { Class cls = Class.forName(tok.nextToken()); @@ -53,7 +53,7 @@ public class MetaNamingService extends DummyNamingService { */ public MetaNamingService(I2PAppContext context, List<NamingService> services) { super(context); - _services = new CopyOnWriteArrayList(); + _services = new CopyOnWriteArrayList<NamingService>(); if (services != null) { for (NamingService ns : services) { addNamingService(ns, false); @@ -172,7 +172,7 @@ public class MetaNamingService extends DummyNamingService { */ @Override public Map<String, Destination> getEntries(Properties options) { - Map<String, Destination> rv = new HashMap(); + Map<String, Destination> rv = new HashMap<String, Destination>(); for (NamingService ns : _services) { rv.putAll(ns.getEntries(options)); } @@ -184,7 +184,7 @@ public class MetaNamingService extends DummyNamingService { */ @Override public Set<String> getNames(Properties options) { - Set<String> rv = new HashSet(); + Set<String> rv = new HashSet<String>(); for (NamingService ns : _services) { rv.addAll(ns.getNames(options)); } diff --git a/core/java/src/net/i2p/client/naming/NamingService.java b/core/java/src/net/i2p/client/naming/NamingService.java index d5c4200e2f..ceade7e317 100644 --- a/core/java/src/net/i2p/client/naming/NamingService.java +++ b/core/java/src/net/i2p/client/naming/NamingService.java @@ -45,8 +45,8 @@ public abstract class NamingService { protected NamingService(I2PAppContext context) { _context = context; _log = context.logManager().getLog(getClass()); - _listeners = new CopyOnWriteArraySet(); - _updaters = new CopyOnWriteArraySet(); + _listeners = new CopyOnWriteArraySet<NamingServiceListener>(); + _updaters = new CopyOnWriteArraySet<NamingServiceUpdater>(); } /** @@ -226,7 +226,7 @@ public abstract class NamingService { * @since 0.8.7 */ public Map<String, Destination> getEntries(Properties options) { - return Collections.EMPTY_MAP; + return Collections.emptyMap(); } /** @@ -242,7 +242,7 @@ public abstract class NamingService { * @since 0.8.7 */ public Map<String, String> getBase64Entries(Properties options) { - return Collections.EMPTY_MAP; + return Collections.emptyMap(); } /** @@ -263,7 +263,7 @@ public abstract class NamingService { * @since 0.8.7 */ public Set<String> getNames(Properties options) { - return Collections.EMPTY_SET; + return Collections.emptySet(); } /** diff --git a/core/java/src/net/i2p/client/naming/SingleFileNamingService.java b/core/java/src/net/i2p/client/naming/SingleFileNamingService.java index 8a8acdaec9..58a2d1a95c 100644 --- a/core/java/src/net/i2p/client/naming/SingleFileNamingService.java +++ b/core/java/src/net/i2p/client/naming/SingleFileNamingService.java @@ -308,7 +308,7 @@ public class SingleFileNamingService extends NamingService { @Override public Map<String, Destination> getEntries(Properties options) { if (!_file.exists()) - return Collections.EMPTY_MAP; + return Collections.emptyMap(); String searchOpt = null; String startsWith = null; if (options != null) { @@ -322,7 +322,7 @@ public class SingleFileNamingService extends NamingService { try { in = new BufferedReader(new InputStreamReader(new FileInputStream(_file), "UTF-8"), 16*1024); String line = null; - Map<String, Destination> rv = new HashMap(); + Map<String, Destination> rv = new HashMap<String, Destination>(); while ( (line = in.readLine()) != null) { if (line.length() <= 0) continue; @@ -357,7 +357,7 @@ public class SingleFileNamingService extends NamingService { return rv; } catch (IOException ioe) { _log.error("getEntries error", ioe); - return Collections.EMPTY_MAP; + return Collections.emptyMap(); } finally { if (in != null) try { in.close(); } catch (IOException ioe) {} releaseReadLock(); @@ -370,13 +370,13 @@ public class SingleFileNamingService extends NamingService { */ public Set<String> getNames(Properties options) { if (!_file.exists()) - return Collections.EMPTY_SET; + return Collections.emptySet(); BufferedReader in = null; getReadLock(); try { in = new BufferedReader(new InputStreamReader(new FileInputStream(_file), "UTF-8"), 16*1024); String line = null; - Set<String> rv = new HashSet(); + Set<String> rv = new HashSet<String>(); while ( (line = in.readLine()) != null) { if (line.length() <= 0) continue; @@ -391,7 +391,7 @@ public class SingleFileNamingService extends NamingService { return rv; } catch (IOException ioe) { _log.error("getNames error", ioe); - return Collections.EMPTY_SET; + return Collections.emptySet(); } finally { if (in != null) try { in.close(); } catch (IOException ioe) {} releaseReadLock(); diff --git a/core/java/src/net/i2p/crypto/CertUtil.java b/core/java/src/net/i2p/crypto/CertUtil.java index 27ca116f58..55d04a0864 100644 --- a/core/java/src/net/i2p/crypto/CertUtil.java +++ b/core/java/src/net/i2p/crypto/CertUtil.java @@ -4,11 +4,8 @@ import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; -import java.security.GeneralSecurityException; import java.security.cert.Certificate; -import java.security.cert.CertificateException; import java.security.cert.CertificateEncodingException; -import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; import java.util.Locale; diff --git a/core/java/src/net/i2p/crypto/CryptixAESEngine.java b/core/java/src/net/i2p/crypto/CryptixAESEngine.java index 18902adea1..35a2d37e61 100644 --- a/core/java/src/net/i2p/crypto/CryptixAESEngine.java +++ b/core/java/src/net/i2p/crypto/CryptixAESEngine.java @@ -18,7 +18,6 @@ import java.security.InvalidKeyException; //import javax.crypto.spec.SecretKeySpec; import net.i2p.I2PAppContext; -import net.i2p.data.ByteArray; import net.i2p.data.DataHelper; import net.i2p.data.SessionKey; import net.i2p.util.Log; diff --git a/core/java/src/net/i2p/crypto/CryptixAESKeyCache.java b/core/java/src/net/i2p/crypto/CryptixAESKeyCache.java index 63b6dcfbae..ae9d897090 100644 --- a/core/java/src/net/i2p/crypto/CryptixAESKeyCache.java +++ b/core/java/src/net/i2p/crypto/CryptixAESKeyCache.java @@ -26,7 +26,7 @@ public final class CryptixAESKeyCache { * @deprecated unused, keys are now cached in the SessionKey objects */ public CryptixAESKeyCache() { - _availableKeys = new LinkedBlockingQueue(MAX_KEYS); + _availableKeys = new LinkedBlockingQueue<KeyCacheEntry>(MAX_KEYS); } /** diff --git a/core/java/src/net/i2p/crypto/DSAEngine.java b/core/java/src/net/i2p/crypto/DSAEngine.java index 1a5638ce9e..dce8843e62 100644 --- a/core/java/src/net/i2p/crypto/DSAEngine.java +++ b/core/java/src/net/i2p/crypto/DSAEngine.java @@ -29,13 +29,11 @@ package net.i2p.crypto; * POSSIBILITY OF SUCH DAMAGE. */ -import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.math.BigInteger; import java.security.GeneralSecurityException; import java.security.Key; -import java.security.KeyFactory; import java.security.MessageDigest; import java.security.PrivateKey; import java.security.PublicKey; diff --git a/core/java/src/net/i2p/crypto/ECConstants.java b/core/java/src/net/i2p/crypto/ECConstants.java index 925291cdc5..2e9de224d8 100644 --- a/core/java/src/net/i2p/crypto/ECConstants.java +++ b/core/java/src/net/i2p/crypto/ECConstants.java @@ -3,11 +3,8 @@ package net.i2p.crypto; import java.lang.reflect.Constructor; import java.math.BigInteger; import java.security.AlgorithmParameters; -import java.security.AlgorithmParameterGenerator; -import java.security.GeneralSecurityException; import java.security.Provider; import java.security.Security; -import java.security.spec.AlgorithmParameterSpec; import java.security.spec.ECField; import java.security.spec.ECFieldFp; import java.security.spec.ECGenParameterSpec; diff --git a/core/java/src/net/i2p/crypto/ElGamalAESEngine.java b/core/java/src/net/i2p/crypto/ElGamalAESEngine.java index c5fe757781..849fd16006 100644 --- a/core/java/src/net/i2p/crypto/ElGamalAESEngine.java +++ b/core/java/src/net/i2p/crypto/ElGamalAESEngine.java @@ -17,7 +17,6 @@ import java.util.List; import java.util.Set; import net.i2p.I2PAppContext; -import net.i2p.data.Base64; import net.i2p.data.DataFormatException; import net.i2p.data.DataHelper; import net.i2p.data.Hash; @@ -100,7 +99,7 @@ public class ElGamalAESEngine { SessionKey key = keyManager.consumeTag(st); SessionKey foundKey = new SessionKey(); SessionKey usedKey = new SessionKey(); - Set foundTags = new HashSet(); + Set<SessionTag> foundTags = new HashSet<SessionTag>(); byte decrypted[] = null; boolean wasExisting = false; if (key != null) { @@ -170,7 +169,7 @@ public class ElGamalAESEngine { * * @return null if decryption fails */ - private byte[] decryptNewSession(byte data[], PrivateKey targetPrivateKey, Set foundTags, SessionKey usedKey, + private byte[] decryptNewSession(byte data[], PrivateKey targetPrivateKey, Set<SessionTag> foundTags, SessionKey usedKey, SessionKey foundKey) throws DataFormatException { if (data == null) { //if (_log.shouldLog(Log.WARN)) _log.warn("Data is null, unable to decrypt new session"); @@ -246,7 +245,7 @@ public class ElGamalAESEngine { * @return decrypted data or null on failure * */ - private byte[] decryptExistingSession(byte data[], SessionKey key, PrivateKey targetPrivateKey, Set foundTags, + private byte[] decryptExistingSession(byte data[], SessionKey key, PrivateKey targetPrivateKey, Set<SessionTag> foundTags, SessionKey usedKey, SessionKey foundKey) throws DataFormatException { byte preIV[] = SimpleByteCache.acquire(32); System.arraycopy(data, 0, preIV, 0, 32); @@ -315,7 +314,7 @@ public class ElGamalAESEngine { * Note: package private for ElGamalTest.testAES() */ byte[] decryptAESBlock(byte encrypted[], int offset, int encryptedLen, SessionKey key, byte iv[], - byte sentTag[], Set foundTags, SessionKey foundKey) throws DataFormatException { + byte sentTag[], Set<SessionTag> foundTags, SessionKey foundKey) throws DataFormatException { //_log.debug("iv for decryption: " + DataHelper.toString(iv, 16)); //_log.debug("decrypting AES block. encr.length = " + (encrypted == null? -1 : encrypted.length) + " sentTag: " + DataHelper.toString(sentTag, 32)); byte decrypted[] = new byte[encryptedLen]; @@ -324,13 +323,13 @@ public class ElGamalAESEngine { //_log.debug("Hash of entire aes block after decryption: \n" + DataHelper.toString(h.getData(), 32)); try { SessionKey newKey = null; - List tags = null; + List<SessionTag> tags = null; //ByteArrayInputStream bais = new ByteArrayInputStream(decrypted); int cur = 0; long numTags = DataHelper.fromLong(decrypted, cur, 2); if ((numTags < 0) || (numTags > MAX_TAGS_RECEIVED)) throw new Exception("Invalid number of session tags"); - if (numTags > 0) tags = new ArrayList((int)numTags); + if (numTags > 0) tags = new ArrayList<SessionTag>((int)numTags); cur += 2; //_log.debug("# tags: " + numTags); if (numTags * SessionTag.BYTE_LENGTH > decrypted.length - 2) { @@ -404,7 +403,7 @@ public class ElGamalAESEngine { * * Unused externally, only called by below (i.e. newKey is always null) */ - public byte[] encrypt(byte data[], PublicKey target, SessionKey key, Set tagsForDelivery, + public byte[] encrypt(byte data[], PublicKey target, SessionKey key, Set<SessionTag> tagsForDelivery, SessionTag currentTag, SessionKey newKey, long paddedSize) { if (currentTag == null) { if (_log.shouldLog(Log.INFO)) @@ -450,7 +449,7 @@ public class ElGamalAESEngine { * body's real size, no bytes are appended but the body is not truncated) * */ - public byte[] encrypt(byte data[], PublicKey target, SessionKey key, Set tagsForDelivery, + public byte[] encrypt(byte data[], PublicKey target, SessionKey key, Set<SessionTag> tagsForDelivery, SessionTag currentTag, long paddedSize) { return encrypt(data, target, key, tagsForDelivery, currentTag, null, paddedSize); } @@ -464,7 +463,7 @@ public class ElGamalAESEngine { * 200 max enforced at receiver * @deprecated unused */ - public byte[] encrypt(byte data[], PublicKey target, SessionKey key, Set tagsForDelivery, long paddedSize) { + public byte[] encrypt(byte data[], PublicKey target, SessionKey key, Set<SessionTag> tagsForDelivery, long paddedSize) { return encrypt(data, target, key, tagsForDelivery, null, null, paddedSize); } @@ -502,7 +501,7 @@ public class ElGamalAESEngine { * @param tagsForDelivery session tags to be associated with the key or null; * 200 max enforced at receiver */ - private byte[] encryptNewSession(byte data[], PublicKey target, SessionKey key, Set tagsForDelivery, + private byte[] encryptNewSession(byte data[], PublicKey target, SessionKey key, Set<SessionTag> tagsForDelivery, SessionKey newKey, long paddedSize) { //_log.debug("Encrypting to a NEW session"); byte elgSrcData[] = new byte[SessionKey.KEYSIZE_BYTES+32+158]; @@ -571,7 +570,7 @@ public class ElGamalAESEngine { * @param tagsForDelivery session tags to be associated with the key or null; * 200 max enforced at receiver */ - private byte[] encryptExistingSession(byte data[], PublicKey target, SessionKey key, Set tagsForDelivery, + private byte[] encryptExistingSession(byte data[], PublicKey target, SessionKey key, Set<SessionTag> tagsForDelivery, SessionTag currentTag, SessionKey newKey, long paddedSize) { //_log.debug("Encrypting to an EXISTING session"); byte rawTag[] = currentTag.getData(); @@ -629,7 +628,7 @@ public class ElGamalAESEngine { * @param tagsForDelivery session tags to be associated with the key or null; * 200 max enforced at receiver */ - final byte[] encryptAESBlock(byte data[], SessionKey key, byte[] iv, Set tagsForDelivery, SessionKey newKey, + final byte[] encryptAESBlock(byte data[], SessionKey key, byte[] iv, Set<SessionTag> tagsForDelivery, SessionKey newKey, long paddedSize) { return encryptAESBlock(data, key, iv, tagsForDelivery, newKey, paddedSize, 0); } @@ -639,11 +638,11 @@ public class ElGamalAESEngine { * @param tagsForDelivery session tags to be associated with the key or null; * 200 max enforced at receiver */ - private final byte[] encryptAESBlock(byte data[], SessionKey key, byte[] iv, Set tagsForDelivery, SessionKey newKey, + private final byte[] encryptAESBlock(byte data[], SessionKey key, byte[] iv, Set<SessionTag> tagsForDelivery, SessionKey newKey, long paddedSize, int prefixBytes) { //_log.debug("iv for encryption: " + DataHelper.toString(iv, 16)); //_log.debug("Encrypting AES"); - if (tagsForDelivery == null) tagsForDelivery = Collections.EMPTY_SET; + if (tagsForDelivery == null) tagsForDelivery = Collections.emptySet(); int size = 2 // sizeof(tags) + SessionTag.BYTE_LENGTH*tagsForDelivery.size() + 4 // payload length @@ -657,8 +656,8 @@ public class ElGamalAESEngine { int cur = prefixBytes; DataHelper.toLong(aesData, cur, 2, tagsForDelivery.size()); cur += 2; - for (Iterator iter = tagsForDelivery.iterator(); iter.hasNext();) { - SessionTag tag = (SessionTag) iter.next(); + for (Iterator<SessionTag> iter = tagsForDelivery.iterator(); iter.hasNext();) { + SessionTag tag = iter.next(); System.arraycopy(tag.getData(), 0, aesData, cur, SessionTag.BYTE_LENGTH); cur += SessionTag.BYTE_LENGTH; } diff --git a/core/java/src/net/i2p/crypto/HMACGenerator.java b/core/java/src/net/i2p/crypto/HMACGenerator.java index b6f13b1e3d..f5643ca1b9 100644 --- a/core/java/src/net/i2p/crypto/HMACGenerator.java +++ b/core/java/src/net/i2p/crypto/HMACGenerator.java @@ -49,7 +49,7 @@ public class HMACGenerator { * @param context unused */ public HMACGenerator(I2PAppContext context) { - _available = new LinkedBlockingQueue(32); + _available = new LinkedBlockingQueue<I2PHMac>(32); } /** diff --git a/core/java/src/net/i2p/crypto/KeyStoreUtil.java b/core/java/src/net/i2p/crypto/KeyStoreUtil.java index 665f9c907c..81179ae8f4 100644 --- a/core/java/src/net/i2p/crypto/KeyStoreUtil.java +++ b/core/java/src/net/i2p/crypto/KeyStoreUtil.java @@ -9,8 +9,6 @@ import java.security.GeneralSecurityException; import java.security.KeyStore; import java.security.PrivateKey; import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.security.cert.CertificateEncodingException; import java.security.cert.CertificateExpiredException; import java.security.cert.CertificateNotYetValidException; import java.security.cert.CertificateFactory; @@ -20,7 +18,6 @@ import java.util.Locale; import net.i2p.I2PAppContext; import net.i2p.data.Base32; -import net.i2p.data.DataHelper; import net.i2p.util.Log; import net.i2p.util.SecureDirectory; import net.i2p.util.SecureFileOutputStream; diff --git a/core/java/src/net/i2p/crypto/SHA256Generator.java b/core/java/src/net/i2p/crypto/SHA256Generator.java index d46488fe91..162b9d0c16 100644 --- a/core/java/src/net/i2p/crypto/SHA256Generator.java +++ b/core/java/src/net/i2p/crypto/SHA256Generator.java @@ -35,7 +35,7 @@ public final class SHA256Generator { * @param context unused */ public SHA256Generator(I2PAppContext context) { - _digests = new LinkedBlockingQueue(32); + _digests = new LinkedBlockingQueue<MessageDigest>(32); } public static final SHA256Generator getInstance() { diff --git a/core/java/src/net/i2p/crypto/SU3File.java b/core/java/src/net/i2p/crypto/SU3File.java index c68192d7fa..dd23ad05ab 100644 --- a/core/java/src/net/i2p/crypto/SU3File.java +++ b/core/java/src/net/i2p/crypto/SU3File.java @@ -30,11 +30,7 @@ import net.i2p.I2PAppContext; import net.i2p.data.DataFormatException; import net.i2p.data.DataHelper; import net.i2p.data.Signature; -import net.i2p.data.SigningPrivateKey; -import net.i2p.data.SigningPublicKey; import net.i2p.data.SimpleDataStructure; -import net.i2p.util.HexDump; -import net.i2p.util.SecureFileOutputStream; /** * Succesor to the ".sud" format used in TrustedUpdate. @@ -441,7 +437,7 @@ public class SU3File { */ public static void main(String[] args) { boolean ok = false; - List<String> a = new ArrayList(Arrays.asList(args)); + List<String> a = new ArrayList<String>(Arrays.asList(args)); try { // defaults String stype = null; diff --git a/core/java/src/net/i2p/crypto/SigUtil.java b/core/java/src/net/i2p/crypto/SigUtil.java index da2fa363e5..52ca857e62 100644 --- a/core/java/src/net/i2p/crypto/SigUtil.java +++ b/core/java/src/net/i2p/crypto/SigUtil.java @@ -21,14 +21,10 @@ import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; import java.security.spec.DSAPrivateKeySpec; import java.security.spec.DSAPublicKeySpec; -import java.security.spec.ECField; -import java.security.spec.ECFieldFp; -import java.security.spec.ECGenParameterSpec; import java.security.spec.ECParameterSpec; import java.security.spec.ECPrivateKeySpec; import java.security.spec.ECPublicKeySpec; import java.security.spec.ECPoint; -import java.security.spec.EllipticCurve; import java.security.spec.KeySpec; import java.security.spec.PKCS8EncodedKeySpec; import java.security.spec.RSAKeyGenParameterSpec; @@ -51,8 +47,8 @@ import net.i2p.util.NativeBigInteger; */ class SigUtil { - private static final Map<SigningPublicKey, ECPublicKey> _pubkeyCache = new LHMCache(64); - private static final Map<SigningPrivateKey, ECPrivateKey> _privkeyCache = new LHMCache(16); + private static final Map<SigningPublicKey, ECPublicKey> _pubkeyCache = new LHMCache<SigningPublicKey, ECPublicKey>(64); + private static final Map<SigningPrivateKey, ECPrivateKey> _privkeyCache = new LHMCache<SigningPrivateKey, ECPrivateKey>(16); private SigUtil() {} diff --git a/core/java/src/net/i2p/crypto/TransientSessionKeyManager.java b/core/java/src/net/i2p/crypto/TransientSessionKeyManager.java index dbe17366a4..8ebfdbf903 100644 --- a/core/java/src/net/i2p/crypto/TransientSessionKeyManager.java +++ b/core/java/src/net/i2p/crypto/TransientSessionKeyManager.java @@ -19,7 +19,6 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.NoSuchElementException; import java.util.Set; import java.util.TreeSet; import java.util.concurrent.atomic.AtomicInteger; @@ -30,7 +29,6 @@ import net.i2p.data.PublicKey; import net.i2p.data.SessionKey; import net.i2p.data.SessionTag; import net.i2p.util.Log; -import net.i2p.util.SimpleScheduler; import net.i2p.util.SimpleTimer; /** @@ -177,8 +175,8 @@ public class TransientSessionKeyManager extends SessionKeyManager { _lowThreshold = lowThreshold; _log = context.logManager().getLog(TransientSessionKeyManager.class); _context = context; - _outboundSessions = new HashMap(64); - _inboundTagSets = new HashMap(128); + _outboundSessions = new HashMap<PublicKey, OutboundSession>(64); + _inboundTagSets = new HashMap<SessionTag, TagSet>(128); context.statManager().createRateStat("crypto.sessionTagsExpired", "How many tags/sessions are expired?", "Encryption", new long[] { 10*60*1000, 60*60*1000, 3*60*60*1000 }); context.statManager().createRateStat("crypto.sessionTagsRemaining", "How many tags/sessions are remaining after a cleanup?", "Encryption", new long[] { 10*60*1000, 60*60*1000, 3*60*60*1000 }); _alive = true; @@ -212,14 +210,14 @@ public class TransientSessionKeyManager extends SessionKeyManager { /** TagSet - used only by HTML */ private Set<TagSet> getInboundTagSets() { synchronized (_inboundTagSets) { - return new HashSet(_inboundTagSets.values()); + return new HashSet<TagSet>(_inboundTagSets.values()); } } /** OutboundSession - used only by HTML */ private Set<OutboundSession> getOutboundSessions() { synchronized (_outboundSessions) { - return new HashSet(_outboundSessions.values()); + return new HashSet<OutboundSession>(_outboundSessions.values()); } } @@ -586,7 +584,7 @@ public class TransientSessionKeyManager extends SessionKeyManager { int tags = 0; int toRemove = overage * 2; _log.log(Log.CRIT, "TOO MANY SESSION TAGS! Starting cleanup, overage = " + overage); - List<TagSet> removed = new ArrayList(toRemove); + List<TagSet> removed = new ArrayList<TagSet>(toRemove); synchronized (_inboundTagSets) { for (TagSet set : _inboundTagSets.values()) { int size = set.getTags().size(); @@ -717,12 +715,12 @@ public class TransientSessionKeyManager extends SessionKeyManager { buf.append("<h2>Inbound sessions</h2>" + "<table>"); Set<TagSet> inbound = getInboundTagSets(); - Map<SessionKey, Set<TagSet>> inboundSets = new HashMap(inbound.size()); + Map<SessionKey, Set<TagSet>> inboundSets = new HashMap<SessionKey, Set<TagSet>>(inbound.size()); // Build a map of the inbound tag sets, grouped by SessionKey for (TagSet ts : inbound) { Set<TagSet> sets = inboundSets.get(ts.getAssociatedKey()); if (sets == null) { - sets = new HashSet(); + sets = new HashSet<TagSet>(); inboundSets.put(ts.getAssociatedKey(), sets); } sets.add(ts); @@ -731,7 +729,7 @@ public class TransientSessionKeyManager extends SessionKeyManager { long now = _context.clock().now(); for (Map.Entry<SessionKey, Set<TagSet>> e : inboundSets.entrySet()) { SessionKey skey = e.getKey(); - Set<TagSet> sets = new TreeSet(new TagSetComparator()); + Set<TagSet> sets = new TreeSet<TagSet>(new TagSetComparator()); sets.addAll(e.getValue()); buf.append("<tr><td><b>Session key</b>: ").append(skey.toBase64()).append("</td>" + "<td><b># Sets:</b> ").append(sets.size()).append("</td></tr>" + @@ -761,7 +759,7 @@ public class TransientSessionKeyManager extends SessionKeyManager { Set<OutboundSession> outbound = getOutboundSessions(); for (Iterator<OutboundSession> iter = outbound.iterator(); iter.hasNext();) { OutboundSession sess = iter.next(); - Set<TagSet> sets = new TreeSet(new TagSetComparator()); + Set<TagSet> sets = new TreeSet<TagSet>(new TagSetComparator()); sets.addAll(sess.getTagSets()); buf.append("<tr><td><b>Target public key:</b> ").append(toString(sess.getTarget())).append("<br>" + "<b>Established:</b> ").append(DataHelper.formatDuration2(now - sess.getEstablishedDate())).append(" ago<br>" + @@ -850,7 +848,7 @@ public class TransientSessionKeyManager extends SessionKeyManager { private static final int MAX_FAILS = 2; public OutboundSession(I2PAppContext ctx, Log log, PublicKey target) { - this(ctx, log, target, null, ctx.clock().now(), ctx.clock().now(), new ArrayList()); + this(ctx, log, target, null, ctx.clock().now(), ctx.clock().now(), new ArrayList<TagSet>()); } OutboundSession(I2PAppContext ctx, Log log, PublicKey target, SessionKey curKey, @@ -862,7 +860,7 @@ public class TransientSessionKeyManager extends SessionKeyManager { _established = established; _lastUsed = lastUsed; _unackedTagSets = tagSets; - _tagSets = new ArrayList(); + _tagSets = new ArrayList<TagSet>(); } /** @@ -873,7 +871,7 @@ public class TransientSessionKeyManager extends SessionKeyManager { List<TagSet> getTagSets() { List<TagSet> rv; synchronized (_tagSets) { - rv = new ArrayList(_unackedTagSets); + rv = new ArrayList<TagSet>(_unackedTagSets); rv.addAll(_tagSets); } return rv; diff --git a/core/java/src/net/i2p/crypto/TrustedUpdate.java b/core/java/src/net/i2p/crypto/TrustedUpdate.java index ad9524c459..e248818360 100644 --- a/core/java/src/net/i2p/crypto/TrustedUpdate.java +++ b/core/java/src/net/i2p/crypto/TrustedUpdate.java @@ -161,7 +161,7 @@ riCe6OlAEiNpcc6mMyIYYWFICbrDFTrDR3wXqwc/Jkcx6L5VVWoagpSzbo3yGhc= /** 172 */ private static final int KEYSIZE_B64_BYTES = 2 + (SigningPublicKey.KEYSIZE_BYTES * 4 / 3); - private static final Map<String, String> DEFAULT_KEYS = new HashMap(4); + private static final Map<String, String> DEFAULT_KEYS = new HashMap<String, String>(4); static { //DEFAULT_KEYS.put(DEFAULT_TRUSTED_KEY, "jrandom@mail.i2p"); DEFAULT_KEYS.put(DEFAULT_TRUSTED_KEY2, "zzz@mail.i2p"); @@ -187,7 +187,7 @@ riCe6OlAEiNpcc6mMyIYYWFICbrDFTrDR3wXqwc/Jkcx6L5VVWoagpSzbo3yGhc= public TrustedUpdate(I2PAppContext context) { _context = context; _log = _context.logManager().getLog(TrustedUpdate.class); - _trustedKeys = new HashMap(4); + _trustedKeys = new HashMap<SigningPublicKey, String>(4); String propertyTrustedKeys = context.getProperty(PROP_TRUSTED_KEYS); diff --git a/core/java/src/net/i2p/crypto/YKGenerator.java b/core/java/src/net/i2p/crypto/YKGenerator.java index 2832f3c926..f78b780eef 100644 --- a/core/java/src/net/i2p/crypto/YKGenerator.java +++ b/core/java/src/net/i2p/crypto/YKGenerator.java @@ -64,7 +64,7 @@ class YKGenerator { MAX_NUM_BUILDERS = ctx.getProperty(PROP_YK_PRECALC_MAX, defaultMax); CALC_DELAY = ctx.getProperty(PROP_YK_PRECALC_DELAY, DEFAULT_YK_PRECALC_DELAY); - _values = new LinkedBlockingQueue(MAX_NUM_BUILDERS); + _values = new LinkedBlockingQueue<BigInteger[]>(MAX_NUM_BUILDERS); //if (_log.shouldLog(Log.DEBUG)) // _log.debug("ElGamal YK Precalc (minimum: " + MIN_NUM_BUILDERS + " max: " + MAX_NUM_BUILDERS + ", delay: " diff --git a/core/java/src/net/i2p/data/DataHelper.java b/core/java/src/net/i2p/data/DataHelper.java index 36b36a068e..83fe675fff 100644 --- a/core/java/src/net/i2p/data/DataHelper.java +++ b/core/java/src/net/i2p/data/DataHelper.java @@ -92,7 +92,7 @@ public class DataHelper { "version", "created", "upgraded", "lists", "a", "s", }; - _propertiesKeyCache = new HashMap(keys.length); + _propertiesKeyCache = new HashMap<String, String>(keys.length); for (int i = 0; i < keys.length; i++) { _propertiesKeyCache.put(keys[i], keys[i]); } @@ -1394,7 +1394,7 @@ public class DataHelper { * @return a new list */ public static List<? extends DataStructure> sortStructures(Collection<? extends DataStructure> dataStructures) { - if (dataStructures == null) return Collections.EMPTY_LIST; + if (dataStructures == null) return Collections.emptyList(); // This used to use Hash.toString(), which is insane, since a change to toString() // would break the whole network. Now use Hash.toBase64(). @@ -1409,7 +1409,7 @@ public class DataHelper { //for (DataStructure struct : tm.values()) { // rv.add(struct); //} - ArrayList<DataStructure> rv = new ArrayList(dataStructures); + ArrayList<DataStructure> rv = new ArrayList<DataStructure>(dataStructures); sortStructureList(rv); return rv; } diff --git a/core/java/src/net/i2p/data/Destination.java b/core/java/src/net/i2p/data/Destination.java index 1eab390bbb..ad21985e39 100644 --- a/core/java/src/net/i2p/data/Destination.java +++ b/core/java/src/net/i2p/data/Destination.java @@ -13,7 +13,6 @@ import java.io.InputStream; import java.io.IOException; import java.util.Map; -import net.i2p.I2PAppContext; import net.i2p.util.LHMCache; import net.i2p.util.SystemVersion; @@ -48,7 +47,7 @@ public class Destination extends KeysAndCert { // I2PAppContext.getGlobalContext().statManager().createRateStat("DestCache", "Hit rate", "Router", new long[] { 10*60*1000 }); } - private static final Map<SigningPublicKey, Destination> _cache = new LHMCache(CACHE_SIZE); + private static final Map<SigningPublicKey, Destination> _cache = new LHMCache<SigningPublicKey, Destination>(CACHE_SIZE); /** * Pull from cache or return new diff --git a/core/java/src/net/i2p/data/Hash.java b/core/java/src/net/i2p/data/Hash.java index add8235a6a..627f02c396 100644 --- a/core/java/src/net/i2p/data/Hash.java +++ b/core/java/src/net/i2p/data/Hash.java @@ -26,7 +26,7 @@ public class Hash extends SimpleDataStructure { public final static Hash FAKE_HASH = new Hash(new byte[HASH_LENGTH]); private static final int CACHE_SIZE = 2048; - private static final SDSCache<Hash> _cache = new SDSCache(Hash.class, HASH_LENGTH, CACHE_SIZE); + private static final SDSCache<Hash> _cache = new SDSCache<Hash>(Hash.class, HASH_LENGTH, CACHE_SIZE); /** * Pull from cache or return new diff --git a/core/java/src/net/i2p/data/LeaseSet.java b/core/java/src/net/i2p/data/LeaseSet.java index e497a1e08e..45c6978aed 100644 --- a/core/java/src/net/i2p/data/LeaseSet.java +++ b/core/java/src/net/i2p/data/LeaseSet.java @@ -93,7 +93,7 @@ public class LeaseSet extends DatabaseEntry { private static final int OLD_MAX_LEASES = 6; public LeaseSet() { - _leases = new ArrayList(OLD_MAX_LEASES); + _leases = new ArrayList<Lease>(OLD_MAX_LEASES); _firstExpiration = Long.MAX_VALUE; } @@ -290,8 +290,8 @@ public class LeaseSet extends DatabaseEntry { _signingKey.writeBytes(out); DataHelper.writeLong(out, 1, _leases.size()); //DataHelper.writeLong(out, 4, _version); - for (Iterator iter = _leases.iterator(); iter.hasNext();) { - Lease lease = (Lease) iter.next(); + for (Iterator<Lease> iter = _leases.iterator(); iter.hasNext();) { + Lease lease = iter.next(); lease.writeBytes(out); } } catch (IOException ioe) { @@ -339,8 +339,8 @@ public class LeaseSet extends DatabaseEntry { _signingKey.writeBytes(out); DataHelper.writeLong(out, 1, _leases.size()); //DataHelper.writeLong(out, 4, _version); - for (Iterator iter = _leases.iterator(); iter.hasNext();) { - Lease lease = (Lease) iter.next(); + for (Iterator<Lease> iter = _leases.iterator(); iter.hasNext();) { + Lease lease = iter.next(); lease.writeBytes(out); } _signature.writeBytes(out); @@ -494,7 +494,7 @@ public class LeaseSet extends DatabaseEntry { byte[] dec = new byte[enclen]; I2PAppContext.getGlobalContext().aes().decrypt(enc, 0, dec, 0, key, iv, enclen); ByteArrayInputStream bais = new ByteArrayInputStream(dec); - _decryptedLeases = new ArrayList(size - 1); + _decryptedLeases = new ArrayList<Lease>(size - 1); for (int i = 0; i < size-1; i++) { Lease l = new Lease(); Hash h = new Hash(); diff --git a/core/java/src/net/i2p/data/PublicKey.java b/core/java/src/net/i2p/data/PublicKey.java index 2a719ffc55..ae5179ae42 100644 --- a/core/java/src/net/i2p/data/PublicKey.java +++ b/core/java/src/net/i2p/data/PublicKey.java @@ -23,7 +23,7 @@ public class PublicKey extends SimpleDataStructure { public final static int KEYSIZE_BYTES = 256; private static final int CACHE_SIZE = 1024; - private static final SDSCache<PublicKey> _cache = new SDSCache(PublicKey.class, KEYSIZE_BYTES, CACHE_SIZE); + private static final SDSCache<PublicKey> _cache = new SDSCache<PublicKey>(PublicKey.class, KEYSIZE_BYTES, CACHE_SIZE); /** * Pull from cache or return new. diff --git a/core/java/src/net/i2p/data/RouterInfo.java b/core/java/src/net/i2p/data/RouterInfo.java index 4199d0ee93..72b54b8a96 100644 --- a/core/java/src/net/i2p/data/RouterInfo.java +++ b/core/java/src/net/i2p/data/RouterInfo.java @@ -202,7 +202,7 @@ public class RouterInfo extends DatabaseEntry { */ public Set<Hash> getPeers() { if (_peers == null) - return Collections.EMPTY_SET; + return Collections.emptySet(); return _peers; } @@ -221,7 +221,7 @@ public class RouterInfo extends DatabaseEntry { return; } if (_peers == null) - _peers = new HashSet(2); + _peers = new HashSet<Hash>(2); synchronized (_peers) { _peers.clear(); _peers.addAll(peers); @@ -546,7 +546,7 @@ public class RouterInfo extends DatabaseEntry { if (numPeers == 0) { _peers = null; } else { - _peers = new HashSet(numPeers); + _peers = new HashSet<Hash>(numPeers); for (int i = 0; i < numPeers; i++) { Hash peerIdentityHash = new Hash(); peerIdentityHash.readBytes(din); diff --git a/core/java/src/net/i2p/data/SDSCache.java b/core/java/src/net/i2p/data/SDSCache.java index 464ca7f971..4bd0f21229 100644 --- a/core/java/src/net/i2p/data/SDSCache.java +++ b/core/java/src/net/i2p/data/SDSCache.java @@ -70,7 +70,7 @@ public class SDSCache<V extends SimpleDataStructure> { */ public SDSCache(Class<V> rvClass, int len, int max) { int size = (int) (max * FACTOR); - _cache = new LHMCache(size); + _cache = new LHMCache<Integer, WeakReference<V>>(size); _datalen = len; try { _rvCon = rvClass.getConstructor(conArg); @@ -135,7 +135,7 @@ public class SDSCache<V extends SimpleDataStructure> { } catch (InvocationTargetException e) { throw new RuntimeException("SDSCache error", e); } - _cache.put(key, new WeakReference(rv)); + _cache.put(key, new WeakReference<V>(rv)); found = 0; } } diff --git a/core/java/src/net/i2p/data/SigningPublicKey.java b/core/java/src/net/i2p/data/SigningPublicKey.java index d1c1a4687f..e01d6ec392 100644 --- a/core/java/src/net/i2p/data/SigningPublicKey.java +++ b/core/java/src/net/i2p/data/SigningPublicKey.java @@ -27,7 +27,7 @@ public class SigningPublicKey extends SimpleDataStructure { public final static int KEYSIZE_BYTES = DEF_TYPE.getPubkeyLen(); private static final int CACHE_SIZE = 1024; - private static final SDSCache<SigningPublicKey> _cache = new SDSCache(SigningPublicKey.class, KEYSIZE_BYTES, CACHE_SIZE); + private static final SDSCache<SigningPublicKey> _cache = new SDSCache<SigningPublicKey>(SigningPublicKey.class, KEYSIZE_BYTES, CACHE_SIZE); private final SigType _type; diff --git a/core/java/src/net/i2p/data/i2cp/CreateLeaseSetMessage.java b/core/java/src/net/i2p/data/i2cp/CreateLeaseSetMessage.java index cfed39f180..b57af1f8da 100644 --- a/core/java/src/net/i2p/data/i2cp/CreateLeaseSetMessage.java +++ b/core/java/src/net/i2p/data/i2cp/CreateLeaseSetMessage.java @@ -14,7 +14,6 @@ import java.io.IOException; import java.io.InputStream; import net.i2p.data.DataFormatException; -import net.i2p.data.DataHelper; import net.i2p.data.LeaseSet; import net.i2p.data.PrivateKey; import net.i2p.data.SigningPrivateKey; diff --git a/core/java/src/net/i2p/data/i2cp/CreateSessionMessage.java b/core/java/src/net/i2p/data/i2cp/CreateSessionMessage.java index e2efacee86..0df5f99fed 100644 --- a/core/java/src/net/i2p/data/i2cp/CreateSessionMessage.java +++ b/core/java/src/net/i2p/data/i2cp/CreateSessionMessage.java @@ -14,7 +14,6 @@ import java.io.IOException; import java.io.InputStream; import net.i2p.data.DataFormatException; -import net.i2p.data.DataHelper; /** * Defines the message a client sends to a router when establishing a new diff --git a/core/java/src/net/i2p/data/i2cp/DestLookupMessage.java b/core/java/src/net/i2p/data/i2cp/DestLookupMessage.java index f6613bc615..2493898b78 100644 --- a/core/java/src/net/i2p/data/i2cp/DestLookupMessage.java +++ b/core/java/src/net/i2p/data/i2cp/DestLookupMessage.java @@ -10,7 +10,6 @@ import java.io.IOException; import java.io.InputStream; import net.i2p.data.DataFormatException; -import net.i2p.data.DataHelper; import net.i2p.data.Hash; /** diff --git a/core/java/src/net/i2p/data/i2cp/DestReplyMessage.java b/core/java/src/net/i2p/data/i2cp/DestReplyMessage.java index ac5d43af61..d13cf658c9 100644 --- a/core/java/src/net/i2p/data/i2cp/DestReplyMessage.java +++ b/core/java/src/net/i2p/data/i2cp/DestReplyMessage.java @@ -11,7 +11,6 @@ import java.io.IOException; import java.io.InputStream; import net.i2p.data.DataFormatException; -import net.i2p.data.DataHelper; import net.i2p.data.Destination; import net.i2p.data.Hash; diff --git a/core/java/src/net/i2p/data/i2cp/DestroySessionMessage.java b/core/java/src/net/i2p/data/i2cp/DestroySessionMessage.java index 4a12eb2544..b67f5fa6f0 100644 --- a/core/java/src/net/i2p/data/i2cp/DestroySessionMessage.java +++ b/core/java/src/net/i2p/data/i2cp/DestroySessionMessage.java @@ -14,7 +14,6 @@ import java.io.IOException; import java.io.InputStream; import net.i2p.data.DataFormatException; -import net.i2p.data.DataHelper; /** * Defines the message a client sends to a router when destroying diff --git a/core/java/src/net/i2p/data/i2cp/ReconfigureSessionMessage.java b/core/java/src/net/i2p/data/i2cp/ReconfigureSessionMessage.java index dd6558f39d..01130670ab 100644 --- a/core/java/src/net/i2p/data/i2cp/ReconfigureSessionMessage.java +++ b/core/java/src/net/i2p/data/i2cp/ReconfigureSessionMessage.java @@ -14,7 +14,6 @@ import java.io.IOException; import java.io.InputStream; import net.i2p.data.DataFormatException; -import net.i2p.data.DataHelper; /** * Defines the message a client sends to a router when diff --git a/core/java/src/net/i2p/data/i2cp/ReportAbuseMessage.java b/core/java/src/net/i2p/data/i2cp/ReportAbuseMessage.java index 60870621b7..76311ae6e5 100644 --- a/core/java/src/net/i2p/data/i2cp/ReportAbuseMessage.java +++ b/core/java/src/net/i2p/data/i2cp/ReportAbuseMessage.java @@ -14,7 +14,6 @@ import java.io.IOException; import java.io.InputStream; import net.i2p.data.DataFormatException; -import net.i2p.data.DataHelper; /** * Defines the message a client sends to a router when asking the diff --git a/core/java/src/net/i2p/data/i2cp/RequestLeaseSetMessage.java b/core/java/src/net/i2p/data/i2cp/RequestLeaseSetMessage.java index 2c177cc858..d9744662a5 100644 --- a/core/java/src/net/i2p/data/i2cp/RequestLeaseSetMessage.java +++ b/core/java/src/net/i2p/data/i2cp/RequestLeaseSetMessage.java @@ -34,7 +34,7 @@ public class RequestLeaseSetMessage extends I2CPMessageImpl { private Date _end; public RequestLeaseSetMessage() { - _endpoints = new ArrayList(); + _endpoints = new ArrayList<TunnelEndpoint>(); } public SessionId getSessionId() { diff --git a/core/java/src/net/i2p/data/i2cp/RequestVariableLeaseSetMessage.java b/core/java/src/net/i2p/data/i2cp/RequestVariableLeaseSetMessage.java index b29603755e..160e193dcb 100644 --- a/core/java/src/net/i2p/data/i2cp/RequestVariableLeaseSetMessage.java +++ b/core/java/src/net/i2p/data/i2cp/RequestVariableLeaseSetMessage.java @@ -37,7 +37,7 @@ public class RequestVariableLeaseSetMessage extends I2CPMessageImpl { private static final String MIN_VERSION = "0.9.7"; public RequestVariableLeaseSetMessage() { - _endpoints = new ArrayList(); + _endpoints = new ArrayList<Lease>(); } /** diff --git a/core/java/src/net/i2p/stat/BufferedStatLog.java b/core/java/src/net/i2p/stat/BufferedStatLog.java index ae8a5b67aa..20b6a2a498 100644 --- a/core/java/src/net/i2p/stat/BufferedStatLog.java +++ b/core/java/src/net/i2p/stat/BufferedStatLog.java @@ -26,7 +26,7 @@ public class BufferedStatLog implements StatLog { private int _lastWrite; /** flush stat events to disk after this many events (or 30s)*/ private int _flushFrequency; - private final List _statFilters; + private final List<String> _statFilters; private String _lastFilters; private BufferedWriter _out; private String _outFile; @@ -45,7 +45,7 @@ public class BufferedStatLog implements StatLog { _events[i] = new StatEvent(); _eventNext = 0; _lastWrite = _events.length-1; - _statFilters = new ArrayList(10); + _statFilters = new ArrayList<String>(10); _flushFrequency = 500; updateFilters(); I2PThread writer = new I2PThread(new StatLogWriter(), "StatLogWriter"); diff --git a/core/java/src/net/i2p/update/Checker.java b/core/java/src/net/i2p/update/Checker.java index f4ff70f332..aa5675c98d 100644 --- a/core/java/src/net/i2p/update/Checker.java +++ b/core/java/src/net/i2p/update/Checker.java @@ -1,8 +1,5 @@ package net.i2p.update; -import java.net.URI; -import java.util.List; - /** * Controls one or more types of updates. * This must be registered with the UpdateManager. diff --git a/core/java/src/net/i2p/util/Addresses.java b/core/java/src/net/i2p/util/Addresses.java index 0397444170..d522167f44 100644 --- a/core/java/src/net/i2p/util/Addresses.java +++ b/core/java/src/net/i2p/util/Addresses.java @@ -83,7 +83,7 @@ public abstract class Addresses { boolean includeIPv6) { boolean haveIPv4 = false; boolean haveIPv6 = false; - SortedSet<String> rv = new TreeSet(); + SortedSet<String> rv = new TreeSet<String>(); try { InetAddress localhost = InetAddress.getLocalHost(); InetAddress[] allMyIps = InetAddress.getAllByName(localhost.getCanonicalHostName()); @@ -236,7 +236,7 @@ public abstract class Addresses { } else { size = 32; } - _IPAddress = new LHMCache(size); + _IPAddress = new LHMCache<String, byte[]>(size); } /** diff --git a/core/java/src/net/i2p/util/ByteCache.java b/core/java/src/net/i2p/util/ByteCache.java index 459b2fce4d..303ebb20eb 100644 --- a/core/java/src/net/i2p/util/ByteCache.java +++ b/core/java/src/net/i2p/util/ByteCache.java @@ -52,7 +52,7 @@ import net.i2p.data.ByteArray; public final class ByteCache { //private static final Log _log = I2PAppContext.getGlobalContext().logManager().getLog(ByteCache.class); - private static final Map<Integer, ByteCache> _caches = new ConcurrentHashMap(16); + private static final Map<Integer, ByteCache> _caches = new ConcurrentHashMap<Integer, ByteCache>(16); /** * max size in bytes of each cache @@ -119,7 +119,7 @@ public final class ByteCache { private ByteCache(int maxCachedEntries, int entrySize) { if (_cache) - _available = new LinkedBlockingQueue(maxCachedEntries); + _available = new LinkedBlockingQueue<ByteArray>(maxCachedEntries); _maxCached = maxCachedEntries; _entrySize = entrySize; _lastOverflow = -1; @@ -131,7 +131,7 @@ public final class ByteCache { if (_maxCached >= maxCachedEntries) return; _maxCached = maxCachedEntries; // make a bigger one, move the cached items over - Queue<ByteArray> newLBQ = new LinkedBlockingQueue(maxCachedEntries); + Queue<ByteArray> newLBQ = new LinkedBlockingQueue<ByteArray>(maxCachedEntries); ByteArray ba; while ((ba = _available.poll()) != null) newLBQ.offer(ba); diff --git a/core/java/src/net/i2p/util/Clock.java b/core/java/src/net/i2p/util/Clock.java index c8587f48eb..3efbbb7d69 100644 --- a/core/java/src/net/i2p/util/Clock.java +++ b/core/java/src/net/i2p/util/Clock.java @@ -27,7 +27,7 @@ public class Clock implements Timestamper.UpdateListener { public Clock(I2PAppContext context) { _context = context; - _listeners = new CopyOnWriteArraySet(); + _listeners = new CopyOnWriteArraySet<ClockUpdateListener>(); _startedOn = System.currentTimeMillis(); } diff --git a/core/java/src/net/i2p/util/ConcurrentHashSet.java b/core/java/src/net/i2p/util/ConcurrentHashSet.java index 6c6d8bfb67..bea627119d 100644 --- a/core/java/src/net/i2p/util/ConcurrentHashSet.java +++ b/core/java/src/net/i2p/util/ConcurrentHashSet.java @@ -17,10 +17,10 @@ public class ConcurrentHashSet<E> extends AbstractSet<E> implements Set<E> { private final Map<E, Object> _map; public ConcurrentHashSet() { - _map = new ConcurrentHashMap(); + _map = new ConcurrentHashMap<E, Object>(); } public ConcurrentHashSet(int capacity) { - _map = new ConcurrentHashMap(capacity); + _map = new ConcurrentHashMap<E, Object>(capacity); } @Override diff --git a/core/java/src/net/i2p/util/EepGet.java b/core/java/src/net/i2p/util/EepGet.java index 2fadef1db7..45dc5a2c6f 100644 --- a/core/java/src/net/i2p/util/EepGet.java +++ b/core/java/src/net/i2p/util/EepGet.java @@ -143,7 +143,7 @@ public class EepGet { _postData = postData; _bytesRemaining = -1; _fetchHeaderTimeout = CONNECT_TIMEOUT; - _listeners = new ArrayList(1); + _listeners = new ArrayList<StatusListener>(1); _etag = etag; _lastModified = lastModified; _etagOrig = etag; @@ -190,7 +190,7 @@ public class EepGet { lineLen = Integer.parseInt(args[++i]); } else if (args[i].equals("-h")) { if (extra == null) - extra = new ArrayList(2); + extra = new ArrayList<String>(2); extra.add(args[++i]); extra.add(args[++i]); } else if (args[i].equals("-u")) { @@ -1241,7 +1241,7 @@ public class EepGet { */ public void addHeader(String name, String value) { if (_extraHeaders == null) - _extraHeaders = new ArrayList(); + _extraHeaders = new ArrayList<String>(); _extraHeaders.add(name + ": " + value); } diff --git a/core/java/src/net/i2p/util/EventDispatcher.java b/core/java/src/net/i2p/util/EventDispatcher.java index 8f74beae7b..04e3731b6c 100644 --- a/core/java/src/net/i2p/util/EventDispatcher.java +++ b/core/java/src/net/i2p/util/EventDispatcher.java @@ -82,7 +82,7 @@ public interface EventDispatcher { * * @return A set of event names */ - public Set getEvents(); + public Set<String> getEvents(); /** * Ignore further event notifications diff --git a/core/java/src/net/i2p/util/EventDispatcherImpl.java b/core/java/src/net/i2p/util/EventDispatcherImpl.java index 700cf8e0f5..82b613e755 100644 --- a/core/java/src/net/i2p/util/EventDispatcherImpl.java +++ b/core/java/src/net/i2p/util/EventDispatcherImpl.java @@ -35,8 +35,8 @@ import java.util.concurrent.CopyOnWriteArrayList; public class EventDispatcherImpl implements EventDispatcher { private boolean _ignore = false; - private final Map<String, Object> _events = new ConcurrentHashMap(4); - private final List<EventDispatcher> _attached = new CopyOnWriteArrayList(); + private final Map<String, Object> _events = new ConcurrentHashMap<String, Object>(4); + private final List<EventDispatcher> _attached = new CopyOnWriteArrayList<EventDispatcher>(); public EventDispatcher getEventDispatcher() { return this; @@ -72,8 +72,8 @@ public class EventDispatcherImpl implements EventDispatcher { } public Set<String> getEvents() { - if (_ignore) return Collections.EMPTY_SET; - return new HashSet(_events.keySet()); + if (_ignore) return Collections.emptySet(); + return new HashSet<String>(_events.keySet()); } public void ignoreEvents() { diff --git a/core/java/src/net/i2p/util/FileUtil.java b/core/java/src/net/i2p/util/FileUtil.java index 2a71805470..382be54416 100644 --- a/core/java/src/net/i2p/util/FileUtil.java +++ b/core/java/src/net/i2p/util/FileUtil.java @@ -106,7 +106,7 @@ public class FileUtil { try { byte buf[] = new byte[16*1024]; zip = new ZipFile(zipfile); - Enumeration entries = zip.entries(); + Enumeration<? extends ZipEntry> entries = zip.entries(); while (entries.hasMoreElements()) { ZipEntry entry = (ZipEntry)entries.nextElement(); if (entry.getName().indexOf("..") != -1) { @@ -215,7 +215,7 @@ public class FileUtil { try { byte buf[] = new byte[16*1024]; zip = new ZipFile(zipfile); - Enumeration entries = zip.entries(); + Enumeration<? extends ZipEntry> entries = zip.entries(); boolean p200TestRequired = true; while (entries.hasMoreElements()) { ZipEntry entry = (ZipEntry)entries.nextElement(); @@ -358,7 +358,7 @@ public class FileUtil { try { fis = new FileInputStream(f); BufferedReader in = new BufferedReader(new InputStreamReader(fis, "UTF-8")); - List lines = new ArrayList(maxNumLines > 0 ? maxNumLines : 64); + List<String> lines = new ArrayList<String>(maxNumLines > 0 ? maxNumLines : 64); String line = null; while ( (line = in.readLine()) != null) { lines.add(line); diff --git a/core/java/src/net/i2p/util/I2PAppThread.java b/core/java/src/net/i2p/util/I2PAppThread.java index 8111083551..bf117ab83d 100644 --- a/core/java/src/net/i2p/util/I2PAppThread.java +++ b/core/java/src/net/i2p/util/I2PAppThread.java @@ -22,7 +22,7 @@ import java.util.concurrent.CopyOnWriteArraySet; */ public class I2PAppThread extends I2PThread { - private final Set _threadListeners = new CopyOnWriteArraySet(); + private final Set<OOMEventListener> _threadListeners = new CopyOnWriteArraySet<OOMEventListener>(); public I2PAppThread() { super(); @@ -45,8 +45,8 @@ public class I2PAppThread extends I2PThread { @Override protected void fireOOM(OutOfMemoryError oom) { - for (Iterator iter = _threadListeners.iterator(); iter.hasNext(); ) { - OOMEventListener listener = (OOMEventListener)iter.next(); + for (Iterator<OOMEventListener> iter = _threadListeners.iterator(); iter.hasNext(); ) { + OOMEventListener listener = iter.next(); listener.outOfMemory(oom); } } diff --git a/core/java/src/net/i2p/util/I2PSSLSocketFactory.java b/core/java/src/net/i2p/util/I2PSSLSocketFactory.java index f7f5b26064..fffbb4f809 100644 --- a/core/java/src/net/i2p/util/I2PSSLSocketFactory.java +++ b/core/java/src/net/i2p/util/I2PSSLSocketFactory.java @@ -1,9 +1,7 @@ package net.i2p.util; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; -import java.io.InputStream; import java.net.InetAddress; import java.net.Socket; import java.security.KeyStore; diff --git a/core/java/src/net/i2p/util/I2PThread.java b/core/java/src/net/i2p/util/I2PThread.java index ac52b96d60..47ce953c67 100644 --- a/core/java/src/net/i2p/util/I2PThread.java +++ b/core/java/src/net/i2p/util/I2PThread.java @@ -26,7 +26,7 @@ public class I2PThread extends Thread { * Logging removed, too much trouble with extra contexts */ //private volatile Log _log; - private static final Set _listeners = new CopyOnWriteArraySet(); + private static final Set<OOMEventListener> _listeners = new CopyOnWriteArraySet<OOMEventListener>(); //private String _name; //private Exception _createdBy; @@ -112,8 +112,8 @@ public class I2PThread extends Thread { ****/ protected void fireOOM(OutOfMemoryError oom) { - for (Iterator iter = _listeners.iterator(); iter.hasNext(); ) { - OOMEventListener listener = (OOMEventListener)iter.next(); + for (Iterator<OOMEventListener> iter = _listeners.iterator(); iter.hasNext(); ) { + OOMEventListener listener = iter.next(); listener.outOfMemory(oom); } } diff --git a/core/java/src/net/i2p/util/InternalServerSocket.java b/core/java/src/net/i2p/util/InternalServerSocket.java index a5b1230631..792a6b4d42 100644 --- a/core/java/src/net/i2p/util/InternalServerSocket.java +++ b/core/java/src/net/i2p/util/InternalServerSocket.java @@ -24,7 +24,7 @@ import java.util.concurrent.LinkedBlockingQueue; * @since 0.7.9 */ public class InternalServerSocket extends ServerSocket { - private static final ConcurrentHashMap<Integer, InternalServerSocket> _sockets = new ConcurrentHashMap(4); + private static final ConcurrentHashMap<Integer, InternalServerSocket> _sockets = new ConcurrentHashMap<Integer, InternalServerSocket>(4); private final BlockingQueue<InternalSocket> _acceptQueue; private final Integer _port; private volatile boolean _running; @@ -41,7 +41,7 @@ public class InternalServerSocket extends ServerSocket { if (previous != null) throw new IOException("Internal port in use: " + port); _running = true; - _acceptQueue = new LinkedBlockingQueue(); + _acceptQueue = new LinkedBlockingQueue<InternalSocket>(); //if (_log.shouldLog(Log.DEBUG)) // _log.debug("Registered " + _port); } diff --git a/core/java/src/net/i2p/util/LogConsoleBuffer.java b/core/java/src/net/i2p/util/LogConsoleBuffer.java index 6149c24da9..18d7cfdf81 100644 --- a/core/java/src/net/i2p/util/LogConsoleBuffer.java +++ b/core/java/src/net/i2p/util/LogConsoleBuffer.java @@ -36,8 +36,8 @@ public class LogConsoleBuffer { lim = Math.max(limit, 4); // Add some extra room to minimize the chance of losing a message, // since we are doing offer() below. - _buffer = new LinkedBlockingQueue(lim + 4); - _critBuffer = new LinkedBlockingQueue(lim + 4); + _buffer = new LinkedBlockingQueue<String>(lim + 4); + _critBuffer = new LinkedBlockingQueue<String>(lim + 4); } void add(String msg) { @@ -64,7 +64,7 @@ public class LogConsoleBuffer { * @return oldest first */ public List<String> getMostRecentMessages() { - return new ArrayList(_buffer); + return new ArrayList<String>(_buffer); } /** @@ -75,7 +75,7 @@ public class LogConsoleBuffer { * @return oldest first */ public List<String> getMostRecentCriticalMessages() { - return new ArrayList(_critBuffer); + return new ArrayList<String>(_critBuffer); } /** diff --git a/core/java/src/net/i2p/util/LogManager.java b/core/java/src/net/i2p/util/LogManager.java index e919f236ee..bb348229de 100644 --- a/core/java/src/net/i2p/util/LogManager.java +++ b/core/java/src/net/i2p/util/LogManager.java @@ -131,14 +131,14 @@ public class LogManager { public LogManager(I2PAppContext context) { _displayOnScreen = true; _alreadyNoticedMissingConfig = false; - _limits = new ConcurrentHashSet(); - _logs = new ConcurrentHashMap(128); + _limits = new ConcurrentHashSet<LogLimit>(); + _logs = new ConcurrentHashMap<Object, Log>(128); _defaultLimit = Log.ERROR; _context = context; _log = getLog(LogManager.class); String location = context.getProperty(CONFIG_LOCATION_PROP, CONFIG_LOCATION_DEFAULT); setConfig(location); - _records = new LinkedBlockingQueue(_logBufferSize); + _records = new LinkedBlockingQueue<LogRecord>(_logBufferSize); _consoleBuffer = new LogConsoleBuffer(_consoleBufferSize); // If we aren't in the router context, delay creating the LogWriter until required, // so it doesn't create a log directory and log files unless there is output. @@ -582,7 +582,7 @@ public class LogManager { for (LogLimit limit : _limits) { if (limit.matches(log)) { if (limits == null) - limits = new ArrayList(4); + limits = new ArrayList<LogLimit>(4); limits.add(limit); } } diff --git a/core/java/src/net/i2p/util/NativeBigInteger.java b/core/java/src/net/i2p/util/NativeBigInteger.java index 99850c0668..954a8f6191 100644 --- a/core/java/src/net/i2p/util/NativeBigInteger.java +++ b/core/java/src/net/i2p/util/NativeBigInteger.java @@ -35,7 +35,6 @@ import freenet.support.CPUInformation.UnknownCPUException; import net.i2p.I2PAppContext; import net.i2p.crypto.CryptoConstants; -import net.i2p.data.DataHelper; /** * <p>BigInteger that takes advantage of the jbigi library for the modPow operation, @@ -627,8 +626,8 @@ public class NativeBigInteger extends BigInteger { */ private static List<String> getResourceList() { if (_isAndroid) - return Collections.EMPTY_LIST; - List<String> rv = new ArrayList(8); + return Collections.emptyList(); + List<String> rv = new ArrayList<String>(8); String primary = getMiddleName2(true); if (primary != null) { if (_is64) { @@ -708,7 +707,7 @@ public class NativeBigInteger extends BigInteger { * @since 0.9.1 */ private static Map<String, String> getCPUInfo() { - Map<String, String> rv = new HashMap(32); + Map<String, String> rv = new HashMap<String, String>(32); BufferedReader in = null; try { in = new BufferedReader(new InputStreamReader(new FileInputStream("/proc/cpuinfo"), "ISO-8859-1"), 4096); diff --git a/core/java/src/net/i2p/util/PortMapper.java b/core/java/src/net/i2p/util/PortMapper.java index 0efd589897..ff626961b1 100644 --- a/core/java/src/net/i2p/util/PortMapper.java +++ b/core/java/src/net/i2p/util/PortMapper.java @@ -32,7 +32,7 @@ public class PortMapper { * @param context unused for now */ public PortMapper(I2PAppContext context) { - _dir = new ConcurrentHashMap(8); + _dir = new ConcurrentHashMap<String, Integer>(8); } /** diff --git a/core/java/src/net/i2p/util/ReusableGZIPInputStream.java b/core/java/src/net/i2p/util/ReusableGZIPInputStream.java index 5ef5b7801f..4a0b392bac 100644 --- a/core/java/src/net/i2p/util/ReusableGZIPInputStream.java +++ b/core/java/src/net/i2p/util/ReusableGZIPInputStream.java @@ -14,7 +14,7 @@ public class ReusableGZIPInputStream extends ResettableGZIPInputStream { private static final LinkedBlockingQueue<ReusableGZIPInputStream> _available; static { if (ENABLE_CACHING) - _available = new LinkedBlockingQueue(8); + _available = new LinkedBlockingQueue<ReusableGZIPInputStream>(8); else _available = null; } diff --git a/core/java/src/net/i2p/util/ReusableGZIPOutputStream.java b/core/java/src/net/i2p/util/ReusableGZIPOutputStream.java index 3cbf1dd335..3c239ffc7d 100644 --- a/core/java/src/net/i2p/util/ReusableGZIPOutputStream.java +++ b/core/java/src/net/i2p/util/ReusableGZIPOutputStream.java @@ -25,7 +25,7 @@ public class ReusableGZIPOutputStream extends ResettableGZIPOutputStream { private static final LinkedBlockingQueue<ReusableGZIPOutputStream> _available; static { if (ENABLE_CACHING) - _available = new LinkedBlockingQueue(16); + _available = new LinkedBlockingQueue<ReusableGZIPOutputStream>(16); else _available = null; } diff --git a/core/java/src/net/i2p/util/SSLEepGet.java b/core/java/src/net/i2p/util/SSLEepGet.java index 311219fe6c..81b728b572 100644 --- a/core/java/src/net/i2p/util/SSLEepGet.java +++ b/core/java/src/net/i2p/util/SSLEepGet.java @@ -39,10 +39,8 @@ package net.i2p.util; import java.io.BufferedInputStream; import java.io.File; -import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; import java.io.PipedInputStream; import java.io.PipedOutputStream; @@ -50,8 +48,6 @@ import java.net.MalformedURLException; import java.net.URL; import java.security.KeyStore; import java.security.GeneralSecurityException; -import java.security.cert.Certificate; -import java.security.cert.CertificateEncodingException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.Locale; diff --git a/core/java/src/net/i2p/util/SimpleByteCache.java b/core/java/src/net/i2p/util/SimpleByteCache.java index 1623fcb148..4b21334b0f 100644 --- a/core/java/src/net/i2p/util/SimpleByteCache.java +++ b/core/java/src/net/i2p/util/SimpleByteCache.java @@ -1,6 +1,5 @@ package net.i2p.util; -import java.util.Map; import java.util.Queue; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.ConcurrentHashMap; @@ -16,7 +15,7 @@ import java.util.concurrent.LinkedBlockingQueue; */ public final class SimpleByteCache { - private static final ConcurrentHashMap<Integer, SimpleByteCache> _caches = new ConcurrentHashMap(8); + private static final ConcurrentHashMap<Integer, SimpleByteCache> _caches = new ConcurrentHashMap<Integer, SimpleByteCache>(8); private static final int DEFAULT_SIZE = 64; @@ -89,8 +88,8 @@ public final class SimpleByteCache { */ private Queue<byte[]> createQueue() { if (_entrySize <= MAX_FOR_ABQ) - return new ArrayBlockingQueue(_maxCached); - return new LinkedBlockingQueue(_maxCached); + return new ArrayBlockingQueue<byte[]>(_maxCached); + return new LinkedBlockingQueue<byte[]>(_maxCached); } /** diff --git a/core/java/src/net/i2p/util/SimpleTimer.java b/core/java/src/net/i2p/util/SimpleTimer.java index 48de1ebbf2..d4b537e584 100644 --- a/core/java/src/net/i2p/util/SimpleTimer.java +++ b/core/java/src/net/i2p/util/SimpleTimer.java @@ -54,9 +54,9 @@ public class SimpleTimer { private SimpleTimer(I2PAppContext context, String name) { runn = new SimpleStore(true); _log = context.logManager().getLog(SimpleTimer.class); - _events = new TreeMap(); - _eventTimes = new HashMap(256); - _readyEvents = new ArrayList(4); + _events = new TreeMap<Long, TimedEvent>(); + _eventTimes = new HashMap<TimedEvent, Long>(256); + _readyEvents = new ArrayList<TimedEvent>(4); I2PThread runner = new I2PThread(new SimpleTimerRunner()); runner.setName(name); runner.setDaemon(true); @@ -155,8 +155,8 @@ public class SimpleTimer { if ( (_events.size() != _eventTimes.size()) ) { _log.error("Skewed events: " + _events.size() + " for " + _eventTimes.size()); - for (Iterator iter = _eventTimes.keySet().iterator(); iter.hasNext(); ) { - TimedEvent evt = (TimedEvent)iter.next(); + for (Iterator<TimedEvent> iter = _eventTimes.keySet().iterator(); iter.hasNext(); ) { + TimedEvent evt = iter.next(); Long when = _eventTimes.get(evt); TimedEvent cur = _events.get(when); if (cur != evt) { @@ -209,7 +209,7 @@ public class SimpleTimer { // private TimedEvent _recentEvents[] = new TimedEvent[5]; private class SimpleTimerRunner implements Runnable { public void run() { - List<TimedEvent> eventsToFire = new ArrayList(1); + List<TimedEvent> eventsToFire = new ArrayList<TimedEvent>(1); while(runn.getAnswer()) { try { synchronized (_events) { diff --git a/core/java/src/net/i2p/util/Translate.java b/core/java/src/net/i2p/util/Translate.java index 3139787db0..86e9c4e6e7 100644 --- a/core/java/src/net/i2p/util/Translate.java +++ b/core/java/src/net/i2p/util/Translate.java @@ -26,8 +26,8 @@ import net.i2p.util.ConcurrentHashSet; public abstract class Translate { public static final String PROP_LANG = "routerconsole.lang"; private static final String _localeLang = Locale.getDefault().getLanguage(); - private static final Map<String, ResourceBundle> _bundles = new ConcurrentHashMap(16); - private static final Set<String> _missing = new ConcurrentHashSet(16); + private static final Map<String, ResourceBundle> _bundles = new ConcurrentHashMap<String, ResourceBundle>(16); + private static final Set<String> _missing = new ConcurrentHashSet<String>(16); /** use to look for untagged strings */ private static final String TEST_LANG = "xx"; private static final String TEST_STRING = "XXXX"; diff --git a/core/java/src/net/i2p/util/TranslateReader.java b/core/java/src/net/i2p/util/TranslateReader.java index f9b89429f5..dd1e910b5a 100644 --- a/core/java/src/net/i2p/util/TranslateReader.java +++ b/core/java/src/net/i2p/util/TranslateReader.java @@ -71,7 +71,7 @@ public class TranslateReader extends FilterReader { super(new BufferedReader(new InputStreamReader(in, "UTF-8"))); _ctx = ctx; _bundle = bundle; - _args = new ArrayList(4); + _args = new ArrayList<String>(4); _inBuf = new StringBuilder(64); _outBuf = new StringBuilder(64); _argBuf = new StringBuilder(64); @@ -415,7 +415,7 @@ public class TranslateReader extends FilterReader { File[] listing = dir.listFiles(); if (listing == null) throw new IOException(); - filelist = new ArrayList(listing.length); + filelist = new ArrayList<String>(listing.length); for (int i = 0; i < listing.length; i++) { File f = listing[i]; if (!f.isDirectory()) diff --git a/core/java/src/net/metanotion/io/block/BlockFile.java b/core/java/src/net/metanotion/io/block/BlockFile.java index 6a386852db..a73c922521 100644 --- a/core/java/src/net/metanotion/io/block/BlockFile.java +++ b/core/java/src/net/metanotion/io/block/BlockFile.java @@ -94,7 +94,7 @@ public class BlockFile { private boolean _isClosed; /** cached list of free pages, only valid if freListStart > 0 */ private FreeListBlock flb; - private final HashMap openIndices = new HashMap(); + private final HashMap<String, BSkipList> openIndices = new HashMap<String, BSkipList>(); private void mount() throws IOException { file.seek(BlockFile.OFFSET_MOUNTED); @@ -481,12 +481,12 @@ public class BlockFile { _isClosed = true; metaIndex.close(); - Set oi = openIndices.keySet(); - Iterator i = oi.iterator(); + Set<String> oi = openIndices.keySet(); + Iterator<String> i = oi.iterator(); Object k; while(i.hasNext()) { k = i.next(); - BSkipList bsl = (BSkipList) openIndices.get(k); + BSkipList bsl = openIndices.get(k); bsl.close(); } diff --git a/core/java/src/net/metanotion/io/block/index/BSkipLevels.java b/core/java/src/net/metanotion/io/block/index/BSkipLevels.java index d0e056dd9e..e983de3cd8 100644 --- a/core/java/src/net/metanotion/io/block/index/BSkipLevels.java +++ b/core/java/src/net/metanotion/io/block/index/BSkipLevels.java @@ -226,7 +226,7 @@ public class BSkipLevels extends SkipLevels { * @since 0.8.8 */ private boolean blvlfix() { - TreeSet<SkipLevels> lvls = new TreeSet(new LevelComparator()); + TreeSet<SkipLevels> lvls = new TreeSet<SkipLevels>(new LevelComparator()); if (bf.log.shouldLog(Log.DEBUG)) bf.log.debug("Starting level search"); getAllLevels(this, lvls); @@ -284,7 +284,7 @@ public class BSkipLevels extends SkipLevels { * @param lvlSet out parameter, the result * @since 0.8.8 */ - private void getAllLevels(SkipLevels l, Set lvlSet) { + private void getAllLevels(SkipLevels l, Set<SkipLevels> lvlSet) { if (bf.log.shouldLog(Log.DEBUG)) bf.log.debug("GAL " + l.print()); // Do level 0 without recursion, on the assumption everything is findable diff --git a/core/java/src/net/metanotion/io/block/index/BSkipList.java b/core/java/src/net/metanotion/io/block/index/BSkipList.java index eccd63c405..9ecb11d973 100644 --- a/core/java/src/net/metanotion/io/block/index/BSkipList.java +++ b/core/java/src/net/metanotion/io/block/index/BSkipList.java @@ -58,8 +58,8 @@ public class BSkipList extends SkipList { public final BlockFile bf; private boolean isClosed; - final HashMap<Integer, BSkipSpan> spanHash = new HashMap(); - final HashMap<Integer, SkipLevels> levelHash = new HashMap(); + final HashMap<Integer, BSkipSpan> spanHash = new HashMap<Integer, BSkipSpan>(); + final HashMap<Integer, SkipLevels> levelHash = new HashMap<Integer, SkipLevels>(); private final boolean fileOnly; -- GitLab