diff options
author | Mark Spruiell <mes@zeroc.com> | 2008-01-30 06:15:20 -0800 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2008-01-30 06:15:20 -0800 |
commit | f3c3029ff651d294a1a0df0e79e72771307310fc (patch) | |
tree | 1f061a96f5f46051b6daf45ccbdb63ebd2cdd746 /java/src | |
parent | Fixed and moved fixVersion.py/fixCopyright.py (diff) | |
download | ice-f3c3029ff651d294a1a0df0e79e72771307310fc.tar.bz2 ice-f3c3029ff651d294a1a0df0e79e72771307310fc.tar.xz ice-f3c3029ff651d294a1a0df0e79e72771307310fc.zip |
using Java5 types in Ice core; general cleanup
Diffstat (limited to 'java/src')
58 files changed, 1007 insertions, 1354 deletions
diff --git a/java/src/Ice/ConnectionI.java b/java/src/Ice/ConnectionI.java index f62be52b497..de67944b223 100644 --- a/java/src/Ice/ConnectionI.java +++ b/java/src/Ice/ConnectionI.java @@ -1131,28 +1131,28 @@ public final class ConnectionI extends IceInternal.EventHandler finishStart(_exception); - java.util.Iterator i = _queuedStreams.iterator(); - while(i.hasNext()) + java.util.Iterator<OutgoingMessage> p = _queuedStreams.iterator(); + while(p.hasNext()) { - OutgoingMessage message = (OutgoingMessage)i.next(); + OutgoingMessage message = p.next(); message.finished(_exception); } _queuedStreams.clear(); - i = _requests.entryIterator(); // _requests is immutable at this point. - while(i.hasNext()) + java.util.Iterator<IceInternal.Outgoing> q = + _requests.values().iterator(); // _requests is immutable at this point. + while(q.hasNext()) { - IceInternal.IntMap.Entry e = (IceInternal.IntMap.Entry)i.next(); - IceInternal.Outgoing out = (IceInternal.Outgoing)e.getValue(); + IceInternal.Outgoing out = q.next(); out.finished(_exception); // The exception is immutable at this point. } _requests.clear(); - i = _asyncRequests.entryIterator(); // _asyncRequests is immutable at this point. - while(i.hasNext()) + java.util.Iterator<IceInternal.OutgoingAsync> r = + _asyncRequests.values().iterator(); // _asyncRequests is immutable at this point. + while(r.hasNext()) { - IceInternal.IntMap.Entry e = (IceInternal.IntMap.Entry)i.next(); - IceInternal.OutgoingAsync out = (IceInternal.OutgoingAsync)e.getValue(); + IceInternal.OutgoingAsync out = r.next(); out.__finished(_exception); // The exception is immutable at this point. } _asyncRequests.clear(); @@ -1326,7 +1326,7 @@ public final class ConnectionI extends IceInternal.EventHandler } else { - java.util.LinkedList streams = _queuedStreams; + java.util.LinkedList<OutgoingMessage> streams = _queuedStreams; _queuedStreams = _sendStreams; _sendStreams = streams; return IceInternal.SocketStatus.NeedWrite; // We're not finished yet, there's more data to send! @@ -1964,7 +1964,7 @@ public final class ConnectionI extends IceInternal.EventHandler while(!_sendStreams.isEmpty()) { - OutgoingMessage message = (OutgoingMessage)_sendStreams.getFirst(); + OutgoingMessage message = _sendStreams.getFirst(); if(!message.prepared) { IceInternal.BasicStream stream = message.stream; @@ -2288,14 +2288,14 @@ public final class ConnectionI extends IceInternal.EventHandler { IceInternal.TraceUtil.traceRecv(info.stream, _logger, _traceLevels); info.requestId = info.stream.readInt(); - IceInternal.Outgoing out = (IceInternal.Outgoing)_requests.remove(info.requestId); + IceInternal.Outgoing out = _requests.remove(info.requestId); if(out != null) { out.finished(info.stream); } else { - info.outAsync = (IceInternal.OutgoingAsync)_asyncRequests.remove(info.requestId); + info.outAsync = _asyncRequests.remove(info.requestId); if(info.outAsync == null) { throw new UnknownRequestIdException(); @@ -2668,28 +2668,26 @@ public final class ConnectionI extends IceInternal.EventHandler if(closed) { - java.util.Iterator i = _queuedStreams.iterator(); - while(i.hasNext()) + java.util.Iterator<OutgoingMessage> p = _queuedStreams.iterator(); + while(p.hasNext()) { - OutgoingMessage message = (OutgoingMessage)i.next(); + OutgoingMessage message = p.next(); message.finished(_exception); } _queuedStreams.clear(); - i = _requests.entryIterator(); - while(i.hasNext()) + java.util.Iterator<IceInternal.Outgoing> q = _requests.values().iterator(); + while(q.hasNext()) { - IceInternal.IntMap.Entry e = (IceInternal.IntMap.Entry)i.next(); - IceInternal.Outgoing out = (IceInternal.Outgoing)e.getValue(); + IceInternal.Outgoing out = q.next(); out.finished(_exception); // The exception is immutable at this point. } _requests.clear(); - i = _asyncRequests.entryIterator(); - while(i.hasNext()) + java.util.Iterator<IceInternal.OutgoingAsync> r = _asyncRequests.values().iterator(); + while(r.hasNext()) { - IceInternal.IntMap.Entry e = (IceInternal.IntMap.Entry)i.next(); - IceInternal.OutgoingAsync out = (IceInternal.OutgoingAsync)e.getValue(); + IceInternal.OutgoingAsync out = r.next(); out.__finished(_exception); // The exception is immutable at this point. } _asyncRequests.clear(); @@ -2778,7 +2776,8 @@ public final class ConnectionI extends IceInternal.EventHandler } public IceInternal.Outgoing - getOutgoing(IceInternal.RequestHandler handler, String operation, OperationMode mode, java.util.Map context) + getOutgoing(IceInternal.RequestHandler handler, String operation, OperationMode mode, + java.util.Map<String, String> context) throws IceInternal.LocalExceptionWrapper { IceInternal.Outgoing out = null; @@ -2968,8 +2967,10 @@ public final class ConnectionI extends IceInternal.EventHandler private int _nextRequestId; - private IceInternal.IntMap _requests = new IceInternal.IntMap(); - private IceInternal.IntMap _asyncRequests = new IceInternal.IntMap(); + private java.util.Map<Integer, IceInternal.Outgoing> _requests = + new java.util.HashMap<Integer, IceInternal.Outgoing>(); + private java.util.Map<Integer, IceInternal.OutgoingAsync> _asyncRequests = + new java.util.HashMap<Integer, IceInternal.OutgoingAsync>(); private LocalException _exception; @@ -2980,8 +2981,8 @@ public final class ConnectionI extends IceInternal.EventHandler private boolean _batchRequestCompress; private int _batchMarker; - private java.util.LinkedList _queuedStreams = new java.util.LinkedList(); - private java.util.LinkedList _sendStreams = new java.util.LinkedList(); + private java.util.LinkedList<OutgoingMessage> _queuedStreams = new java.util.LinkedList<OutgoingMessage>(); + private java.util.LinkedList<OutgoingMessage> _sendStreams = new java.util.LinkedList<OutgoingMessage>(); private boolean _sendInProgress; private int _dispatchCount; diff --git a/java/src/Ice/ImplicitContextI.java b/java/src/Ice/ImplicitContextI.java index 7f3a7a91f9d..036dfbf4627 100644 --- a/java/src/Ice/ImplicitContextI.java +++ b/java/src/Ice/ImplicitContextI.java @@ -31,21 +31,20 @@ public abstract class ImplicitContextI implements ImplicitContext else { throw new Ice.InitializationException( - "'" + kind + "' is not a valid value for Ice.ImplicitContext"); + "'" + kind + "' is not a valid value for Ice.ImplicitContext"); } } - abstract public void write(java.util.Map prxContext, IceInternal.BasicStream os); - abstract java.util.Map combine(java.util.Map prxContext); - + abstract public void write(java.util.Map<String, String> prxContext, IceInternal.BasicStream os); + abstract java.util.Map<String, String> combine(java.util.Map<String, String> prxContext); static class Shared extends ImplicitContextI { public synchronized java.util.Map getContext() { - return (java.util.Map)_context.clone(); + return new java.util.HashMap<String, String>(_context); } - + public synchronized void setContext(java.util.Map context) { _context.clear(); @@ -54,7 +53,7 @@ public abstract class ImplicitContextI implements ImplicitContext _context.putAll(context); } } - + public synchronized boolean containsKey(String key) { if(key == null) @@ -72,12 +71,12 @@ public abstract class ImplicitContextI implements ImplicitContext key = ""; } - String val = (String)_context.get(key); + String val = _context.get(key); if(val == null) { val = ""; } - + return val; } @@ -92,7 +91,7 @@ public abstract class ImplicitContextI implements ImplicitContext value = ""; } - String oldVal = (String)_context.put(key, value); + String oldVal = _context.put(key, value); if(oldVal == null) { oldVal = ""; @@ -107,7 +106,7 @@ public abstract class ImplicitContextI implements ImplicitContext key = ""; } - String val = (String)_context.remove(key); + String val = _context.remove(key); if(val == null) { @@ -116,7 +115,7 @@ public abstract class ImplicitContextI implements ImplicitContext return val; } - public void write(java.util.Map prxContext, IceInternal.BasicStream os) + public void write(java.util.Map<String, String> prxContext, IceInternal.BasicStream os) { if(prxContext.isEmpty()) { @@ -125,40 +124,40 @@ public abstract class ImplicitContextI implements ImplicitContext ContextHelper.write(os, _context); } } - else + else { - java.util.Map ctx = null; + java.util.Map<String, String> ctx = null; synchronized(this) { - ctx = _context.isEmpty() ? prxContext : combine(prxContext); + ctx = _context.isEmpty() ? prxContext : combine(prxContext); } ContextHelper.write(os, ctx); } } - synchronized java.util.Map combine(java.util.Map prxContext) + synchronized java.util.Map<String, String> combine(java.util.Map<String, String> prxContext) { - java.util.Map combined = (java.util.Map)_context.clone(); + java.util.Map<String, String> combined = new java.util.HashMap<String, String>(_context); combined.putAll(prxContext); return combined; } - private java.util.HashMap _context = new java.util.HashMap(); + private java.util.Map<String, String> _context = new java.util.HashMap<String, String>(); } static class PerThread extends ImplicitContextI { - + public java.util.Map getContext() { // // Note that _map is a *synchronized* map // - java.util.HashMap threadContext = (java.util.HashMap)_map.get(Thread.currentThread()); - + java.util.Map<String, String> threadContext = _map.get(Thread.currentThread()); + if(threadContext == null) { - threadContext = new java.util.HashMap(); + threadContext = new java.util.HashMap<String, String>(); } return threadContext; } @@ -171,7 +170,7 @@ public abstract class ImplicitContextI implements ImplicitContext } else { - java.util.HashMap threadContext = new java.util.HashMap(context); + java.util.Map<String, String> threadContext = new java.util.HashMap<String, String>(context); _map.put(Thread.currentThread(), threadContext); } } @@ -183,7 +182,7 @@ public abstract class ImplicitContextI implements ImplicitContext key = ""; } - java.util.HashMap threadContext = (java.util.HashMap)_map.get(Thread.currentThread()); + java.util.Map<String, String> threadContext = _map.get(Thread.currentThread()); if(threadContext == null) { @@ -200,13 +199,13 @@ public abstract class ImplicitContextI implements ImplicitContext key = ""; } - java.util.HashMap threadContext = (java.util.HashMap)_map.get(Thread.currentThread()); + java.util.Map<String, String> threadContext = _map.get(Thread.currentThread()); if(threadContext == null) { return ""; } - String val = (String)threadContext.get(key); + String val = threadContext.get(key); if(val == null) { val = ""; @@ -226,15 +225,15 @@ public abstract class ImplicitContextI implements ImplicitContext } Thread currentThread = Thread.currentThread(); - java.util.HashMap threadContext = (java.util.HashMap)_map.get(currentThread); + java.util.Map<String, String> threadContext = _map.get(currentThread); if(threadContext == null) { - threadContext = new java.util.HashMap(); + threadContext = new java.util.HashMap<String, String>(); _map.put(currentThread, threadContext); } - - String oldVal = (String)threadContext.put(key, value); + + String oldVal = threadContext.put(key, value); if(oldVal == null) { oldVal = ""; @@ -249,14 +248,14 @@ public abstract class ImplicitContextI implements ImplicitContext key = ""; } - java.util.HashMap threadContext = (java.util.HashMap)_map.get(Thread.currentThread()); + java.util.Map<String, String> threadContext = _map.get(Thread.currentThread()); if(threadContext == null) { return null; } - String val = (String)threadContext.remove(key); + String val = threadContext.remove(key); if(val == null) { @@ -265,10 +264,10 @@ public abstract class ImplicitContextI implements ImplicitContext return val; } - public void write(java.util.Map prxContext, IceInternal.BasicStream os) + public void write(java.util.Map<String, String> prxContext, IceInternal.BasicStream os) { - java.util.HashMap threadContext = (java.util.HashMap)_map.get(Thread.currentThread()); - + java.util.Map<String, String> threadContext = _map.get(Thread.currentThread()); + if(threadContext == null || threadContext.isEmpty()) { ContextHelper.write(os, prxContext); @@ -279,17 +278,17 @@ public abstract class ImplicitContextI implements ImplicitContext } else { - java.util.Map combined = (java.util.Map)threadContext.clone(); + java.util.Map<String, String> combined = new java.util.HashMap<String, String>(threadContext); combined.putAll(prxContext); ContextHelper.write(os, combined); } } - java.util.Map combine(java.util.Map prxContext) + java.util.Map<String, String> combine(java.util.Map<String, String> prxContext) { - java.util.HashMap threadContext = (java.util.HashMap)_map.get(Thread.currentThread()); + java.util.Map<String, String> threadContext = _map.get(Thread.currentThread()); - java.util.Map combined = (java.util.Map)threadContext.clone(); + java.util.Map<String, String> combined = new java.util.HashMap<String, String>(threadContext); combined.putAll(prxContext); return combined; } @@ -297,7 +296,7 @@ public abstract class ImplicitContextI implements ImplicitContext // // Synchronized map Thread -> Context // - private java.util.Map _map = java.util.Collections.synchronizedMap(new java.util.HashMap()); - - } + private java.util.Map<Thread, java.util.Map<String, String> > _map = + java.util.Collections.synchronizedMap(new java.util.HashMap<Thread, java.util.Map<String, String> >()); + } } diff --git a/java/src/Ice/ObjectAdapterI.java b/java/src/Ice/ObjectAdapterI.java index d8e10e68f2e..6998793fa06 100644 --- a/java/src/Ice/ObjectAdapterI.java +++ b/java/src/Ice/ObjectAdapterI.java @@ -24,7 +24,7 @@ public final class ObjectAdapterI implements ObjectAdapter getCommunicator() { checkForDeactivation(); - + return _communicator; } @@ -38,7 +38,7 @@ public final class ObjectAdapterI implements ObjectAdapter synchronized(this) { checkForDeactivation(); - + // // If the one off initializations of the adapter are already // done, we just need to activate the incoming connection @@ -64,7 +64,7 @@ public final class ObjectAdapterI implements ObjectAdapter // initializations are done. // _waitForActivate = true; - + locatorInfo = _locatorInfo; if(!_noConfig) { @@ -104,7 +104,7 @@ public final class ObjectAdapterI implements ObjectAdapter synchronized(this) { assert(!_deactivated); // Not possible if _waitForActivate = true; - + // // Signal threads waiting for the activation. // @@ -112,7 +112,7 @@ public final class ObjectAdapterI implements ObjectAdapter notifyAll(); _activateOneOffDone = true; - + final int sz = _incomingConnectionFactories.size(); for(int i = 0; i < sz; ++i) { @@ -127,7 +127,7 @@ public final class ObjectAdapterI implements ObjectAdapter hold() { checkForDeactivation(); - + final int sz = _incomingConnectionFactories.size(); for(int i = 0; i < sz; ++i) { @@ -155,7 +155,7 @@ public final class ObjectAdapterI implements ObjectAdapter deactivate() { IceInternal.OutgoingConnectionFactory outgoingConnectionFactory; - java.util.ArrayList incomingConnectionFactories; + java.util.List<IceInternal.IncomingConnectionFactory> incomingConnectionFactories; IceInternal.LocatorInfo locatorInfo; synchronized(this) { @@ -196,13 +196,14 @@ public final class ObjectAdapterI implements ObjectAdapter // _routerInfo.setAdapter(null); } - - incomingConnectionFactories = new java.util.ArrayList(_incomingConnectionFactories); + + incomingConnectionFactories = + new java.util.ArrayList<IceInternal.IncomingConnectionFactory>(_incomingConnectionFactories); outgoingConnectionFactory = _instance.outgoingConnectionFactory(); locatorInfo = _locatorInfo; _deactivated = true; - + notifyAll(); } @@ -226,8 +227,7 @@ public final class ObjectAdapterI implements ObjectAdapter final int sz = incomingConnectionFactories.size(); for(int i = 0; i < sz; ++i) { - IceInternal.IncomingConnectionFactory factory = - (IceInternal.IncomingConnectionFactory)incomingConnectionFactories.get(i); + IceInternal.IncomingConnectionFactory factory = incomingConnectionFactories.get(i); factory.destroy(); } @@ -266,12 +266,12 @@ public final class ObjectAdapterI implements ObjectAdapter { } } - + incomingConnectionFactories = (IceInternal.IncomingConnectionFactory[])_incomingConnectionFactories.toArray( new IceInternal.IncomingConnectionFactory[0]); } - + // // Now we wait for until all incoming connection factories are // finished. @@ -330,7 +330,7 @@ public final class ObjectAdapterI implements ObjectAdapter // locators. // _servantManager.destroy(); - + // // Destroy the thread pool. // @@ -359,7 +359,7 @@ public final class ObjectAdapterI implements ObjectAdapter // to null so that the finalizer does not invoke methods on objects. // _incomingConnectionFactories = null; - + // // Remove object references (some of them cyclic). // @@ -393,7 +393,7 @@ public final class ObjectAdapterI implements ObjectAdapter { checkForDeactivation(); checkIdentity(ident); - + // // Create a copy of the Identity argument, in case the caller // reuses it. @@ -536,7 +536,7 @@ public final class ObjectAdapterI implements ObjectAdapter { IceInternal.LocatorInfo locatorInfo = null; boolean registerProcess = false; - java.util.ArrayList oldPublishedEndpoints; + java.util.List<IceInternal.EndpointI> oldPublishedEndpoints; synchronized(this) { @@ -579,7 +579,7 @@ public final class ObjectAdapterI implements ObjectAdapter // NOTE: it's important that isLocal() doesn't perform any blocking operations as // it can be called for AMI invocations if the proxy has no delegate set yet. // - + IceInternal.Reference ref = ((ObjectPrxHelperBase)proxy).__reference(); if(ref.isWellKnown()) { @@ -604,7 +604,7 @@ public final class ObjectAdapterI implements ObjectAdapter synchronized(this) { checkForDeactivation(); - + // // Proxies which have at least one endpoint in common with the // endpoints used by this object adapter's incoming connection @@ -612,26 +612,26 @@ public final class ObjectAdapterI implements ObjectAdapter // for(int i = 0; i < endpoints.length; ++i) { - java.util.Iterator p; - p = _publishedEndpoints.iterator(); + java.util.Iterator<IceInternal.EndpointI> p = _publishedEndpoints.iterator(); while(p.hasNext()) { - if(endpoints[i].equivalent((IceInternal.EndpointI)p.next())) + if(endpoints[i].equivalent(p.next())) { return true; } } - p = _incomingConnectionFactories.iterator(); - while(p.hasNext()) + java.util.Iterator<IceInternal.IncomingConnectionFactory> q = + _incomingConnectionFactories.iterator(); + while(q.hasNext()) { - if(endpoints[i].equivalent(((IceInternal.IncomingConnectionFactory)p.next()).endpoint())) + if(endpoints[i].equivalent(q.next().endpoint())) { return true; } } - + } - + // // Proxies which have at least one endpoint in common with the // router's server proxy endpoints (if any), are also considered @@ -641,11 +641,10 @@ public final class ObjectAdapterI implements ObjectAdapter { for(int i = 0; i < endpoints.length; ++i) { - java.util.Iterator p; - p = _routerEndpoints.iterator(); + java.util.Iterator<IceInternal.EndpointI> p = _routerEndpoints.iterator(); while(p.hasNext()) { - if(endpoints[i].equivalent((IceInternal.EndpointI)p.next())) + if(endpoints[i].equivalent(p.next())) { return true; } @@ -661,15 +660,15 @@ public final class ObjectAdapterI implements ObjectAdapter public void flushBatchRequests() { - java.util.ArrayList f; + java.util.List<IceInternal.IncomingConnectionFactory> f; synchronized(this) { - f = new java.util.ArrayList(_incomingConnectionFactories); + f = new java.util.ArrayList<IceInternal.IncomingConnectionFactory>(_incomingConnectionFactories); } - java.util.Iterator i = f.iterator(); + java.util.Iterator<IceInternal.IncomingConnectionFactory> i = f.iterator(); while(i.hasNext()) { - ((IceInternal.IncomingConnectionFactory)i.next()).flushBatchRequests(); + i.next().flushBatchRequests(); } } @@ -686,9 +685,9 @@ public final class ObjectAdapterI implements ObjectAdapter decDirectCount() { // Not check for deactivation here! - + assert(_instance != null); // Must not be called after destroy(). - + assert(_directCount > 0); if(--_directCount == 0) { @@ -702,9 +701,9 @@ public final class ObjectAdapterI implements ObjectAdapter // No mutex lock necessary, _threadPool and _instance are // immutable after creation until they are removed in // destroy(). - + // Not check for deactivation here! - + assert(_instance != null); // Must not be called after destroy(). if(_threadPool != null) @@ -765,7 +764,7 @@ public final class ObjectAdapterI implements ObjectAdapter } final Properties properties = _instance.initializationData().properties; - java.util.ArrayList unknownProps = new java.util.ArrayList(); + java.util.List<String> unknownProps = new java.util.ArrayList<String>(); boolean noProps = filterProperties(unknownProps); // @@ -774,10 +773,10 @@ public final class ObjectAdapterI implements ObjectAdapter if(unknownProps.size() != 0 && properties.getPropertyAsIntWithDefault("Ice.Warn.UnknownProperties", 1) > 0) { String message = "found unknown properties for object adapter `" + _name + "':"; - java.util.Iterator p = unknownProps.iterator(); + java.util.Iterator<String> p = unknownProps.iterator(); while(p.hasNext()) { - message += "\n " + (String)p.next(); + message += "\n " + p.next(); } _instance.initializationData().logger.warning(message); } @@ -877,11 +876,11 @@ public final class ObjectAdapterI implements ObjectAdapter // Remove duplicate endpoints, so we have a list of unique // endpoints. // - for(int i = 0; i < _routerEndpoints.size()-1;) + for(int i = 0; i < _routerEndpoints.size() - 1;) { - java.lang.Object o1 = _routerEndpoints.get(i); - java.lang.Object o2 = _routerEndpoints.get(i + 1); - if(o1.equals(o2)) + IceInternal.EndpointI e1 = _routerEndpoints.get(i); + IceInternal.EndpointI e2 = _routerEndpoints.get(i + 1); + if(e1.equals(e2)) { _routerEndpoints.remove(i); } @@ -912,7 +911,7 @@ public final class ObjectAdapterI implements ObjectAdapter // Parse the endpoints, but don't store them in the adapter. The connection // factory might change it, for example, to fill in the real port number. // - java.util.ArrayList endpoints; + java.util.List<IceInternal.EndpointI> endpoints; if(endpointInfo.length() == 0) { endpoints = parseEndpoints(properties.getProperty(_name + ".Endpoints"), true); @@ -923,7 +922,7 @@ public final class ObjectAdapterI implements ObjectAdapter } for(int i = 0; i < endpoints.size(); ++i) { - IceInternal.EndpointI endp = (IceInternal.EndpointI)endpoints.get(i); + IceInternal.EndpointI endp = endpoints.get(i); IceInternal.IncomingConnectionFactory factory = new IceInternal.IncomingConnectionFactory(instance, endp, this, _name); _incomingConnectionFactories.add(factory); @@ -1068,7 +1067,7 @@ public final class ObjectAdapterI implements ObjectAdapter } } - private java.util.ArrayList + private java.util.List<IceInternal.EndpointI> parseEndpoints(String endpts, boolean oaEndpoints) { int beg; @@ -1076,7 +1075,7 @@ public final class ObjectAdapterI implements ObjectAdapter final String delim = " \t\n\r"; - java.util.ArrayList endpoints = new java.util.ArrayList(); + java.util.List<IceInternal.EndpointI> endpoints = new java.util.ArrayList<IceInternal.EndpointI>(); while(end < endpts.length()) { beg = IceUtilInternal.StringUtil.findFirstNotOf(endpts, delim, end); @@ -1150,7 +1149,7 @@ public final class ObjectAdapterI implements ObjectAdapter return endpoints; } - private java.util.ArrayList + private java.util.List<IceInternal.EndpointI> parsePublishedEndpoints() { // @@ -1158,7 +1157,7 @@ public final class ObjectAdapterI implements ObjectAdapter // instead of the connection factory Endpoints. // String endpts = _instance.initializationData().properties.getProperty(_name + ".PublishedEndpoints"); - java.util.ArrayList endpoints = parseEndpoints(endpts, false); + java.util.List<IceInternal.EndpointI> endpoints = parseEndpoints(endpts, false); if(!endpoints.isEmpty()) { return endpoints; @@ -1170,8 +1169,7 @@ public final class ObjectAdapterI implements ObjectAdapter // for(int i = 0; i < _incomingConnectionFactories.size(); ++i) { - IceInternal.IncomingConnectionFactory factory = - (IceInternal.IncomingConnectionFactory)_incomingConnectionFactories.get(i); + IceInternal.IncomingConnectionFactory factory = _incomingConnectionFactories.get(i); endpoints.add(factory.endpoint()); } @@ -1179,11 +1177,11 @@ public final class ObjectAdapterI implements ObjectAdapter // Expand any endpoints that may be listening on INADDR_ANY to // include actual addresses in the published endpoints. // - java.util.ArrayList expandedEndpoints = new java.util.ArrayList(); - java.util.Iterator p = endpoints.iterator(); + java.util.List<IceInternal.EndpointI> expandedEndpoints = new java.util.ArrayList<IceInternal.EndpointI>(); + java.util.Iterator<IceInternal.EndpointI> p = endpoints.iterator(); while(p.hasNext()) { - expandedEndpoints.addAll(((IceInternal.EndpointI)p.next()).expand()); + expandedEndpoints.addAll(p.next().expand()); } return expandedEndpoints; } @@ -1246,7 +1244,7 @@ public final class ObjectAdapterI implements ObjectAdapter s.append("the object adapter is not known to the locator registry"); _instance.initializationData().logger.trace(_instance.traceLevels().locationCat, s.toString()); } - + NotRegisteredException ex1 = new NotRegisteredException(); ex1.kindOfObject = "object adapter"; ex1.id = _id; @@ -1312,7 +1310,7 @@ public final class ObjectAdapterI implements ObjectAdapter _instance.initializationData().logger.trace(_instance.traceLevels().locationCat, s.toString()); } } - + if(registerProcess && serverId.length() > 0) { synchronized(this) @@ -1354,7 +1352,7 @@ public final class ObjectAdapterI implements ObjectAdapter } throw ex; // TODO: Shall we raise a special exception instead of a non obvious local exception? } - + if(_instance.traceLevels().location >= 1) { StringBuffer s = new StringBuffer(); @@ -1383,7 +1381,7 @@ public final class ObjectAdapterI implements ObjectAdapter }; boolean - filterProperties(java.util.List unknownProps) + filterProperties(java.util.List<String> unknownProps) { // // Do not create unknown properties list if Ice prefix, ie Ice, Glacier2, etc @@ -1400,12 +1398,11 @@ public final class ObjectAdapterI implements ObjectAdapter } boolean noProps = true; - java.util.Map props = _instance.initializationData().properties.getPropertiesForPrefix(prefix); - java.util.Iterator p = props.entrySet().iterator(); + java.util.Map<String, String> props = _instance.initializationData().properties.getPropertiesForPrefix(prefix); + java.util.Iterator<String> p = props.keySet().iterator(); while(p.hasNext()) { - java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); - String prop = (String)entry.getKey(); + String prop = p.next(); boolean valid = false; for(int i = 0; i < _suffixes.length; ++i) @@ -1438,10 +1435,12 @@ public final class ObjectAdapterI implements ObjectAdapter final private String _id; final private String _replicaGroupId; private IceInternal.Reference _reference; - private java.util.ArrayList _incomingConnectionFactories = new java.util.ArrayList(); - private java.util.ArrayList _routerEndpoints = new java.util.ArrayList(); + private java.util.List<IceInternal.IncomingConnectionFactory> _incomingConnectionFactories = + new java.util.ArrayList<IceInternal.IncomingConnectionFactory>(); + private java.util.List<IceInternal.EndpointI> _routerEndpoints = new java.util.ArrayList<IceInternal.EndpointI>(); private IceInternal.RouterInfo _routerInfo = null; - private java.util.ArrayList _publishedEndpoints = new java.util.ArrayList(); + private java.util.List<IceInternal.EndpointI> _publishedEndpoints = + new java.util.ArrayList<IceInternal.EndpointI>(); private IceInternal.LocatorInfo _locatorInfo; private int _directCount; private boolean _waitForActivate; diff --git a/java/src/Ice/PluginManagerI.java b/java/src/Ice/PluginManagerI.java index 66285019a37..3b385dfd10c 100644 --- a/java/src/Ice/PluginManagerI.java +++ b/java/src/Ice/PluginManagerI.java @@ -26,13 +26,13 @@ public final class PluginManagerI implements PluginManager // // Invoke initialize() on the plugins, in the order they were loaded. // - java.util.ArrayList initializedPlugins = new java.util.ArrayList(); + java.util.List<Plugin> initializedPlugins = new java.util.ArrayList<Plugin>(); try { - java.util.Iterator i = _initOrder.iterator(); + java.util.Iterator<Plugin> i = _initOrder.iterator(); while(i.hasNext()) { - Plugin p = (Plugin)i.next(); + Plugin p = i.next(); p.initialize(); initializedPlugins.add(p); } @@ -43,10 +43,10 @@ public final class PluginManagerI implements PluginManager // Destroy the plugins that have been successfully initialized, in the // reverse order. // - java.util.ListIterator i = initializedPlugins.listIterator(initializedPlugins.size()); + java.util.ListIterator<Plugin> i = initializedPlugins.listIterator(initializedPlugins.size()); while(i.hasPrevious()) { - Plugin p = (Plugin)i.previous(); + Plugin p = i.previous(); try { p.destroy(); @@ -70,7 +70,7 @@ public final class PluginManagerI implements PluginManager throw new CommunicatorDestroyedException(); } - Plugin p = (Plugin)_plugins.get(name); + Plugin p = _plugins.get(name); if(p != null) { return p; @@ -104,10 +104,10 @@ public final class PluginManagerI implements PluginManager { if(_communicator != null) { - java.util.Iterator i = _plugins.values().iterator(); + java.util.Iterator<Plugin> i = _plugins.values().iterator(); while(i.hasNext()) { - Plugin p = (Plugin)i.next(); + Plugin p = i.next(); p.destroy(); } @@ -141,7 +141,7 @@ public final class PluginManagerI implements PluginManager // final String prefix = "Ice.Plugin."; Properties properties = _communicator.getProperties(); - java.util.Map plugins = properties.getPropertiesForPrefix(prefix); + java.util.Map<String, String> plugins = properties.getPropertiesForPrefix(prefix); final String loadOrder = properties.getProperty("Ice.PluginLoadOrder"); if(loadOrder.length() > 0) @@ -188,10 +188,10 @@ public final class PluginManagerI implements PluginManager // while(!plugins.isEmpty()) { - java.util.Iterator p = plugins.entrySet().iterator(); - java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); + java.util.Iterator<java.util.Map.Entry<String, String> > p = plugins.entrySet().iterator(); + java.util.Map.Entry<String, String> entry = p.next(); - String name = ((String)entry.getKey()).substring(prefix.length()); + String name = entry.getKey().substring(prefix.length()); int dotPos = name.lastIndexOf('.'); if(dotPos != -1) @@ -207,8 +207,7 @@ public final class PluginManagerI implements PluginManager else if(suffix.equals("java")) { name = name.substring(0, dotPos); - String value = (String)entry.getValue(); - loadPlugin(name, value, cmdArgs); + loadPlugin(name, entry.getValue(), cmdArgs); p.remove(); } else @@ -225,10 +224,10 @@ public final class PluginManagerI implements PluginManager // // Is there a .java entry? // - String value = (String)entry.getValue(); + String value = entry.getValue(); p.remove(); - String javaValue = (String)plugins.remove("Ice.Plugin." + name + ".java"); + String javaValue = plugins.remove("Ice.Plugin." + name + ".java"); if(javaValue != null) { value = javaValue; @@ -384,8 +383,8 @@ public final class PluginManagerI implements PluginManager } private Communicator _communicator; - private java.util.HashMap _plugins = new java.util.HashMap(); - private java.util.ArrayList _initOrder = new java.util.ArrayList(); + private java.util.Map<String, Plugin> _plugins = new java.util.HashMap<String, Plugin>(); + private java.util.List<Plugin> _initOrder = new java.util.ArrayList<Plugin>(); private Logger _logger = null; private boolean _initialized; } diff --git a/java/src/Ice/PropertiesI.java b/java/src/Ice/PropertiesI.java index d18ea835c0b..d78651ae2d7 100644 --- a/java/src/Ice/PropertiesI.java +++ b/java/src/Ice/PropertiesI.java @@ -33,20 +33,16 @@ public final class PropertiesI implements Properties getProperty(String key) { String result = null; - PropertyValue pv = (PropertyValue)_properties.get(key); + PropertyValue pv = _properties.get(key); if(pv == null) { - result = System.getProperty(key); + result = System.getProperty(key, ""); } else { pv.used = true; result = pv.value; } - if(result == null) - { - result = ""; - } return result; } @@ -54,20 +50,16 @@ public final class PropertiesI implements Properties getPropertyWithDefault(String key, String value) { String result = null; - PropertyValue pv = (PropertyValue)_properties.get(key); + PropertyValue pv = _properties.get(key); if(pv == null) { - result = System.getProperty(key); + result = System.getProperty(key, value); } else { pv.used = true; result = pv.value; } - if(result == null) - { - result = value; - } return result; } @@ -81,7 +73,7 @@ public final class PropertiesI implements Properties getPropertyAsIntWithDefault(String key, int value) { String result = null; - PropertyValue pv = (PropertyValue)_properties.get(key); + PropertyValue pv = _properties.get(key); if(pv == null) { result = System.getProperty(key); @@ -123,7 +115,7 @@ public final class PropertiesI implements Properties } String result = null; - PropertyValue pv = (PropertyValue)_properties.get(key); + PropertyValue pv = _properties.get(key); if(pv == null) { result = System.getProperty(key); @@ -152,18 +144,18 @@ public final class PropertiesI implements Properties } - public synchronized java.util.Map + public synchronized java.util.Map<String, String> getPropertiesForPrefix(String prefix) { - java.util.HashMap result = new java.util.HashMap(); - java.util.Iterator p = _properties.entrySet().iterator(); + java.util.HashMap<String, String> result = new java.util.HashMap<String, String>(); + java.util.Iterator<java.util.Map.Entry<String, PropertyValue> > p = _properties.entrySet().iterator(); while(p.hasNext()) { - java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); - String key = (String)entry.getKey(); + java.util.Map.Entry<String, PropertyValue> entry = p.next(); + String key = entry.getKey(); if(prefix.length() == 0 || key.startsWith(prefix)) { - PropertyValue pv = (PropertyValue)entry.getValue(); + PropertyValue pv = entry.getValue(); pv.used = true; result.put(key, pv.value); } @@ -191,6 +183,10 @@ public final class PropertiesI implements Properties { String pattern = IceInternal.PropertyNames.validProps[i][0].pattern(); dotPos = pattern.indexOf('.'); + // + // Each top level prefix describes a non-empty namespace. Having a string without a + // prefix followed by a dot is an error. + // assert(dotPos != -1); String propPrefix = pattern.substring(0, dotPos - 1); if(!propPrefix.equals(prefix)) @@ -229,7 +225,7 @@ public final class PropertiesI implements Properties // if(value != null && value.length() > 0) { - PropertyValue pv = (PropertyValue)_properties.get(key); + PropertyValue pv = _properties.get(key); if(pv != null) { pv.value = value; @@ -251,12 +247,12 @@ public final class PropertiesI implements Properties getCommandLineOptions() { String[] result = new String[_properties.size()]; - java.util.Iterator p = _properties.entrySet().iterator(); + java.util.Iterator<java.util.Map.Entry<String, PropertyValue> > p = _properties.entrySet().iterator(); int i = 0; while(p.hasNext()) { - java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); - result[i++] = "--" + entry.getKey() + "=" + ((PropertyValue)entry.getValue()).value; + java.util.Map.Entry<String, PropertyValue> entry = p.next(); + result[i++] = "--" + entry.getKey() + "=" + entry.getValue().value; } assert(i == result.length); return result; @@ -271,7 +267,7 @@ public final class PropertiesI implements Properties } pfx = "--" + pfx; - java.util.ArrayList result = new java.util.ArrayList(); + java.util.ArrayList<String> result = new java.util.ArrayList<String>(); for(int i = 0; i < options.length; i++) { String opt = options[i]; @@ -289,9 +285,7 @@ public final class PropertiesI implements Properties result.add(opt); } } - String[] arr = new String[result.size()]; - result.toArray(arr); - return arr; + return (String[])result.toArray(new String[0]); } public String[] @@ -330,18 +324,18 @@ public final class PropertiesI implements Properties return new PropertiesI(this); } - public synchronized java.util.List + public synchronized java.util.List<String> getUnusedProperties() { - java.util.List unused = new java.util.ArrayList(); - java.util.Iterator p = _properties.entrySet().iterator(); + java.util.List<String> unused = new java.util.ArrayList<String>(); + java.util.Iterator<java.util.Map.Entry<String, PropertyValue> > p = _properties.entrySet().iterator(); while(p.hasNext()) { - java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); - PropertyValue pv = (PropertyValue)entry.getValue(); + java.util.Map.Entry<String, PropertyValue> entry = p.next(); + PropertyValue pv = entry.getValue(); if(!pv.used) { - unused.add((String)entry.getKey()); + unused.add(entry.getKey()); } } return unused; @@ -353,12 +347,12 @@ public final class PropertiesI implements Properties // NOTE: we can't just do a shallow copy of the map as the map values // would otherwise be shared between the two PropertiesI object. // - //_properties = new java.util.HashMap(p._properties); - java.util.Iterator p = props._properties.entrySet().iterator(); + //_properties = new java.util.HashMap<String, PropertyValue>(props._properties); + java.util.Iterator<java.util.Map.Entry<String, PropertyValue> > p = props._properties.entrySet().iterator(); while(p.hasNext()) { - java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); - _properties.put(entry.getKey(), new PropertyValue((PropertyValue)entry.getValue())); + java.util.Map.Entry<String, PropertyValue> entry = p.next(); + _properties.put(entry.getKey(), new PropertyValue(entry.getValue())); } } @@ -370,7 +364,7 @@ public final class PropertiesI implements Properties { if(defaults != null) { - _properties = new java.util.HashMap(((PropertiesI)defaults)._properties); + _properties = new java.util.HashMap<String, PropertyValue>(((PropertiesI)defaults)._properties); } boolean loadConfigFiles = false; @@ -397,6 +391,14 @@ public final class PropertiesI implements Properties } } + if(!loadConfigFiles) + { + // + // If Ice.Config is not set, load from ICE_CONFIG (if set) + // + loadConfigFiles = !_properties.containsKey("Ice.Config"); + } + if(loadConfigFiles) { loadConfig(); @@ -479,9 +481,21 @@ public final class PropertiesI implements Properties { String value = getProperty("Ice.Config"); - if(value.equals("1")) + if(value.length() == 0 || value.equals("1")) { - value = ""; + try + { + value = System.getenv("ICE_CONFIG"); + if(value == null) + { + value = ""; + } + } + catch(SecurityException ex) + { + Ice.Util.getProcessLogger().warning("unable to access ICE_CONFIG environment variable"); + value = ""; + } } if(value.length() > 0) @@ -501,7 +515,7 @@ public final class PropertiesI implements Properties // private String[] splitString(String str, String delim) { - java.util.List l = new java.util.ArrayList(); + java.util.List<String> l = new java.util.ArrayList<String>(); char[] arr = new char[str.length()]; int pos = 0; @@ -516,7 +530,8 @@ public final class PropertiesI implements Properties } while(pos < str.length()) { - if(quoteChar != '\0' && str.charAt(pos) == '\\' && pos + 1 < str.length() && str.charAt(pos + 1) == quoteChar) + if(quoteChar != '\0' && str.charAt(pos) == '\\' && pos + 1 < str.length() && + str.charAt(pos + 1) == quoteChar) { ++pos; } @@ -553,5 +568,5 @@ public final class PropertiesI implements Properties return (String[])l.toArray(new String[0]); } - private java.util.HashMap _properties = new java.util.HashMap(); + private java.util.HashMap<String, PropertyValue> _properties = new java.util.HashMap<String, PropertyValue>(); } diff --git a/java/src/Ice/_ObjectDelD.java b/java/src/Ice/_ObjectDelD.java index 65f321861ad..ed1904ec76f 100644 --- a/java/src/Ice/_ObjectDelD.java +++ b/java/src/Ice/_ObjectDelD.java @@ -280,11 +280,11 @@ public class _ObjectDelD implements _ObjectDel ImplicitContextI implicitContext = __reference.getInstance().getImplicitContext(); - java.util.Map prxContext = __reference.getContext(); + java.util.Map<String, String> prxContext = __reference.getContext(); if(implicitContext == null) { - current.ctx = new java.util.HashMap(prxContext); + current.ctx = new java.util.HashMap<String, String>(prxContext); } else { diff --git a/java/src/IceBox/Admin.java b/java/src/IceBox/Admin.java index 133b0eee01c..5402d7c1086 100644 --- a/java/src/IceBox/Admin.java +++ b/java/src/IceBox/Admin.java @@ -30,7 +30,7 @@ public final class Admin public int run(String[] args) { - java.util.ArrayList commands = new java.util.ArrayList(); + java.util.List<String> commands = new java.util.ArrayList<String>(); int idx = 0; while(idx < args.length) diff --git a/java/src/IceBox/ServiceManagerI.java b/java/src/IceBox/ServiceManagerI.java index 611657a1773..297438f06f4 100644 --- a/java/src/IceBox/ServiceManagerI.java +++ b/java/src/IceBox/ServiceManagerI.java @@ -21,7 +21,8 @@ public class ServiceManagerI extends _ServiceManagerDisp _server = server; _logger = _server.communicator().getLogger(); _argv = args; - _traceServiceObserver = _server.communicator().getProperties().getPropertyAsInt("IceBox.Trace.ServiceObserver"); + _traceServiceObserver = + _server.communicator().getProperties().getPropertyAsInt("IceBox.Trace.ServiceObserver"); } public java.util.Map @@ -76,10 +77,10 @@ public class ServiceManagerI extends _ServiceManagerDisp java.io.PrintWriter pw = new java.io.PrintWriter(sw); e.printStackTrace(pw); pw.flush(); - _logger.warning("ServiceManager: exception in start for service " + info.name + "\n" + + _logger.warning("ServiceManager: exception in start for service " + info.name + "\n" + sw.toString()); } - + java.util.Set<ServiceObserverPrx> observers = null; synchronized(this) { @@ -92,7 +93,7 @@ public class ServiceManagerI extends _ServiceManagerDisp if(started) { in.status = StatusStarted; - observers = (java.util.Set<ServiceObserverPrx>)_observers.clone(); + observers = new java.util.HashSet<ServiceObserverPrx>(_observers); } else { @@ -107,7 +108,7 @@ public class ServiceManagerI extends _ServiceManagerDisp if(observers != null) { - java.util.List<String> services = new java.util.Vector<String>(); + java.util.List<String> services = new java.util.ArrayList<String>(); services.add(name); servicesStarted(services, observers); } @@ -158,10 +159,10 @@ public class ServiceManagerI extends _ServiceManagerDisp java.io.PrintWriter pw = new java.io.PrintWriter(sw); e.printStackTrace(pw); pw.flush(); - _logger.warning("ServiceManager: exception in stop for service " + info.name + "\n" + + _logger.warning("ServiceManager: exception in stop for service " + info.name + "\n" + sw.toString()); } - + java.util.Set<ServiceObserverPrx> observers = null; synchronized(this) { @@ -174,7 +175,7 @@ public class ServiceManagerI extends _ServiceManagerDisp if(stopped) { in.status = StatusStopped; - observers = (java.util.Set<ServiceObserverPrx>)_observers.clone(); + observers = new java.util.HashSet<ServiceObserverPrx>(_observers); } else { @@ -189,7 +190,7 @@ public class ServiceManagerI extends _ServiceManagerDisp if(observers != null) { - java.util.List<String> services = new java.util.Vector<String>(); + java.util.List<String> services = new java.util.ArrayList<String>(); services.add(name); servicesStopped(services, observers); } @@ -212,9 +213,9 @@ public class ServiceManagerI extends _ServiceManagerDisp { _logger.trace("IceBox.ServiceObserver", "Added service observer " + _server.communicator().proxyToString(observer)); - } - - + } + + for(ServiceInfo info: _services) { if(info.status == StatusStarted) @@ -222,10 +223,10 @@ public class ServiceManagerI extends _ServiceManagerDisp activeServices.add(info.name); } } - + } } - + if(activeServices.size() > 0) { AMI_ServiceObserver_servicesStarted cb = new AMI_ServiceObserver_servicesStarted() @@ -234,7 +235,7 @@ public class ServiceManagerI extends _ServiceManagerDisp { // ok, success } - + public void ice_exception(Ice.LocalException ex) { // @@ -243,7 +244,7 @@ public class ServiceManagerI extends _ServiceManagerDisp removeObserver(observer, ex); } }; - + observer.servicesStarted_async(cb, activeServices.toArray(new String[0])); } } @@ -299,7 +300,7 @@ public class ServiceManagerI extends _ServiceManagerDisp // then load any remaining services. // final String prefix = "IceBox.Service."; - java.util.Map services = properties.getPropertiesForPrefix(prefix); + java.util.Map<String, String> services = properties.getPropertiesForPrefix(prefix); if(loadOrder != null) { for(int i = 0; i < loadOrder.length; ++i) @@ -307,7 +308,7 @@ public class ServiceManagerI extends _ServiceManagerDisp if(loadOrder[i].length() > 0) { String key = prefix + loadOrder[i]; - String value = (String)services.get(key); + String value = services.get(key); if(value == null) { FailureException ex = new FailureException(); @@ -319,12 +320,12 @@ public class ServiceManagerI extends _ServiceManagerDisp } } } - java.util.Iterator p = services.entrySet().iterator(); + java.util.Iterator<java.util.Map.Entry<String, String> > p = services.entrySet().iterator(); while(p.hasNext()) { - java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); - String name = ((String)entry.getKey()).substring(prefix.length()); - String value = (String)entry.getValue(); + java.util.Map.Entry<String, String> entry = p.next(); + String name = entry.getKey().substring(prefix.length()); + String value = entry.getValue(); load(name, value); } @@ -354,7 +355,7 @@ public class ServiceManagerI extends _ServiceManagerDisp // _server.shutdownOnInterrupt(); - + // // Register "this" as a facet to the Admin object and // create Admin object @@ -365,7 +366,7 @@ public class ServiceManagerI extends _ServiceManagerDisp // // Add a Properties facet for each service - // + // for(ServiceInfo info: _services) { Ice.Communicator communicator = info.communicator != null ? info.communicator : _sharedCommunicator; @@ -382,7 +383,7 @@ public class ServiceManagerI extends _ServiceManagerDisp // } - // + // // Start request dispatching after we've started the services. // if(adapter != null) @@ -487,7 +488,7 @@ public class ServiceManagerI extends _ServiceManagerDisp // shared communicator, depending on the value of the // IceBox.UseSharedCommunicator property. // - java.util.ArrayList l = new java.util.ArrayList(); + java.util.List<String> l = new java.util.ArrayList<String>(); for(int j = 0; j < args.length; j++) { l.add(args[j]); @@ -499,7 +500,7 @@ public class ServiceManagerI extends _ServiceManagerDisp l.add(_argv[j]); } } - + Ice.StringSeqHolder serviceArgs = new Ice.StringSeqHolder(); serviceArgs.value = (String[])l.toArray(new String[0]); @@ -573,25 +574,26 @@ public class ServiceManagerI extends _ServiceManagerDisp // // Erase properties in 'properties' // - java.util.Map allProps = properties.getPropertiesForPrefix(""); - java.util.Iterator p = allProps.keySet().iterator(); + java.util.Map<String, String> allProps = properties.getPropertiesForPrefix(""); + java.util.Iterator<String> p = allProps.keySet().iterator(); while(p.hasNext()) { - String key = (String)p.next(); + String key = p.next(); if(svcProperties.getProperty(key).length() == 0) { properties.setProperty(key, ""); } } - + // // Add the service properties to the shared communicator properties. // - p = svcProperties.getPropertiesForPrefix("").entrySet().iterator(); - while(p.hasNext()) + java.util.Iterator<java.util.Map.Entry<String, String> > q = + svcProperties.getPropertiesForPrefix("").entrySet().iterator(); + while(q.hasNext()) { - java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); - properties.setProperty((String)entry.getKey(), (String)entry.getValue()); + java.util.Map.Entry<String, String> entry = q.next(); + properties.setProperty(entry.getKey(), entry.getValue()); } // @@ -605,7 +607,7 @@ public class ServiceManagerI extends _ServiceManagerDisp info.communicator = createCommunicator(service, serviceArgs); communicator = info.communicator; } - + try { info.args = serviceArgs.value; @@ -614,8 +616,8 @@ public class ServiceManagerI extends _ServiceManagerDisp // // There is no need to notify the observers since the 'start all' - // (that indirectly calls this method) occurs before the creation of - // the Server Admin object, and before the activation of the main + // (that indirectly calls this method) occurs before the creation of + // the Server Admin object, and before the activation of the main // object adapter (so before any observer can be registered) // } @@ -644,7 +646,7 @@ public class ServiceManagerI extends _ServiceManagerDisp _logger.warning("ServiceManager: exception in shutting down communicator for service " + service + "\n" + sw.toString()); } - + try { info.communicator.destroy(); @@ -680,9 +682,9 @@ public class ServiceManagerI extends _ServiceManagerDisp private void stopAll() { - java.util.List<String> stoppedServices = new java.util.Vector<String>(); + java.util.List<String> stoppedServices = new java.util.ArrayList<String>(); java.util.Set<ServiceObserverPrx> observers = null; - + synchronized(this) { // @@ -698,15 +700,15 @@ public class ServiceManagerI extends _ServiceManagerDisp { } } - + // - // For each service, we call stop on the service and flush its database environment to + // For each service, we call stop on the service and flush its database environment to // the disk. Services are stopped in the reverse order of the order they were started. // - java.util.ListIterator p = _services.listIterator(_services.size()); + java.util.ListIterator<ServiceInfo> p = _services.listIterator(_services.size()); while(p.hasPrevious()) { - ServiceInfo info = (ServiceInfo)p.previous(); + ServiceInfo info = p.previous(); if(info.status == StatusStarted) { try @@ -721,11 +723,11 @@ public class ServiceManagerI extends _ServiceManagerDisp java.io.PrintWriter pw = new java.io.PrintWriter(sw); e.printStackTrace(pw); pw.flush(); - _logger.warning("ServiceManager: exception in stop for service " + info.name + "\n" + + _logger.warning("ServiceManager: exception in stop for service " + info.name + "\n" + sw.toString()); } } - + try { _server.communicator().removeAdminFacet("IceBox.Service." + info.name + ".Properties"); @@ -734,7 +736,7 @@ public class ServiceManagerI extends _ServiceManagerDisp { // Ignored } - + if(info.communicator != null) { try @@ -755,10 +757,10 @@ public class ServiceManagerI extends _ServiceManagerDisp java.io.PrintWriter pw = new java.io.PrintWriter(sw); e.printStackTrace(pw); pw.flush(); - _logger.warning("ServiceManager: exception in stop for service " + info.name + "\n" + + _logger.warning("ServiceManager: exception in stop for service " + info.name + "\n" + sw.toString()); } - + try { info.communicator.destroy(); @@ -769,7 +771,7 @@ public class ServiceManagerI extends _ServiceManagerDisp java.io.PrintWriter pw = new java.io.PrintWriter(sw); e.printStackTrace(pw); pw.flush(); - _logger.warning("ServiceManager: exception in stop for service " + info.name + "\n" + + _logger.warning("ServiceManager: exception in stop for service " + info.name + "\n" + sw.toString()); } } @@ -787,20 +789,19 @@ public class ServiceManagerI extends _ServiceManagerDisp java.io.PrintWriter pw = new java.io.PrintWriter(sw); e.printStackTrace(pw); pw.flush(); - _logger.warning("ServiceManager: unknown exception while destroying shared communicator:\n" + + _logger.warning("ServiceManager: unknown exception while destroying shared communicator:\n" + sw.toString()); } _sharedCommunicator = null; } _services.clear(); - observers = (java.util.Set<ServiceObserverPrx>)_observers.clone(); + observers = new java.util.HashSet<ServiceObserverPrx>(_observers); } servicesStopped(stoppedServices, observers); } - private void servicesStarted(java.util.List<String> services, java.util.Set<ServiceObserverPrx> observers) { @@ -818,7 +819,7 @@ public class ServiceManagerI extends _ServiceManagerDisp { // ok, success } - + public void ice_exception(Ice.LocalException ex) { // @@ -850,7 +851,7 @@ public class ServiceManagerI extends _ServiceManagerDisp { // ok, success } - + public void ice_exception(Ice.LocalException ex) { // @@ -874,8 +875,8 @@ public class ServiceManagerI extends _ServiceManagerDisp observerRemoved(observer, ex); } } - - private void + + private void observerRemoved(ServiceObserverPrx observer, RuntimeException ex) { if(_traceServiceObserver >= 1) @@ -883,14 +884,14 @@ public class ServiceManagerI extends _ServiceManagerDisp _logger.trace("IceBox.ServiceObserver", "Removed service observer " + _server.communicator().proxyToString(observer) + "\nafter catching " + ex.toString()); - } - } + } + } public final static int StatusStopping = 0; public final static int StatusStopped = 1; public final static int StatusStarting = 2; public final static int StatusStarted = 3; - + static class ServiceInfo implements Cloneable { public Object clone() @@ -919,19 +920,19 @@ public class ServiceManagerI extends _ServiceManagerDisp { _properties = properties; } - + public String getProperty(String name, Ice.Current current) { return _properties.getProperty(name); } - - public java.util.TreeMap + + public java.util.TreeMap<String, String> getPropertiesForPrefix(String name, Ice.Current current) { - return new java.util.TreeMap(_properties.getPropertiesForPrefix(name)); + return new java.util.TreeMap<String, String>(_properties.getPropertiesForPrefix(name)); } - + private final Ice.Properties _properties; } @@ -956,8 +957,8 @@ public class ServiceManagerI extends _ServiceManagerDisp } // - // Set the default program name for the service properties. By default it's - // the IceBox program name + "-" + the service name, or just the IceBox + // Set the default program name for the service properties. By default it's + // the IceBox program name + "-" + the service name, or just the IceBox // program name if we're creating the shared communicator (service == ""). // String programName = communicatorProperties.getProperty("Ice.ProgramName"); @@ -991,11 +992,11 @@ public class ServiceManagerI extends _ServiceManagerDisp // read the service config file if it's specified with --Ice.Config. // properties = Ice.Util.createProperties(args, properties); - + if(service.length() > 0) { // - // Next, parse the service "<service>.*" command line options (the Ice command + // Next, parse the service "<service>.*" command line options (the Ice command // line options were parsed by the createProperties above) // args.value = properties.parseCommandLineOptions(service, args.value); @@ -1003,7 +1004,7 @@ public class ServiceManagerI extends _ServiceManagerDisp } // - // Remaining command line options are passed to the communicator. This is + // Remaining command line options are passed to the communicator. This is // necessary for Ice plugin properties (e.g.: IceSSL). // Ice.InitializationData initData = new Ice.InitializationData(); diff --git a/java/src/IceGridGUI/Application/Node.java b/java/src/IceGridGUI/Application/Node.java index 86f11a8a817..35f0650e5e6 100755 --- a/java/src/IceGridGUI/Application/Node.java +++ b/java/src/IceGridGUI/Application/Node.java @@ -634,7 +634,7 @@ class Node extends TreeNode implements PropertySetParent PropertySet ps = (PropertySet)p.next(); if(ps.getEditable().isNew() || ps.getEditable().isModified()) { - update.propertySets.put(ps.getId(), ps.getDescriptor()); + update.propertySets.put(ps.getId(), (PropertySetDescriptor)ps.getDescriptor()); } } } @@ -663,11 +663,11 @@ class Node extends TreeNode implements PropertySetParent { if(server instanceof PlainServer) { - update.servers.add(server.getDescriptor()); + update.servers.add((ServerDescriptor)server.getDescriptor()); } else { - update.serverInstances.add(server.getDescriptor()); + update.serverInstances.add((ServerInstanceDescriptor)server.getDescriptor()); } } } diff --git a/java/src/IceInternal/BasicStream.java b/java/src/IceInternal/BasicStream.java index c24fcf490fe..c2a3084ba67 100644 --- a/java/src/IceInternal/BasicStream.java +++ b/java/src/IceInternal/BasicStream.java @@ -131,7 +131,7 @@ public class BasicStream other._seqDataStack = _seqDataStack; _seqDataStack = tmpSeqDataStack; - java.util.ArrayList tmpObjectList = other._objectList; + java.util.ArrayList<Ice.Object> tmpObjectList = other._objectList; other._objectList = _objectList; _objectList = tmpObjectList; @@ -590,7 +590,7 @@ public class BasicStream public void writeTypeId(String id) { - Integer index = (Integer)_writeEncapsStack.typeIdMap.get(id); + Integer index = _writeEncapsStack.typeIdMap.get(id); if(index != null) { writeBool(true); @@ -614,7 +614,7 @@ public class BasicStream if(isIndex) { index = new Integer(readSize()); - id = (String)_readEncapsStack.typeIdMap.get(index); + id = _readEncapsStack.typeIdMap.get(index); if(id == null) { throw new Ice.UnmarshalOutOfBoundsException(); @@ -1312,22 +1312,22 @@ public class BasicStream if(_writeEncapsStack.toBeMarshaledMap == null) // Lazy initialization { - _writeEncapsStack.toBeMarshaledMap = new java.util.IdentityHashMap(); - _writeEncapsStack.marshaledMap = new java.util.IdentityHashMap(); - _writeEncapsStack.typeIdMap = new java.util.TreeMap(); + _writeEncapsStack.toBeMarshaledMap = new java.util.IdentityHashMap<Ice.Object, Integer>(); + _writeEncapsStack.marshaledMap = new java.util.IdentityHashMap<Ice.Object, Integer>(); + _writeEncapsStack.typeIdMap = new java.util.TreeMap<String, Integer>(); } if(v != null) { // // Look for this instance in the to-be-marshaled map. // - Integer p = (Integer)_writeEncapsStack.toBeMarshaledMap.get(v); + Integer p = _writeEncapsStack.toBeMarshaledMap.get(v); if(p == null) { // // Didn't find it, try the marshaled map next. // - Integer q = (Integer)_writeEncapsStack.marshaledMap.get(v); + Integer q = _writeEncapsStack.marshaledMap.get(v); if(q == null) { // @@ -1368,9 +1368,9 @@ public class BasicStream if(_readEncapsStack.patchMap == null) // Lazy initialization { - _readEncapsStack.patchMap = new java.util.TreeMap(); - _readEncapsStack.unmarshaledMap = new java.util.TreeMap(); - _readEncapsStack.typeIdMap = new java.util.TreeMap(); + _readEncapsStack.patchMap = new java.util.TreeMap<Integer, java.util.LinkedList<Patcher> >(); + _readEncapsStack.unmarshaledMap = new java.util.TreeMap<Integer, Ice.Object>(); + _readEncapsStack.typeIdMap = new java.util.TreeMap<Integer, String>(); } int index = readInt(); @@ -1384,14 +1384,14 @@ public class BasicStream if(index < 0 && patcher != null) { Integer i = new Integer(-index); - java.util.LinkedList patchlist = (java.util.LinkedList)_readEncapsStack.patchMap.get(i); + java.util.LinkedList<Patcher> patchlist = _readEncapsStack.patchMap.get(i); if(patchlist == null) { // // We have no outstanding instances to be patched for // this index, so make a new entry in the patch map. // - patchlist = new java.util.LinkedList(); + patchlist = new java.util.LinkedList<Patcher>(); _readEncapsStack.patchMap.put(i, patchlist); } // @@ -1493,7 +1493,7 @@ public class BasicStream // if(_objectList == null) { - _objectList = new java.util.ArrayList(); + _objectList = new java.util.ArrayList<Ice.Object>(); } _objectList.add(v); @@ -1587,9 +1587,11 @@ public class BasicStream { while(_writeEncapsStack.toBeMarshaledMap.size() > 0) { - java.util.IdentityHashMap savedMap = new java.util.IdentityHashMap(_writeEncapsStack.toBeMarshaledMap); + java.util.IdentityHashMap<Ice.Object, Integer> savedMap = + new java.util.IdentityHashMap<Ice.Object, Integer>(_writeEncapsStack.toBeMarshaledMap); writeSize(savedMap.size()); - for(java.util.Iterator p = savedMap.entrySet().iterator(); p.hasNext(); ) + java.util.Iterator<java.util.Map.Entry<Ice.Object, Integer> > p = savedMap.entrySet().iterator(); + while(p.hasNext()) { // // Add an instance from the old to-be-marshaled @@ -1598,9 +1600,9 @@ public class BasicStream // instances that are triggered by the classes // marshaled are added to toBeMarshaledMap. // - java.util.Map.Entry e = (java.util.Map.Entry)p.next(); + java.util.Map.Entry<Ice.Object, Integer> e = p.next(); _writeEncapsStack.marshaledMap.put(e.getKey(), e.getValue()); - writeInstance((Ice.Object)e.getKey(), (Integer)e.getValue()); + writeInstance(e.getKey(), e.getValue()); } // @@ -1608,9 +1610,10 @@ public class BasicStream // substract what we have marshaled from the // toBeMarshaledMap. // - for(java.util.Iterator p = savedMap.keySet().iterator(); p.hasNext(); ) + java.util.Iterator<Ice.Object> q = savedMap.keySet().iterator(); + while(q.hasNext()) { - _writeEncapsStack.toBeMarshaledMap.remove(p.next()); + _writeEncapsStack.toBeMarshaledMap.remove(q.next()); } } } @@ -1639,10 +1642,10 @@ public class BasicStream // if(_objectList != null) { - java.util.Iterator e = _objectList.iterator(); + java.util.Iterator<Ice.Object> e = _objectList.iterator(); while(e.hasNext()) { - Ice.Object obj = (Ice.Object)e.next(); + Ice.Object obj = e.next(); try { obj.ice_postUnmarshal(); @@ -1703,7 +1706,7 @@ public class BasicStream // assert((instanceIndex != null && patchIndex == null) || (instanceIndex == null && patchIndex != null)); - java.util.LinkedList patchlist; + java.util.LinkedList<Patcher> patchlist; Ice.Object v; if(instanceIndex != null) { @@ -1711,12 +1714,12 @@ public class BasicStream // We have just unmarshaled an instance -- check if // something needs patching for that instance. // - patchlist = (java.util.LinkedList)_readEncapsStack.patchMap.get(instanceIndex); + patchlist = _readEncapsStack.patchMap.get(instanceIndex); if(patchlist == null) { return; // We don't have anything to patch for the instance just unmarshaled } - v = (Ice.Object)_readEncapsStack.unmarshaledMap.get(instanceIndex); + v = _readEncapsStack.unmarshaledMap.get(instanceIndex); patchIndex = instanceIndex; } else @@ -1725,12 +1728,12 @@ public class BasicStream // We have just unmarshaled an index -- check if we have // unmarshaled the instance for that index yet. // - v = (Ice.Object)_readEncapsStack.unmarshaledMap.get(patchIndex); + v = _readEncapsStack.unmarshaledMap.get(patchIndex); if(v == null) { return; // We haven't unmarshaled the instance for this index yet } - patchlist = (java.util.LinkedList)_readEncapsStack.patchMap.get(patchIndex); + patchlist = _readEncapsStack.patchMap.get(patchIndex); } assert(patchlist != null && patchlist.size() > 0); assert(v != null); @@ -1738,9 +1741,9 @@ public class BasicStream // // Patch all references that refer to the instance. // - for(java.util.Iterator i = patchlist.iterator(); i.hasNext(); ) + for(java.util.Iterator<Patcher> i = patchlist.iterator(); i.hasNext(); ) { - Patcher p = (Patcher)i.next(); + Patcher p = i.next(); try { p.patch(v); @@ -2150,7 +2153,7 @@ public class BasicStream synchronized(_factoryMutex) { - factory = (UserExceptionFactory)_exceptionFactories.get(id); + factory = _exceptionFactories.get(id); } if(factory == null) @@ -2326,10 +2329,10 @@ public class BasicStream byte encodingMajor; byte encodingMinor; - java.util.TreeMap patchMap; - java.util.TreeMap unmarshaledMap; + java.util.TreeMap<Integer, java.util.LinkedList<Patcher> > patchMap; + java.util.TreeMap<Integer, Ice.Object> unmarshaledMap; int typeIdIndex; - java.util.TreeMap typeIdMap; + java.util.TreeMap<Integer, String> typeIdMap; ReadEncaps next; void @@ -2350,10 +2353,10 @@ public class BasicStream int start; int writeIndex; - java.util.IdentityHashMap toBeMarshaledMap; - java.util.IdentityHashMap marshaledMap; + java.util.IdentityHashMap<Ice.Object, Integer> toBeMarshaledMap; + java.util.IdentityHashMap<Ice.Object, Integer> marshaledMap; int typeIdIndex; - java.util.TreeMap typeIdMap; + java.util.TreeMap<String, Integer> typeIdMap; WriteEncaps next; void @@ -2400,9 +2403,10 @@ public class BasicStream } SeqData _seqDataStack; - private java.util.ArrayList _objectList; + private java.util.ArrayList<Ice.Object> _objectList; - private static java.util.HashMap _exceptionFactories = new java.util.HashMap(); + private static java.util.HashMap<String, UserExceptionFactory> _exceptionFactories = + new java.util.HashMap<String, UserExceptionFactory>(); private static java.lang.Object _factoryMutex = new java.lang.Object(); // Protects _exceptionFactories. public static boolean @@ -2417,8 +2421,8 @@ public class BasicStream { try { - Class cls; - Class[] types = new Class[1]; + Class<?> cls; + Class<?>[] types = new Class<?>[1]; cls = Class.forName("org.apache.tools.bzip2.CBZip2InputStream"); types[0] = java.io.InputStream.class; _bzInputStreamCtor = cls.getDeclaredConstructor(types); diff --git a/java/src/IceInternal/ConnectRequestHandler.java b/java/src/IceInternal/ConnectRequestHandler.java index bebd060b41c..ab38043e5a0 100644 --- a/java/src/IceInternal/ConnectRequestHandler.java +++ b/java/src/IceInternal/ConnectRequestHandler.java @@ -183,7 +183,7 @@ public class ConnectRequestHandler } public Outgoing - getOutgoing(String operation, Ice.OperationMode mode, java.util.Map context) + getOutgoing(String operation, Ice.OperationMode mode, java.util.Map<String, String> context) throws LocalExceptionWrapper { synchronized(this) @@ -397,10 +397,10 @@ public class ConnectRequestHandler try { - java.util.Iterator p = _requests.iterator(); // _requests is immutable when _flushing = true + java.util.Iterator<Request> p = _requests.iterator(); // _requests is immutable when _flushing = true while(p.hasNext()) { - Request request = (Request)p.next(); + Request request = p.next(); if(request.out != null) { _connection.sendAsyncRequest(request.out, _compress, _response); @@ -493,10 +493,10 @@ public class ConnectRequestHandler void flushRequestsWithException(Ice.LocalException ex) { - java.util.Iterator p = _requests.iterator(); + java.util.Iterator<Request> p = _requests.iterator(); while(p.hasNext()) { - Request request = (Request)p.next(); + Request request = p.next(); if(request.out != null) { request.out.__finished(ex); @@ -512,10 +512,10 @@ public class ConnectRequestHandler void flushRequestsWithException(LocalExceptionWrapper ex) { - java.util.Iterator p = _requests.iterator(); + java.util.Iterator<Request> p = _requests.iterator(); while(p.hasNext()) { - Request request = (Request)p.next(); + Request request = p.next(); if(request.out != null) { request.out.__finished(ex); @@ -539,7 +539,7 @@ public class ConnectRequestHandler private boolean _response; private Ice.LocalException _exception = null; - private java.util.List _requests = new java.util.LinkedList(); + private java.util.List<Request> _requests = new java.util.LinkedList<Request>(); private boolean _batchRequestInProgress; private int _batchRequestsSize; private BasicStream _batchStream; diff --git a/java/src/IceInternal/ConnectionMonitor.java b/java/src/IceInternal/ConnectionMonitor.java index 9a08f9612e7..6483c5242af 100644 --- a/java/src/IceInternal/ConnectionMonitor.java +++ b/java/src/IceInternal/ConnectionMonitor.java @@ -61,7 +61,7 @@ public final class ConnectionMonitor implements IceInternal.TimerTask public void runTimerTask() { - java.util.HashSet connections = new java.util.HashSet(); + java.util.Set<Ice.ConnectionI> connections = new java.util.HashSet<Ice.ConnectionI>(); synchronized(this) { @@ -79,10 +79,10 @@ public final class ConnectionMonitor implements IceInternal.TimerTask // so that connections can be added or removed during // monitoring. // - java.util.Iterator iter = connections.iterator(); + java.util.Iterator<Ice.ConnectionI> iter = connections.iterator(); while(iter.hasNext()) { - Ice.ConnectionI connection = (Ice.ConnectionI)iter.next(); + Ice.ConnectionI connection = iter.next(); try { @@ -125,5 +125,5 @@ public final class ConnectionMonitor implements IceInternal.TimerTask } private Instance _instance; - private java.util.HashSet _connections = new java.util.HashSet(); + private java.util.Set<Ice.ConnectionI> _connections = new java.util.HashSet<Ice.ConnectionI>(); } diff --git a/java/src/IceInternal/ConnectionRequestHandler.java b/java/src/IceInternal/ConnectionRequestHandler.java index 3296e6c8b94..8b74c44b9f1 100644 --- a/java/src/IceInternal/ConnectionRequestHandler.java +++ b/java/src/IceInternal/ConnectionRequestHandler.java @@ -63,7 +63,7 @@ public class ConnectionRequestHandler implements RequestHandler } public Outgoing - getOutgoing(String operation, Ice.OperationMode mode, java.util.Map context) + getOutgoing(String operation, Ice.OperationMode mode, java.util.Map<String, String> context) throws LocalExceptionWrapper { return _connection.getOutgoing(this, operation, mode, context); diff --git a/java/src/IceInternal/DictionaryPatcher.java b/java/src/IceInternal/DictionaryPatcher.java index 67367acceca..545d474ca08 100644 --- a/java/src/IceInternal/DictionaryPatcher.java +++ b/java/src/IceInternal/DictionaryPatcher.java @@ -9,10 +9,10 @@ package IceInternal; -public class DictionaryPatcher implements Patcher, Ice.ReadObjectCallback +public class DictionaryPatcher<K, V> implements Patcher, Ice.ReadObjectCallback { public - DictionaryPatcher(java.util.Map dict, Class cls, String type, java.lang.Object key) + DictionaryPatcher(java.util.Map<K, V> dict, Class<V> cls, String type, K key) { _dict = dict; _cls = cls; @@ -35,7 +35,7 @@ public class DictionaryPatcher implements Patcher, Ice.ReadObjectCallback } } - _dict.put(_key, v); + _dict.put(_key, _cls.cast(v)); } public String @@ -50,8 +50,8 @@ public class DictionaryPatcher implements Patcher, Ice.ReadObjectCallback patch(v); } - private java.util.Map _dict; - private Class _cls; + private java.util.Map<K, V> _dict; + private Class<V> _cls; private String _type; - private java.lang.Object _key; + private K _key; } diff --git a/java/src/IceInternal/EndpointFactoryManager.java b/java/src/IceInternal/EndpointFactoryManager.java index ee8a957933b..f3663577f9b 100644 --- a/java/src/IceInternal/EndpointFactoryManager.java +++ b/java/src/IceInternal/EndpointFactoryManager.java @@ -21,7 +21,7 @@ public final class EndpointFactoryManager { for(int i = 0; i < _factories.size(); i++) { - EndpointFactory f = (EndpointFactory)_factories.get(i); + EndpointFactory f = _factories.get(i); if(f.type() == factory.type()) { assert(false); @@ -35,7 +35,7 @@ public final class EndpointFactoryManager { for(int i = 0; i < _factories.size(); i++) { - EndpointFactory f = (EndpointFactory)_factories.get(i); + EndpointFactory f = _factories.get(i); if(f.type() == type) { return f; @@ -69,7 +69,7 @@ public final class EndpointFactoryManager for(int i = 0; i < _factories.size(); i++) { - EndpointFactory f = (EndpointFactory)_factories.get(i); + EndpointFactory f = _factories.get(i); if(f.protocol().equals(protocol)) { return f.create(s.substring(m.end()), oaEndpoint); @@ -100,7 +100,7 @@ public final class EndpointFactoryManager EndpointI ue = new UnknownEndpointI(s.substring(m.end())); for(int i = 0; i < _factories.size(); i++) { - EndpointFactory f = (EndpointFactory)_factories.get(i); + EndpointFactory f = _factories.get(i); if(f.type() == ue.type()) { // @@ -130,7 +130,7 @@ public final class EndpointFactoryManager for(int i = 0; i < _factories.size(); i++) { - EndpointFactory f = (EndpointFactory)_factories.get(i); + EndpointFactory f = _factories.get(i); if(f.type() == type) { return f.read(s); @@ -144,12 +144,12 @@ public final class EndpointFactoryManager { for(int i = 0; i < _factories.size(); i++) { - EndpointFactory f = (EndpointFactory)_factories.get(i); + EndpointFactory f = _factories.get(i); f.destroy(); } _factories.clear(); } private Instance _instance; - private java.util.ArrayList _factories = new java.util.ArrayList(); + private java.util.List<EndpointFactory> _factories = new java.util.ArrayList<EndpointFactory>(); } diff --git a/java/src/IceInternal/EndpointHostResolver.java b/java/src/IceInternal/EndpointHostResolver.java index 97948959318..cc978401ec8 100644 --- a/java/src/IceInternal/EndpointHostResolver.java +++ b/java/src/IceInternal/EndpointHostResolver.java @@ -93,10 +93,10 @@ public class EndpointHostResolver Network.getAddresses(resolve.host, resolve.port, _instance.protocolSupport()))); } - java.util.Iterator p = _queue.iterator(); + java.util.Iterator<ResolveEntry> p = _queue.iterator(); while(p.hasNext()) { - ((ResolveEntry)p.next()).callback.exception(new Ice.CommunicatorDestroyedException()); + p.next().callback.exception(new Ice.CommunicatorDestroyedException()); } _queue.clear(); } @@ -111,7 +111,7 @@ public class EndpointHostResolver private final Instance _instance; private boolean _destroyed; - private java.util.LinkedList _queue = new java.util.LinkedList(); + private java.util.LinkedList<ResolveEntry> _queue = new java.util.LinkedList<ResolveEntry>(); private final class HelperThread extends Thread { diff --git a/java/src/IceInternal/EndpointI.java b/java/src/IceInternal/EndpointI.java index b58c616087f..fa5a44b9246 100644 --- a/java/src/IceInternal/EndpointI.java +++ b/java/src/IceInternal/EndpointI.java @@ -9,7 +9,7 @@ package IceInternal; -abstract public class EndpointI implements Ice.Endpoint, java.lang.Comparable +abstract public class EndpointI implements Ice.Endpoint, java.lang.Comparable<EndpointI> { public String toString() @@ -86,7 +86,7 @@ abstract public class EndpointI implements Ice.Endpoint, java.lang.Comparable // Return connectors for this endpoint, or empty list if no connector // is available. // - public abstract java.util.List connectors(); + public abstract java.util.List<Connector> connectors(); public abstract void connectors_async(EndpointI_connectors callback); // @@ -102,7 +102,7 @@ abstract public class EndpointI implements Ice.Endpoint, java.lang.Comparable // Expand endpoint out in to separate endpoints for each local // host if listening on INADDR_ANY. // - public abstract java.util.List expand(); + public abstract java.util.List<EndpointI> expand(); // // Check whether the endpoint is equivalent to another one. @@ -113,10 +113,10 @@ abstract public class EndpointI implements Ice.Endpoint, java.lang.Comparable // Compare endpoints for sorting purposes. // public abstract boolean equals(java.lang.Object obj); - public abstract int compareTo(java.lang.Object obj); // From java.lang.Comparable. + public abstract int compareTo(EndpointI obj); // From java.lang.Comparable. - public java.util.List - connectors(java.util.List addresses) + public java.util.List<Connector> + connectors(java.util.List<java.net.InetSocketAddress> addresses) { // // This method must be extended by endpoints which use the EndpointHostResolver to create diff --git a/java/src/IceInternal/EndpointI_connectors.java b/java/src/IceInternal/EndpointI_connectors.java index cba36c4c7a7..5621d128ecd 100644 --- a/java/src/IceInternal/EndpointI_connectors.java +++ b/java/src/IceInternal/EndpointI_connectors.java @@ -11,6 +11,6 @@ package IceInternal; public interface EndpointI_connectors { - void connectors(java.util.List connectors); + void connectors(java.util.List<Connector> connectors); void exception(Ice.LocalException ex); -}
\ No newline at end of file +} diff --git a/java/src/IceInternal/FixedReference.java b/java/src/IceInternal/FixedReference.java index 6fad0830513..376b42ed1e2 100644 --- a/java/src/IceInternal/FixedReference.java +++ b/java/src/IceInternal/FixedReference.java @@ -15,7 +15,7 @@ public class FixedReference extends Reference FixedReference(Instance instance, Ice.Communicator communicator, Ice.Identity identity, - java.util.Map context, + java.util.Map<String, String> context, String facet, int mode, boolean secure, diff --git a/java/src/IceInternal/Incoming.java b/java/src/IceInternal/Incoming.java index 72fdee73ace..439ccc8dd1d 100644 --- a/java/src/IceInternal/Incoming.java +++ b/java/src/IceInternal/Incoming.java @@ -94,7 +94,7 @@ final public class Incoming extends IncomingBase implements Ice.Request _current.operation = _is.readString(); _current.mode = Ice.OperationMode.convert(_is.readByte()); - _current.ctx = new java.util.HashMap(); + _current.ctx = new java.util.HashMap<String, String>(); int sz = _is.readSize(); while(sz-- > 0) { @@ -279,7 +279,7 @@ final public class Incoming extends IncomingBase implements Ice.Request { if(_interceptorAsyncCallbackList == null) { - _interceptorAsyncCallbackList = new java.util.LinkedList(); + _interceptorAsyncCallbackList = new java.util.LinkedList<Ice.DispatchInterceptorAsyncCallback>(); } _interceptorAsyncCallbackList.addFirst(cb); diff --git a/java/src/IceInternal/IncomingAsync.java b/java/src/IceInternal/IncomingAsync.java index dad81f32ac6..202922117a7 100644 --- a/java/src/IceInternal/IncomingAsync.java +++ b/java/src/IceInternal/IncomingAsync.java @@ -45,7 +45,6 @@ public class IncomingAsync extends IncomingBase in.adopt(this); } - final protected void __response(boolean ok) { @@ -59,10 +58,10 @@ public class IncomingAsync extends IncomingBase if(_response) { _os.endWriteEncaps(); - + int save = _os.pos(); _os.pos(Protocol.headerSize + 4); // Reply status position. - + if(ok) { _os.writeByte(ReplyStatus.replyOK); @@ -71,7 +70,7 @@ public class IncomingAsync extends IncomingBase { _os.writeByte(ReplyStatus.replyUserException); } - + _os.pos(save); _connection.sendResponse(_os, _compress); @@ -90,7 +89,7 @@ public class IncomingAsync extends IncomingBase final protected void __exception(java.lang.Exception exc) { - + try { if(!__servantLocatorFinished()) @@ -147,7 +146,7 @@ public class IncomingAsync extends IncomingBase } } - final protected boolean + final protected boolean __validateResponse(boolean ok) { if(!_retriable) @@ -177,10 +176,10 @@ public class IncomingAsync extends IncomingBase // // interceptorAsyncCallbackList is null or all its elements returned OK - // - + // + synchronized(this) - { + { if(_active) { _active = false; @@ -193,8 +192,7 @@ public class IncomingAsync extends IncomingBase } } - - final protected boolean + final protected boolean __validateException(java.lang.Exception exc) { if(!_retriable) @@ -206,10 +204,10 @@ public class IncomingAsync extends IncomingBase { if(_interceptorAsyncCallbackList != null) { - java.util.Iterator p = _interceptorAsyncCallbackList.iterator(); + java.util.Iterator<Ice.DispatchInterceptorAsyncCallback> p = _interceptorAsyncCallbackList.iterator(); while(p.hasNext()) { - Ice.DispatchInterceptorAsyncCallback cb = (Ice.DispatchInterceptorAsyncCallback)p.next(); + Ice.DispatchInterceptorAsyncCallback cb = p.next(); if(cb.exception(exc) == false) { return false; @@ -224,8 +222,8 @@ public class IncomingAsync extends IncomingBase // // interceptorAsyncCallbackList is null or all its elements returned OK - // - + // + synchronized(this) { if(_active) @@ -240,14 +238,12 @@ public class IncomingAsync extends IncomingBase } } - final protected BasicStream __os() { return _os; } - private final boolean _retriable; private boolean _active = false; // only meaningful when _retriable == true } diff --git a/java/src/IceInternal/IncomingBase.java b/java/src/IceInternal/IncomingBase.java index 6a152c07f83..c2d993f448d 100644 --- a/java/src/IceInternal/IncomingBase.java +++ b/java/src/IceInternal/IncomingBase.java @@ -43,7 +43,8 @@ public class IncomingBase // // Copy, not just reference // - _interceptorAsyncCallbackList = new java.util.LinkedList(in._interceptorAsyncCallbackList); + _interceptorAsyncCallbackList = + new java.util.LinkedList<Ice.DispatchInterceptorAsyncCallback>(in._interceptorAsyncCallbackList); } // @@ -375,5 +376,5 @@ public class IncomingBase protected Ice.ConnectionI _connection; - protected java.util.LinkedList _interceptorAsyncCallbackList; + protected java.util.LinkedList<Ice.DispatchInterceptorAsyncCallback> _interceptorAsyncCallbackList; } diff --git a/java/src/IceInternal/IncomingConnectionFactory.java b/java/src/IceInternal/IncomingConnectionFactory.java index 88e3d5d450c..4efcaf79318 100644 --- a/java/src/IceInternal/IncomingConnectionFactory.java +++ b/java/src/IceInternal/IncomingConnectionFactory.java @@ -32,7 +32,7 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice public void waitUntilHolding() { - java.util.LinkedList connections; + java.util.LinkedList<Ice.ConnectionI> connections; synchronized(this) { @@ -55,16 +55,16 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice // We want to wait until all connections are in holding state // outside the thread synchronization. // - connections = (java.util.LinkedList)_connections.clone(); + connections = new java.util.LinkedList<Ice.ConnectionI>(_connections); } // // Now we wait until each connection is in holding state. // - java.util.ListIterator p = connections.listIterator(); + java.util.ListIterator<Ice.ConnectionI> p = connections.listIterator(); while(p.hasNext()) { - Ice.ConnectionI connection = (Ice.ConnectionI)p.next(); + Ice.ConnectionI connection = p.next(); connection.waitUntilHolding(); } } @@ -73,7 +73,7 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice waitUntilFinished() { Thread threadPerIncomingConnectionFactory = null; - java.util.LinkedList connections = null; + java.util.LinkedList<Ice.ConnectionI> connections = null; synchronized(this) { @@ -106,7 +106,7 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice // if(_connections != null) { - connections = new java.util.LinkedList(_connections); + connections = new java.util.LinkedList<Ice.ConnectionI>(_connections); } } @@ -127,10 +127,10 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice if(connections != null) { - java.util.ListIterator p = connections.listIterator(); + java.util.ListIterator<Ice.ConnectionI> p = connections.listIterator(); while(p.hasNext()) { - Ice.ConnectionI connection = (Ice.ConnectionI)p.next(); + Ice.ConnectionI connection = p.next(); connection.waitUntilFinished(); } } @@ -153,18 +153,18 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice return _endpoint; } - public synchronized java.util.LinkedList + public synchronized java.util.LinkedList<Ice.ConnectionI> connections() { - java.util.LinkedList connections = new java.util.LinkedList(); + java.util.LinkedList<Ice.ConnectionI> connections = new java.util.LinkedList<Ice.ConnectionI>(); // // Only copy connections which have not been destroyed. // - java.util.ListIterator p = _connections.listIterator(); + java.util.ListIterator<Ice.ConnectionI> p = _connections.listIterator(); while(p.hasNext()) { - Ice.ConnectionI connection = (Ice.ConnectionI)p.next(); + Ice.ConnectionI connection = p.next(); if(connection.isActiveOrHolding()) { connections.add(connection); @@ -177,12 +177,13 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice public void flushBatchRequests() { - java.util.Iterator p = connections().iterator(); // connections() is synchronized, no need to synchronize here. + java.util.Iterator<Ice.ConnectionI> p = + connections().iterator(); // connections() is synchronized, no need to synchronize here. while(p.hasNext()) { try { - ((Ice.ConnectionI)p.next()).flushBatchRequests(); + p.next().flushBatchRequests(); } catch(Ice.LocalException ex) { @@ -245,10 +246,10 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice // // Reap connections for which destruction has completed. // - java.util.ListIterator p = _connections.listIterator(); + java.util.ListIterator<Ice.ConnectionI> p = _connections.listIterator(); while(p.hasNext()) { - Ice.ConnectionI con = (Ice.ConnectionI)p.next(); + Ice.ConnectionI con = p.next(); if(con.isFinished()) { p.remove(); @@ -560,10 +561,10 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice registerWithPool(); } - java.util.ListIterator p = _connections.listIterator(); + java.util.ListIterator<Ice.ConnectionI> p = _connections.listIterator(); while(p.hasNext()) { - Ice.ConnectionI connection = (Ice.ConnectionI)p.next(); + Ice.ConnectionI connection = p.next(); connection.activate(); } break; @@ -580,10 +581,10 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice unregisterWithPool(); } - java.util.ListIterator p = _connections.listIterator(); + java.util.ListIterator<Ice.ConnectionI> p = _connections.listIterator(); while(p.hasNext()) { - Ice.ConnectionI connection = (Ice.ConnectionI)p.next(); + Ice.ConnectionI connection = p.next(); connection.hold(); } break; @@ -614,10 +615,10 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice } } - java.util.ListIterator p = _connections.listIterator(); + java.util.ListIterator<Ice.ConnectionI> p = _connections.listIterator(); while(p.hasNext()) { - Ice.ConnectionI connection = (Ice.ConnectionI)p.next(); + Ice.ConnectionI connection = p.next(); connection.destroy(Ice.ConnectionI.ObjectAdapterDeactivated); } break; @@ -759,10 +760,10 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice // // Reap connections for which destruction has completed. // - java.util.ListIterator p = _connections.listIterator(); + java.util.ListIterator<Ice.ConnectionI> p = _connections.listIterator(); while(p.hasNext()) { - Ice.ConnectionI con = (Ice.ConnectionI)p.next(); + Ice.ConnectionI con = p.next(); if(con.isFinished()) { p.remove(); @@ -836,7 +837,7 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice private final boolean _warn; - private java.util.LinkedList _connections = new java.util.LinkedList(); + private java.util.List<Ice.ConnectionI> _connections = new java.util.LinkedList<Ice.ConnectionI>(); private int _state; diff --git a/java/src/IceInternal/Instance.java b/java/src/IceInternal/Instance.java index 307e7c001c0..b14f46db598 100644 --- a/java/src/IceInternal/Instance.java +++ b/java/src/IceInternal/Instance.java @@ -279,7 +279,7 @@ public final class Instance } public synchronized void - setDefaultContext(java.util.Map ctx) + setDefaultContext(java.util.Map<String, String> ctx) { if(_state == StateDestroyed) { @@ -292,11 +292,11 @@ public final class Instance } else { - _defaultContext = new java.util.HashMap(ctx); + _defaultContext = new java.util.HashMap<String, String>(ctx); } } - public synchronized java.util.Map + public synchronized java.util.Map<String, String> getDefaultContext() { if(_state == StateDestroyed) @@ -304,7 +304,7 @@ public final class Instance throw new Ice.CommunicatorDestroyedException(); } - return new java.util.HashMap(_defaultContext); + return new java.util.HashMap<String, String>(_defaultContext); } public Ice.ImplicitContextI @@ -400,15 +400,15 @@ public final class Instance // // Add all facets to OA // - java.util.Map filteredFacets = new java.util.HashMap(); - java.util.Iterator p = _adminFacets.entrySet().iterator(); + java.util.Map<String, Ice.Object> filteredFacets = new java.util.HashMap<String, Ice.Object>(); + java.util.Iterator<java.util.Map.Entry<String, Ice.Object> > p = _adminFacets.entrySet().iterator(); while(p.hasNext()) { - java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); + java.util.Map.Entry<String, Ice.Object> entry = p.next(); - if(_adminFacetFilter.isEmpty() || _adminFacetFilter.contains((String)entry.getKey())) + if(_adminFacetFilter.isEmpty() || _adminFacetFilter.contains(entry.getKey())) { - _adminAdapter.addFacet((Ice.Object)entry.getValue(), _adminIdentity, (String)entry.getKey()); + _adminAdapter.addFacet(entry.getValue(), _adminIdentity, entry.getKey()); } else { @@ -523,7 +523,7 @@ public final class Instance Ice.Object result = null; if(_adminAdapter == null || (!_adminFacetFilter.isEmpty() && !_adminFacetFilter.contains(facet))) { - result = (Ice.Object)_adminFacets.remove(facet); + result = _adminFacets.remove(facet); if(result == null) { @@ -1014,14 +1014,14 @@ public final class Instance if(_initData.properties.getPropertyAsInt("Ice.Warn.UnusedProperties") > 0) { - java.util.List unusedProperties = ((Ice.PropertiesI)_initData.properties).getUnusedProperties(); + java.util.List<String> unusedProperties = ((Ice.PropertiesI)_initData.properties).getUnusedProperties(); if(unusedProperties.size() != 0) { String message = "The following properties were set but never read:"; - java.util.Iterator p = unusedProperties.iterator(); + java.util.Iterator<String> p = unusedProperties.iterator(); while(p.hasNext()) { - message += "\n " + (String)p.next(); + message += "\n " + p.next(); } _initData.logger.warning(message); } @@ -1032,13 +1032,13 @@ public final class Instance validatePackages() { final String prefix = "Ice.Package."; - java.util.Map map = _initData.properties.getPropertiesForPrefix(prefix); - java.util.Iterator p = map.entrySet().iterator(); + java.util.Map<String, String> map = _initData.properties.getPropertiesForPrefix(prefix); + java.util.Iterator<java.util.Map.Entry<String, String> > p = map.entrySet().iterator(); while(p.hasNext()) { - java.util.Map.Entry e = (java.util.Map.Entry)p.next(); - String key = (String)e.getKey(); - String pkg = (String)e.getValue(); + java.util.Map.Entry<String, String> e = p.next(); + String key = e.getKey(); + String pkg = e.getValue(); if(key.length() == prefix.length()) { _initData.logger.warning("ignoring invalid property: " + key + "=" + pkg); @@ -1087,14 +1087,14 @@ public final class Instance private final boolean _background; private EndpointFactoryManager _endpointFactoryManager; private Ice.PluginManager _pluginManager; - private java.util.Map _defaultContext; + private java.util.Map<String, String> _defaultContext; private Ice.ObjectAdapter _adminAdapter; - private java.util.Map _adminFacets = new java.util.HashMap(); - private java.util.Set _adminFacetFilter = new java.util.HashSet(); + private java.util.Map<String, Ice.Object> _adminFacets = new java.util.HashMap<String, Ice.Object>(); + private java.util.Set<String> _adminFacetFilter = new java.util.HashSet<String>(); private Ice.Identity _adminIdentity; - private static java.util.Map _emptyContext = new java.util.HashMap(); + private static java.util.Map<String, String> _emptyContext = new java.util.HashMap<String, String>(); private static boolean _oneOffDone = false; } diff --git a/java/src/IceInternal/IntMap.java b/java/src/IceInternal/IntMap.java deleted file mode 100755 index eb2c0a5fa5e..00000000000 --- a/java/src/IceInternal/IntMap.java +++ /dev/null @@ -1,389 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -package IceInternal; - -public class IntMap -{ - public - IntMap(int initialCapacity, float loadFactor) - { - if(initialCapacity > MAXIMUM_CAPACITY) - { - initialCapacity = MAXIMUM_CAPACITY; - } - - // Find a power of 2 >= initialCapacity - int capacity = 1; - while(capacity < initialCapacity) - { - capacity <<= 1; - } - - _loadFactor = loadFactor; - _threshold = (int)(capacity * loadFactor); - _table = new Entry[capacity]; - } - - public - IntMap(int initialCapacity) - { - this(initialCapacity, DEFAULT_LOAD_FACTOR); - } - - public - IntMap() - { - _loadFactor = DEFAULT_LOAD_FACTOR; - _threshold = (int)(DEFAULT_INITIAL_CAPACITY); - _table = new Entry[DEFAULT_INITIAL_CAPACITY]; - } - - public int - size() - { - return _size; - } - - public boolean - isEmpty() - { - return _size == 0; - } - - public Object - get(int key) - { - int i = indexFor(key, _table.length); - Entry e = _table[i]; - while(true) - { - if(e == null) - { - return e; - } - if(key == e.key) - { - return e.value; - } - e = e.next; - } - } - - public boolean - containsKey(int key) - { - int i = indexFor(key, _table.length); - Entry e = _table[i]; - while(e != null) - { - if(key == e.key) - { - return true; - } - e = e.next; - } - return false; - } - - public Object - put(int key, Object value) - { - int i = indexFor(key, _table.length); - - for(Entry e = _table[i]; e != null; e = e.next) - { - if(key == e.key) - { - Object oldValue = e.value; - e.value = value; - return oldValue; - } - } - - _modCount++; - addEntry(key, value, i); - return null; - } - - public Object - remove(int key) - { - int i = indexFor(key, _table.length); - Entry prev = _table[i]; - Entry e = prev; - - while(e != null) - { - Entry next = e.next; - if(key == e.key) - { - _modCount++; - _size--; - if(prev == e) - { - _table[i] = next; - } - else - { - prev.next = next; - } - e.next = _entryCache; - _entryCache = e; - return e.value; - } - prev = e; - e = next; - } - - return (e == null ? e : e.value); - } - - public void - clear() - { - _modCount++; - Entry tab[] = _table; - for(int i = 0; i < tab.length; i++) - { - tab[i] = null; - } - _size = 0; - } - - public java.util.Iterator - entryIterator() - { - return new EntryIterator(); - } - - public static final class Entry - { - int key; - Object value; - Entry next; - - Entry(int k, Object v, Entry n) - { - key = k; - value = v; - next = n; - } - - public int - getKey() - { - return key; - } - - public Object - getValue() - { - return value; - } - - public Object - setValue(Object newValue) - { - Object oldValue = value; - value = newValue; - return oldValue; - } - } - - private static int - indexFor(int key, int length) - { - return key & (length - 1); - } - - private void - addEntry(int key, Object value, int bucketIndex) - { - Entry e; - if(_entryCache != null) - { - e = _entryCache; - _entryCache = _entryCache.next; - e.key = key; - e.value = value; - e.next = _table[bucketIndex]; - } - else - { - e = new Entry(key, value, _table[bucketIndex]); - } - _table[bucketIndex] = e; - if(_size++ >= _threshold) - { - resize(2 * _table.length); - } - } - - private void - resize(int newCapacity) - { - // assert (newCapacity & -newCapacity) == newCapacity; // power of 2 - Entry[] oldTable = _table; - int oldCapacity = oldTable.length; - - // check if needed - if(_size < _threshold || oldCapacity > newCapacity) - { - return; - } - - Entry[] newTable = new Entry[newCapacity]; - transfer(newTable); - _table = newTable; - _threshold = (int)(newCapacity * _loadFactor); - } - - private void - transfer(Entry[] newTable) - { - Entry[] src = _table; - int newCapacity = newTable.length; - for(int j = 0; j < src.length; j++) - { - Entry e = src[j]; - if(e != null) - { - src[j] = null; - do - { - Entry next = e.next; - int i = indexFor(e.key, newCapacity); - e.next = newTable[i]; - newTable[i] = e; - e = next; - } - while(e != null); - } - } - } - - private class EntryIterator implements java.util.Iterator - { - EntryIterator() - { - _expectedModCount = _modCount; - Entry[] t = _table; - int i = t.length; - Entry n = null; - if(_size != 0) // advance to first entry - { - while(i > 0 && (n = t[--i]) == null) - ; - } - _next = n; - _index = i; - } - - public boolean - hasNext() - { - return _next != null; - } - - public Object - next() - { - if(_modCount != _expectedModCount) - { - throw new java.util.ConcurrentModificationException(); - } - Entry e = _next; - if(e == null) - { - throw new java.util.NoSuchElementException(); - } - - Entry n = e.next; - Entry[] t = _table; - int i = _index; - while(n == null && i > 0) - { - n = t[--i]; - } - _index = i; - _next = n; - return _current = e; - } - - public void - remove() - { - if(_current == null) - { - throw new IllegalStateException(); - } - if(_modCount != _expectedModCount) - { - throw new java.util.ConcurrentModificationException(); - } - int k = _current.key; - _current = null; - IntMap.this.remove(k); - _expectedModCount = _modCount; - } - - private Entry _next; - private int _expectedModCount; - private int _index; - private Entry _current; - } - - // - // The default initial capacity - MUST be a power of two. - // - private static final int DEFAULT_INITIAL_CAPACITY = 16; - - // - // The maximum capacity, used if a higher value is implicitly specified - // by either of the constructors with arguments. - // MUST be a power of two <= 1<<30. - // - private static final int MAXIMUM_CAPACITY = 1 << 30; - - // - // The default load factor. - // - private static final float DEFAULT_LOAD_FACTOR = 0.75f; - - // - // The table, resized as necessary. Length MUST Always be a power of two. - // - private Entry[] _table; - - // - // The number of key-value mappings contained in this map. - // - private int _size; - - // - // The next size value at which to resize (capacity * load factor). - // - private int _threshold; - - // - // The load factor for the hash table. - // - private final float _loadFactor; - - // - // The number of times this map has been structurally modified - // Structural modifications are those that change the number of - // mappings in the map or otherwise modify its internal structure - // (e.g., rehash). This field is used to make iterators fail-fast. - // - private volatile int _modCount; - - private Entry _entryCache; -} diff --git a/java/src/IceInternal/ListPatcher.java b/java/src/IceInternal/ListPatcher.java index 37b8713b68b..6d1dfd16280 100644 --- a/java/src/IceInternal/ListPatcher.java +++ b/java/src/IceInternal/ListPatcher.java @@ -9,10 +9,10 @@ package IceInternal; -public class ListPatcher implements Patcher, Ice.ReadObjectCallback +public class ListPatcher<T> implements Patcher, Ice.ReadObjectCallback { public - ListPatcher(java.util.List list, Class cls, String type, int index) + ListPatcher(java.util.List<T> list, Class<T> cls, String type, int index) { _list = list; _cls = cls; @@ -40,7 +40,7 @@ public class ListPatcher implements Patcher, Ice.ReadObjectCallback // isn't much we can do about it as long as a new patcher instance is // created for each element. // - _list.set(_index, v); + _list.set(_index, _cls.cast(v)); } public String @@ -55,8 +55,8 @@ public class ListPatcher implements Patcher, Ice.ReadObjectCallback patch(v); } - private java.util.List _list; - private Class _cls; + private java.util.List<T> _list; + private Class<T> _cls; private String _type; private int _index; } diff --git a/java/src/IceInternal/LocatorManager.java b/java/src/IceInternal/LocatorManager.java index 72f9a54dada..d45d4bff34a 100644 --- a/java/src/IceInternal/LocatorManager.java +++ b/java/src/IceInternal/LocatorManager.java @@ -18,10 +18,10 @@ public final class LocatorManager synchronized void destroy() { - java.util.Iterator i = _table.values().iterator(); + java.util.Iterator<LocatorInfo> i = _table.values().iterator(); while(i.hasNext()) { - LocatorInfo info = (LocatorInfo)i.next(); + LocatorInfo info = i.next(); info.destroy(); } _table.clear(); @@ -51,7 +51,7 @@ public final class LocatorManager synchronized(this) { - LocatorInfo info = (LocatorInfo)_table.get(locator); + LocatorInfo info = _table.get(locator); if(info == null) { // @@ -59,7 +59,7 @@ public final class LocatorManager // have only one table per locator (not one per locator // proxy). // - LocatorTable table = (LocatorTable)_locatorTables.get(locator.ice_getIdentity()); + LocatorTable table = _locatorTables.get(locator.ice_getIdentity()); if(table == null) { table = new LocatorTable(); @@ -74,6 +74,8 @@ public final class LocatorManager } } - private java.util.HashMap _table = new java.util.HashMap(); - private java.util.HashMap _locatorTables = new java.util.HashMap(); + private java.util.HashMap<Ice.LocatorPrx, LocatorInfo> _table = + new java.util.HashMap<Ice.LocatorPrx, LocatorInfo>(); + private java.util.HashMap<Ice.Identity, LocatorTable> _locatorTables = + new java.util.HashMap<Ice.Identity, LocatorTable>(); } diff --git a/java/src/IceInternal/LocatorTable.java b/java/src/IceInternal/LocatorTable.java index 87bd5f4af0e..1e8568fe703 100644 --- a/java/src/IceInternal/LocatorTable.java +++ b/java/src/IceInternal/LocatorTable.java @@ -30,7 +30,7 @@ final class LocatorTable return null; } - EndpointTableEntry entry = (EndpointTableEntry)_adapterEndpointsTable.get(adapter); + EndpointTableEntry entry = _adapterEndpointsTable.get(adapter); if(entry != null && checkTTL(entry.time, ttl)) { return entry.endpoints; @@ -48,7 +48,7 @@ final class LocatorTable synchronized IceInternal.EndpointI[] removeAdapterEndpoints(String adapter) { - EndpointTableEntry entry = (EndpointTableEntry)_adapterEndpointsTable.remove(adapter); + EndpointTableEntry entry = _adapterEndpointsTable.remove(adapter); return entry != null ? entry.endpoints : null; } @@ -60,7 +60,7 @@ final class LocatorTable return null; } - ProxyTableEntry entry = (ProxyTableEntry)_objectTable.get(id); + ProxyTableEntry entry = _objectTable.get(id); if(entry != null && checkTTL(entry.time, ttl)) { return entry.proxy; @@ -77,7 +77,7 @@ final class LocatorTable synchronized Ice.ObjectPrx removeProxy(Ice.Identity id) { - ProxyTableEntry entry = (ProxyTableEntry)_objectTable.remove(id); + ProxyTableEntry entry = _objectTable.remove(id); return entry != null ? entry.proxy : null; } @@ -105,7 +105,7 @@ final class LocatorTable final public long time; final public IceInternal.EndpointI[] endpoints; - }; + } private static final class ProxyTableEntry { @@ -117,9 +117,10 @@ final class LocatorTable final public long time; final public Ice.ObjectPrx proxy; - }; + } - private java.util.HashMap _adapterEndpointsTable = new java.util.HashMap(); - private java.util.HashMap _objectTable = new java.util.HashMap(); + private java.util.Map<String, EndpointTableEntry> _adapterEndpointsTable = + new java.util.HashMap<String, EndpointTableEntry>(); + private java.util.Map<Ice.Identity, ProxyTableEntry> _objectTable = + new java.util.HashMap<Ice.Identity, ProxyTableEntry>(); } - diff --git a/java/src/IceInternal/Network.java b/java/src/IceInternal/Network.java index 07a86633166..84775bb76b7 100644 --- a/java/src/IceInternal/Network.java +++ b/java/src/IceInternal/Network.java @@ -833,11 +833,11 @@ public final class Network // Iterate over the network interfaces and pick an IP // address (preferably not the loopback address). // - java.util.ArrayList addrs = getLocalAddresses(protocol); - java.util.Iterator iter = addrs.iterator(); + java.util.ArrayList<java.net.InetAddress> addrs = getLocalAddresses(protocol); + java.util.Iterator<java.net.InetAddress> iter = addrs.iterator(); while(addr == null && iter.hasNext()) { - java.net.InetAddress a = (java.net.InetAddress)iter.next(); + java.net.InetAddress a = iter.next(); if(protocol == EnableBoth || (protocol == EnableIPv4 && a instanceof java.net.Inet4Address) || (protocol == EnableIPv6 && a instanceof java.net.Inet6Address)) @@ -856,10 +856,11 @@ public final class Network return addr; } - public static java.util.ArrayList + public static java.util.ArrayList<java.net.InetSocketAddress> getAddresses(String host, int port, int protocol) { - java.util.ArrayList addresses = new java.util.ArrayList(); + java.util.ArrayList<java.net.InetSocketAddress> addresses = + new java.util.ArrayList<java.net.InetSocketAddress>(); try { java.net.InetAddress[] addrs; @@ -902,20 +903,20 @@ public final class Network return addresses; } - public static java.util.ArrayList + public static java.util.ArrayList<java.net.InetAddress> getLocalAddresses(int protocol) { - java.util.ArrayList result = new java.util.ArrayList(); + java.util.ArrayList<java.net.InetAddress> result = new java.util.ArrayList<java.net.InetAddress>(); try { - java.util.Enumeration ifaces = java.net.NetworkInterface.getNetworkInterfaces(); + java.util.Enumeration<java.net.NetworkInterface> ifaces = java.net.NetworkInterface.getNetworkInterfaces(); while(ifaces.hasMoreElements()) { - java.net.NetworkInterface iface = (java.net.NetworkInterface)ifaces.nextElement(); - java.util.Enumeration addrs = iface.getInetAddresses(); + java.net.NetworkInterface iface = ifaces.nextElement(); + java.util.Enumeration<java.net.InetAddress> addrs = iface.getInetAddresses(); while(addrs.hasMoreElements()) { - java.net.InetAddress addr = (java.net.InetAddress)addrs.nextElement(); + java.net.InetAddress addr = addrs.nextElement(); if(!addr.isLoopbackAddress()) { if(protocol == EnableBoth || @@ -1003,7 +1004,7 @@ public final class Network return fds; } - public static java.util.ArrayList + public static java.util.ArrayList<String> getHostsForEndpointExpand(String host, int protocolSupport) { boolean wildcard = (host == null || host.length() == 0); @@ -1018,18 +1019,18 @@ public final class Network } } - java.util.ArrayList hosts = new java.util.ArrayList(); + java.util.ArrayList<String> hosts = new java.util.ArrayList<String>(); if(wildcard) { - java.util.ArrayList addrs = getLocalAddresses(protocolSupport); - java.util.Iterator p = addrs.iterator(); + java.util.ArrayList<java.net.InetAddress> addrs = getLocalAddresses(protocolSupport); + java.util.Iterator<java.net.InetAddress> p = addrs.iterator(); while(p.hasNext()) { // // NOTE: We don't publish link-local IPv6 addresses as these addresses can only // be accessed in general with a scope-id. // - java.net.InetAddress addr = (java.net.InetAddress)p.next(); + java.net.InetAddress addr = p.next(); if(!addr.isLinkLocalAddress()) { hosts.add(addr.getHostAddress()); diff --git a/java/src/IceInternal/ObjectAdapterFactory.java b/java/src/IceInternal/ObjectAdapterFactory.java index f611ecd42ae..9dd4779930f 100644 --- a/java/src/IceInternal/ObjectAdapterFactory.java +++ b/java/src/IceInternal/ObjectAdapterFactory.java @@ -14,7 +14,7 @@ public final class ObjectAdapterFactory public void shutdown() { - java.util.HashMap adapters; + java.util.Map<String, Ice.ObjectAdapterI> adapters; synchronized(this) { // @@ -40,10 +40,10 @@ public final class ObjectAdapterFactory // if(adapters != null) { - java.util.Iterator i = adapters.values().iterator(); + java.util.Iterator<Ice.ObjectAdapterI> i = adapters.values().iterator(); while(i.hasNext()) { - Ice.ObjectAdapter adapter = (Ice.ObjectAdapter)i.next(); + Ice.ObjectAdapter adapter = i.next(); adapter.deactivate(); } } @@ -52,7 +52,7 @@ public final class ObjectAdapterFactory public void waitForShutdown() { - java.util.HashMap adapters; + java.util.Map<String, Ice.ObjectAdapterI> adapters; synchronized(this) { // @@ -92,10 +92,10 @@ public final class ObjectAdapterFactory // if(adapters != null) { - java.util.Iterator i = adapters.values().iterator(); + java.util.Iterator<Ice.ObjectAdapterI> i = adapters.values().iterator(); while(i.hasNext()) { - Ice.ObjectAdapter adapter = (Ice.ObjectAdapter)i.next(); + Ice.ObjectAdapter adapter = i.next(); adapter.waitForDeactivate(); } } @@ -124,7 +124,7 @@ public final class ObjectAdapterFactory // waitForShutdown(); - java.util.HashMap adapters; + java.util.Map<String, Ice.ObjectAdapterI> adapters; synchronized(this) { adapters = _adapters; @@ -142,10 +142,10 @@ public final class ObjectAdapterFactory // if(adapters != null) { - java.util.Iterator i = adapters.values().iterator(); + java.util.Iterator<Ice.ObjectAdapterI> i = adapters.values().iterator(); while(i.hasNext()) { - Ice.ObjectAdapter adapter = (Ice.ObjectAdapter)i.next(); + Ice.ObjectAdapter adapter = i.next(); adapter.destroy(); } } @@ -159,7 +159,7 @@ public final class ObjectAdapterFactory throw new Ice.ObjectAdapterDeactivatedException(); } - Ice.ObjectAdapter adapter = (Ice.ObjectAdapter)_adapters.get(name); + Ice.ObjectAdapterI adapter = _adapters.get(name); if(adapter != null) { throw new Ice.AlreadyRegisteredException("object adapter", name); @@ -189,7 +189,7 @@ public final class ObjectAdapterFactory public Ice.ObjectAdapter findObjectAdapter(Ice.ObjectPrx proxy) { - java.util.ArrayList adapters; + java.util.List<Ice.ObjectAdapterI> adapters; synchronized(this) { if(_instance == null) @@ -197,15 +197,15 @@ public final class ObjectAdapterFactory return null; } - adapters = new java.util.ArrayList(_adapters.values()); + adapters = new java.util.ArrayList<Ice.ObjectAdapterI>(_adapters.values()); } - java.util.Iterator p = adapters.iterator(); + java.util.Iterator<Ice.ObjectAdapterI> p = adapters.iterator(); while(p.hasNext()) { try { - Ice.ObjectAdapterI adapter = (Ice.ObjectAdapterI)p.next(); + Ice.ObjectAdapterI adapter = p.next(); if(adapter.isLocal(proxy)) { return adapter; @@ -234,7 +234,7 @@ public final class ObjectAdapterFactory public void flushBatchRequests() { - java.util.ArrayList adapters; + java.util.List<Ice.ObjectAdapterI> adapters; synchronized(this) { if(_adapters == null) @@ -242,13 +242,13 @@ public final class ObjectAdapterFactory return; } - adapters = new java.util.ArrayList(_adapters.values()); + adapters = new java.util.ArrayList<Ice.ObjectAdapterI>(_adapters.values()); } - java.util.Iterator p = adapters.iterator(); + java.util.Iterator<Ice.ObjectAdapterI> p = adapters.iterator(); while(p.hasNext()) { - ((Ice.ObjectAdapterI)p.next()).flushBatchRequests(); + p.next().flushBatchRequests(); } } @@ -276,6 +276,6 @@ public final class ObjectAdapterFactory private Instance _instance; private Ice.Communicator _communicator; - private java.util.HashMap _adapters = new java.util.HashMap(); + private java.util.Map<String, Ice.ObjectAdapterI> _adapters = new java.util.HashMap<String, Ice.ObjectAdapterI>(); private boolean _waitForShutdown; } diff --git a/java/src/IceInternal/ObjectFactoryManager.java b/java/src/IceInternal/ObjectFactoryManager.java index f7ed4f3492c..7e50cc43f2c 100644 --- a/java/src/IceInternal/ObjectFactoryManager.java +++ b/java/src/IceInternal/ObjectFactoryManager.java @@ -28,12 +28,12 @@ public final class ObjectFactoryManager public void remove(String id) { - Object o = null; + Ice.ObjectFactory factory = null; synchronized(this) { - o = _factoryMap.get(id); - if(o == null) + factory = _factoryMap.get(id); + if(factory == null) { Ice.NotRegisteredException ex = new Ice.NotRegisteredException(); ex.id = id; @@ -43,13 +43,13 @@ public final class ObjectFactoryManager _factoryMap.remove(id); } - ((Ice.ObjectFactory)o).destroy(); + factory.destroy(); } public synchronized Ice.ObjectFactory find(String id) { - return (Ice.ObjectFactory)_factoryMap.get(id); + return _factoryMap.get(id); } // @@ -62,20 +62,21 @@ public final class ObjectFactoryManager void destroy() { - java.util.Map oldMap = null; + java.util.Map<String, Ice.ObjectFactory> oldMap = null; synchronized(this) { oldMap = _factoryMap; - _factoryMap = new java.util.HashMap(); + _factoryMap = new java.util.HashMap<String, Ice.ObjectFactory>(); } - java.util.Iterator i = oldMap.values().iterator(); + java.util.Iterator<Ice.ObjectFactory> i = oldMap.values().iterator(); while(i.hasNext()) { - Ice.ObjectFactory factory = (Ice.ObjectFactory)i.next(); + Ice.ObjectFactory factory = i.next(); factory.destroy(); } } - private java.util.HashMap _factoryMap = new java.util.HashMap(); + private java.util.Map<String, Ice.ObjectFactory> _factoryMap = + new java.util.HashMap<String, Ice.ObjectFactory>(); } diff --git a/java/src/IceInternal/Outgoing.java b/java/src/IceInternal/Outgoing.java index 89734a36c96..a454993f852 100644 --- a/java/src/IceInternal/Outgoing.java +++ b/java/src/IceInternal/Outgoing.java @@ -12,7 +12,7 @@ package IceInternal; public final class Outgoing implements OutgoingMessageCallback { public - Outgoing(RequestHandler handler, String operation, Ice.OperationMode mode, java.util.Map context) + Outgoing(RequestHandler handler, String operation, Ice.OperationMode mode, java.util.Map<String, String> context) throws LocalExceptionWrapper { _state = StateUnsent; @@ -30,7 +30,7 @@ public final class Outgoing implements OutgoingMessageCallback // These functions allow this object to be reused, rather than reallocated. // public void - reset(RequestHandler handler, String operation, Ice.OperationMode mode, java.util.Map context) + reset(RequestHandler handler, String operation, Ice.OperationMode mode, java.util.Map<String, String> context) throws LocalExceptionWrapper { _state = StateUnsent; @@ -449,7 +449,7 @@ public final class Outgoing implements OutgoingMessageCallback } private void - writeHeader(String operation, Ice.OperationMode mode, java.util.Map context) + writeHeader(String operation, Ice.OperationMode mode, java.util.Map<String, String> context) throws LocalExceptionWrapper { switch(_handler.getReference().getMode()) @@ -505,7 +505,7 @@ public final class Outgoing implements OutgoingMessageCallback // Implicit context // Ice.ImplicitContextI implicitContext = _handler.getReference().getInstance().getImplicitContext(); - java.util.Map prxContext = _handler.getReference().getContext(); + java.util.Map<String, String> prxContext = _handler.getReference().getContext(); if(implicitContext == null) { diff --git a/java/src/IceInternal/OutgoingAsync.java b/java/src/IceInternal/OutgoingAsync.java index 463a0643844..31bf5557462 100644 --- a/java/src/IceInternal/OutgoingAsync.java +++ b/java/src/IceInternal/OutgoingAsync.java @@ -18,8 +18,8 @@ public abstract class OutgoingAsync extends OutgoingAsyncMessageCallback { _sent = true; - if(!_proxy.ice_isTwoway()) - { + if(!_proxy.ice_isTwoway()) + { __release(); } else if(_response) @@ -31,14 +31,14 @@ public abstract class OutgoingAsync extends OutgoingAsyncMessageCallback assert(_timerTask == null); _timerTask = new TimerTask() { - public void - runTimerTask() - { - __runTimerTask(connection); - } - }; - _proxy.__reference().getInstance().timer().schedule(_timerTask, connection.timeout()); - } + public void + runTimerTask() + { + __runTimerTask(connection); + } + }; + _proxy.__reference().getInstance().timer().schedule(_timerTask, connection.timeout()); + } } } @@ -46,7 +46,7 @@ public abstract class OutgoingAsync extends OutgoingAsyncMessageCallback __finished(BasicStream is) { assert(_proxy.ice_isTwoway()); // Can only be called for twoways. - + byte replyStatus; try { @@ -59,7 +59,7 @@ public abstract class OutgoingAsync extends OutgoingAsyncMessageCallback { _timerTask = null; // Timer cancelled. } - + while(!_sent || _timerTask != null) { try @@ -193,9 +193,9 @@ public abstract class OutgoingAsync extends OutgoingAsyncMessageCallback __finished(ex); return; } - + assert(replyStatus == ReplyStatus.replyOK || replyStatus == ReplyStatus.replyUserException); - + try { __response(replyStatus == ReplyStatus.replyOK); @@ -219,7 +219,7 @@ public abstract class OutgoingAsync extends OutgoingAsyncMessageCallback { _timerTask = null; // Timer cancelled. } - + while(_timerTask != null) { try @@ -232,7 +232,7 @@ public abstract class OutgoingAsync extends OutgoingAsyncMessageCallback } } } - + // // NOTE: at this point, synchronization isn't needed, no other threads should be // calling on the callback. @@ -272,7 +272,7 @@ public abstract class OutgoingAsync extends OutgoingAsyncMessageCallback } protected final void - __prepare(Ice.ObjectPrx prx, String operation, Ice.OperationMode mode, java.util.Map context) + __prepare(Ice.ObjectPrx prx, String operation, Ice.OperationMode mode, java.util.Map<String, String> context) { assert(__os != null); @@ -280,7 +280,7 @@ public abstract class OutgoingAsync extends OutgoingAsyncMessageCallback _delegate = null; _cnt = 0; _mode = mode; - + // // Can't call async via a batch proxy. // @@ -288,13 +288,13 @@ public abstract class OutgoingAsync extends OutgoingAsyncMessageCallback { throw new Ice.FeatureNotSupportedException("can't send batch requests with AMI"); } - + __os.writeBlob(IceInternal.Protocol.requestHdr); - + Reference ref = _proxy.__reference(); ref.getIdentity().__write(__os); - + // // For compatibility with the old FacetPath. // @@ -308,11 +308,11 @@ public abstract class OutgoingAsync extends OutgoingAsyncMessageCallback String[] facetPath = { facet }; __os.writeStringSeq(facetPath); } - + __os.writeString(operation); - + __os.writeByte((byte)mode.value()); - + if(context != null) { // @@ -326,8 +326,8 @@ public abstract class OutgoingAsync extends OutgoingAsyncMessageCallback // Implicit context // Ice.ImplicitContextI implicitContext = ref.getInstance().getImplicitContext(); - java.util.Map prxContext = ref.getContext(); - + java.util.Map<String, String> prxContext = ref.getContext(); + if(implicitContext == null) { Ice.ContextHelper.write(__os, prxContext); @@ -337,7 +337,7 @@ public abstract class OutgoingAsync extends OutgoingAsyncMessageCallback implicitContext.write(prxContext, __os); } } - + __os.startWriteEncaps(); } @@ -367,7 +367,7 @@ public abstract class OutgoingAsync extends OutgoingAsyncMessageCallback protected abstract void __response(boolean ok); - protected void + protected void __throwUserException() throws Ice.UserException { @@ -407,20 +407,20 @@ public abstract class OutgoingAsync extends OutgoingAsyncMessageCallback // close connection message, the server guarantees that all outstanding requests // can safely be repeated. // - // An ObjectNotExistException can always be retried as well without violating + // An ObjectNotExistException can always be retried as well without violating // "at-most-once" (see the implementation of the checkRetryAfterException method of // the ProxyFactory class for the reasons why it can be useful). - // - if(!_sent || - exc instanceof Ice.CloseConnectionException || + // + if(!_sent || + exc instanceof Ice.CloseConnectionException || exc instanceof Ice.ObjectNotExistException) { throw exc; } - + // - // Throw the exception wrapped in a LocalExceptionWrapper, to indicate that the - // request cannot be resent without potentially violating the "at-most-once" + // Throw the exception wrapped in a LocalExceptionWrapper, to indicate that the + // request cannot be resent without potentially violating the "at-most-once" // principle. // throw new LocalExceptionWrapper(exc, false); @@ -448,7 +448,7 @@ public abstract class OutgoingAsync extends OutgoingAsyncMessageCallback synchronized(__monitor) { assert(_timerTask != null && _sent); // Can only be set once the request is sent. - + if(_response) // If the response was just received, don't close the connection. { connection = null; diff --git a/java/src/IceInternal/OutgoingConnectionFactory.java b/java/src/IceInternal/OutgoingConnectionFactory.java index 94f6bc1c078..fec7e825ab0 100644 --- a/java/src/IceInternal/OutgoingConnectionFactory.java +++ b/java/src/IceInternal/OutgoingConnectionFactory.java @@ -25,15 +25,15 @@ public final class OutgoingConnectionFactory return; } - java.util.Iterator p = _connections.values().iterator(); + java.util.Iterator<java.util.List<Ice.ConnectionI> > p = _connections.values().iterator(); while(p.hasNext()) { - java.util.LinkedList connectionList = (java.util.LinkedList)p.next(); + java.util.List<Ice.ConnectionI> connectionList = p.next(); - java.util.Iterator q = connectionList.iterator(); + java.util.Iterator<Ice.ConnectionI> q = connectionList.iterator(); while(q.hasNext()) { - Ice.ConnectionI connection = (Ice.ConnectionI)q.next(); + Ice.ConnectionI connection = q.next(); connection.destroy(Ice.ConnectionI.CommunicatorDestroyed); } } @@ -45,7 +45,7 @@ public final class OutgoingConnectionFactory public void waitUntilFinished() { - java.util.HashMap connections = null; + java.util.Map<ConnectorInfo, java.util.List<Ice.ConnectionI> > connections = null; synchronized(this) { @@ -72,22 +72,23 @@ public final class OutgoingConnectionFactory // if(_connections != null) { - connections = new java.util.HashMap(_connections); + connections = + new java.util.HashMap<ConnectorInfo, java.util.List<Ice.ConnectionI> >(_connections); } } // // Now we wait until the destruction of each connection is finished. // - java.util.Iterator p = connections.values().iterator(); + java.util.Iterator<java.util.List<Ice.ConnectionI> > p = connections.values().iterator(); while(p.hasNext()) { - java.util.LinkedList connectionList = (java.util.LinkedList)p.next(); + java.util.List<Ice.ConnectionI> connectionList = p.next(); - java.util.Iterator q = connectionList.iterator(); + java.util.Iterator<Ice.ConnectionI> q = connectionList.iterator(); while(q.hasNext()) { - Ice.ConnectionI connection = (Ice.ConnectionI)q.next(); + Ice.ConnectionI connection = q.next(); connection.waitUntilFinished(); } } @@ -113,7 +114,7 @@ public final class OutgoingConnectionFactory // // Apply the overrides. // - java.util.List endpoints = applyOverrides(endpts); + java.util.List<EndpointI> endpoints = applyOverrides(endpts); // // Try to find a connection to one of the given endpoints. @@ -130,18 +131,18 @@ public final class OutgoingConnectionFactory // If we didn't find a connection with the endpoints, we create the connectors // for the endpoints. // - java.util.ArrayList connectors = new java.util.ArrayList(); - java.util.Iterator p = endpoints.iterator(); + java.util.List<ConnectorInfo> connectors = new java.util.ArrayList<ConnectorInfo>(); + java.util.Iterator<EndpointI> p = endpoints.iterator(); while(p.hasNext()) { - EndpointI endpoint = (EndpointI)p.next(); + EndpointI endpoint = p.next(); // // Create connectors for the endpoint. // try { - java.util.List cons = endpoint.connectors(); + java.util.List<Connector> cons = endpoint.connectors(); assert(cons.size() > 0); // @@ -152,10 +153,10 @@ public final class OutgoingConnectionFactory java.util.Collections.shuffle(cons); } - java.util.Iterator q = cons.iterator(); + java.util.Iterator<Connector> q = cons.iterator(); while(q.hasNext()) { - connectors.add(new ConnectorInfo((Connector)q.next(), endpoint, tpc)); + connectors.add(new ConnectorInfo(q.next(), endpoint, tpc)); } } catch(Ice.LocalException ex) @@ -187,10 +188,10 @@ public final class OutgoingConnectionFactory // Try to establish the connection to the connectors. // DefaultsAndOverrides defaultsAndOverrides = _instance.defaultsAndOverrides(); - p = connectors.iterator(); - while(p.hasNext()) + java.util.Iterator<ConnectorInfo> q = connectors.iterator(); + while(q.hasNext()) { - ConnectorInfo ci = (ConnectorInfo)p.next(); + ConnectorInfo ci = q.next(); try { int timeout; @@ -260,7 +261,7 @@ public final class OutgoingConnectionFactory // // Apply the overrides. // - java.util.List endpoints = applyOverrides(endpts); + java.util.List<EndpointI> endpoints = applyOverrides(endpts); // // Try to find a connection to one of the given endpoints. @@ -327,15 +328,15 @@ public final class OutgoingConnectionFactory // endpoint = endpoint.compress(false); - java.util.Iterator p = _connections.values().iterator(); + java.util.Iterator<java.util.List<Ice.ConnectionI> > p = _connections.values().iterator(); while(p.hasNext()) { - java.util.LinkedList connectionList = (java.util.LinkedList)p.next(); - - java.util.Iterator q = connectionList.iterator(); + java.util.List<Ice.ConnectionI> connectionList = p.next(); + + java.util.Iterator<Ice.ConnectionI> q = connectionList.iterator(); while(q.hasNext()) { - Ice.ConnectionI connection = (Ice.ConnectionI)q.next(); + Ice.ConnectionI connection = q.next(); if(connection.endpoint() == endpoint) { try @@ -362,15 +363,15 @@ public final class OutgoingConnectionFactory return; } - java.util.Iterator p = _connections.values().iterator(); + java.util.Iterator<java.util.List<Ice.ConnectionI> > p = _connections.values().iterator(); while(p.hasNext()) { - java.util.LinkedList connectionList = (java.util.LinkedList)p.next(); + java.util.List<Ice.ConnectionI> connectionList = p.next(); - java.util.Iterator q = connectionList.iterator(); + java.util.Iterator<Ice.ConnectionI> q = connectionList.iterator(); while(q.hasNext()) { - Ice.ConnectionI connection = (Ice.ConnectionI)q.next(); + Ice.ConnectionI connection = q.next(); if(connection.getAdapter() == adapter) { try @@ -391,15 +392,15 @@ public final class OutgoingConnectionFactory public void flushBatchRequests() { - java.util.LinkedList c = new java.util.LinkedList(); + java.util.List<Ice.ConnectionI> c = new java.util.LinkedList<Ice.ConnectionI>(); synchronized(this) { - java.util.Iterator p = _connections.values().iterator(); + java.util.Iterator<java.util.List<Ice.ConnectionI> > p = _connections.values().iterator(); while(p.hasNext()) { - java.util.LinkedList connectionList = (java.util.LinkedList)p.next(); - java.util.Iterator q = connectionList.iterator(); + java.util.List<Ice.ConnectionI> connectionList = p.next(); + java.util.Iterator<Ice.ConnectionI> q = connectionList.iterator(); while(q.hasNext()) { c.add(q.next()); @@ -407,10 +408,10 @@ public final class OutgoingConnectionFactory } } - java.util.Iterator p = c.iterator(); + java.util.Iterator<Ice.ConnectionI> p = c.iterator(); while(p.hasNext()) { - Ice.ConnectionI conn = (Ice.ConnectionI)p.next(); + Ice.ConnectionI conn = p.next(); try { conn.flushBatchRequests(); @@ -444,11 +445,11 @@ public final class OutgoingConnectionFactory super.finalize(); } - private java.util.List + private java.util.List<EndpointI> applyOverrides(EndpointI[] endpts) { DefaultsAndOverrides defaultsAndOverrides = _instance.defaultsAndOverrides(); - java.util.ArrayList endpoints = new java.util.ArrayList(); + java.util.List<EndpointI> endpoints = new java.util.ArrayList<EndpointI>(); for(int i = 0; i < endpts.length; i++) { // @@ -468,7 +469,7 @@ public final class OutgoingConnectionFactory } synchronized private Ice.ConnectionI - findConnection(java.util.List endpoints, boolean tpc, Ice.BooleanHolder compress) + findConnection(java.util.List<EndpointI> endpoints, boolean tpc, Ice.BooleanHolder compress) { if(_destroyed) { @@ -478,20 +479,20 @@ public final class OutgoingConnectionFactory DefaultsAndOverrides defaultsAndOverrides = _instance.defaultsAndOverrides(); assert(!endpoints.isEmpty()); - java.util.Iterator p = endpoints.iterator(); + java.util.Iterator<EndpointI> p = endpoints.iterator(); while(p.hasNext()) { - EndpointI endpoint = (EndpointI)p.next(); - java.util.LinkedList connectionList = (java.util.LinkedList)_connectionsByEndpoint.get(endpoint); + EndpointI endpoint = p.next(); + java.util.List<Ice.ConnectionI> connectionList = _connectionsByEndpoint.get(endpoint); if(connectionList == null) { continue; } - java.util.Iterator q = connectionList.iterator(); + java.util.Iterator<Ice.ConnectionI> q = connectionList.iterator(); while(q.hasNext()) { - Ice.ConnectionI connection = (Ice.ConnectionI)q.next(); + Ice.ConnectionI connection = q.next(); if(connection.isActiveOrHolding() && connection.threadPerConnection() == tpc) // Don't return destroyed or un-validated connections { @@ -515,31 +516,31 @@ public final class OutgoingConnectionFactory // Must be called while synchronized. // private Ice.ConnectionI - findConnection(java.util.List connectors, Ice.BooleanHolder compress) + findConnection(java.util.List<ConnectorInfo> connectors, Ice.BooleanHolder compress) { DefaultsAndOverrides defaultsAndOverrides = _instance.defaultsAndOverrides(); - java.util.Iterator p = connectors.iterator(); + java.util.Iterator<ConnectorInfo> p = connectors.iterator(); while(p.hasNext()) { - ConnectorInfo ci = (ConnectorInfo)p.next(); - java.util.LinkedList connectionList = (java.util.LinkedList)_connections.get(ci); + ConnectorInfo ci = p.next(); + java.util.List<Ice.ConnectionI> connectionList = _connections.get(ci); if(connectionList == null) { continue; } - java.util.Iterator q = connectionList.iterator(); + java.util.Iterator<Ice.ConnectionI> q = connectionList.iterator(); while(q.hasNext()) { - Ice.ConnectionI connection = (Ice.ConnectionI)q.next(); + Ice.ConnectionI connection = q.next(); if(connection.isActiveOrHolding()) // Don't return destroyed or un-validated connections { if(!connection.endpoint().equals(ci.endpoint)) { - java.util.List conList = (java.util.LinkedList)_connectionsByEndpoint.get(ci.endpoint); + java.util.List<Ice.ConnectionI> conList = _connectionsByEndpoint.get(ci.endpoint); if(conList == null) { - conList = new java.util.LinkedList(); + conList = new java.util.LinkedList<Ice.ConnectionI>(); _connectionsByEndpoint.put(ci.endpoint, conList); } conList.add(connection); @@ -591,7 +592,7 @@ public final class OutgoingConnectionFactory } private Ice.ConnectionI - getConnection(java.util.List connectors, ConnectCallback cb, Ice.BooleanHolder compress) + getConnection(java.util.List<ConnectorInfo> connectors, ConnectCallback cb, Ice.BooleanHolder compress) { synchronized(this) { @@ -603,46 +604,50 @@ public final class OutgoingConnectionFactory // // Reap connections for which destruction has completed. // - java.util.Iterator p = _connections.values().iterator(); - while(p.hasNext()) { - java.util.LinkedList connectionList = (java.util.LinkedList)p.next(); - java.util.Iterator q = connectionList.iterator(); - while(q.hasNext()) + java.util.Iterator<java.util.List<Ice.ConnectionI> > p = _connections.values().iterator(); + while(p.hasNext()) { - Ice.ConnectionI con = (Ice.ConnectionI)q.next(); - if(con.isFinished()) + java.util.List<Ice.ConnectionI> connectionList = p.next(); + java.util.Iterator<Ice.ConnectionI> q = connectionList.iterator(); + while(q.hasNext()) { - q.remove(); + Ice.ConnectionI con = q.next(); + if(con.isFinished()) + { + q.remove(); + } + } + + if(connectionList.isEmpty()) + { + p.remove(); } - } - - if(connectionList.isEmpty()) - { - p.remove(); } } - p = _connectionsByEndpoint.values().iterator(); - while(p.hasNext()) { - java.util.LinkedList connectionList = (java.util.LinkedList)p.next(); - java.util.Iterator q = connectionList.iterator(); - while(q.hasNext()) + java.util.Iterator<java.util.List<Ice.ConnectionI> > p = _connectionsByEndpoint.values().iterator(); + while(p.hasNext()) { - Ice.ConnectionI con = (Ice.ConnectionI)q.next(); - if(con.isFinished()) + java.util.List<Ice.ConnectionI> connectionList = p.next(); + java.util.Iterator<Ice.ConnectionI> q = connectionList.iterator(); + while(q.hasNext()) { - q.remove(); + Ice.ConnectionI con = q.next(); + if(con.isFinished()) + { + q.remove(); + } + } + + if(connectionList.isEmpty()) + { + p.remove(); } - } - - if(connectionList.isEmpty()) - { - p.remove(); } } - + // // Try to get the connection. We may need to wait for other threads to // finish if one of them is currently establishing a connection to one @@ -664,10 +669,10 @@ public final class OutgoingConnectionFactory // connectors since we just found a connection and therefore don't need to // wait anymore for other pending connectors. // - p = connectors.iterator(); + java.util.Iterator<ConnectorInfo> p = connectors.iterator(); while(p.hasNext()) { - java.util.Set cbs = (java.util.Set)_pending.get(p.next()); + java.util.Set<ConnectCallback> cbs = _pending.get(p.next()); if(cbs != null) { cbs.remove(cb); @@ -681,11 +686,11 @@ public final class OutgoingConnectionFactory // Determine whether another thread is currently attempting to connect to one of our endpoints; // if so we wait until it's done. // - p = connectors.iterator(); + java.util.Iterator<ConnectorInfo> p = connectors.iterator(); boolean found = false; while(p.hasNext()) { - java.util.Set cbs = (java.util.Set)_pending.get(p.next()); + java.util.Set<ConnectCallback> cbs = _pending.get(p.next()); if(cbs != null) { found = true; @@ -740,13 +745,13 @@ public final class OutgoingConnectionFactory // the _pending set to indicate that we're attempting connection establishment to // these connectors. We might attempt to connect to the same connector multiple times. // - p = connectors.iterator(); + java.util.Iterator<ConnectorInfo> p = connectors.iterator(); while(p.hasNext()) { - Object obj = p.next(); + ConnectorInfo obj = p.next(); if(!_pending.containsKey(obj)) { - _pending.put(obj, new java.util.HashSet()); + _pending.put(obj, new java.util.HashSet<ConnectCallback>()); } } } @@ -785,17 +790,17 @@ public final class OutgoingConnectionFactory Ice.ConnectionI connection = new Ice.ConnectionI(_instance, transceiver, ci.endpoint.compress(false), null, ci.threadPerConnection); - java.util.LinkedList connectionList = (java.util.LinkedList)_connections.get(ci); + java.util.List<Ice.ConnectionI> connectionList = _connections.get(ci); if(connectionList == null) { - connectionList = new java.util.LinkedList(); + connectionList = new java.util.LinkedList<Ice.ConnectionI>(); _connections.put(ci, connectionList); } connectionList.add(connection); - connectionList = (java.util.LinkedList)_connectionsByEndpoint.get(ci.endpoint); + connectionList = _connectionsByEndpoint.get(ci.endpoint); if(connectionList == null) { - connectionList = new java.util.LinkedList(); + connectionList = new java.util.LinkedList<Ice.ConnectionI>(); _connectionsByEndpoint.put(ci.endpoint, connectionList); } connectionList.add(connection); @@ -816,9 +821,9 @@ public final class OutgoingConnectionFactory } private void - finishGetConnection(java.util.List connectors, ConnectCallback cb, Ice.ConnectionI connection) + finishGetConnection(java.util.List<ConnectorInfo> connectors, ConnectCallback cb, Ice.ConnectionI connection) { - java.util.Set callbacks = new java.util.HashSet(); + java.util.Set<ConnectCallback> callbacks = new java.util.HashSet<ConnectCallback>(); synchronized(this) { @@ -828,10 +833,10 @@ public final class OutgoingConnectionFactory // notify the pending connect callbacks (outside the synchronization). // - java.util.Iterator p = connectors.iterator(); + java.util.Iterator<ConnectorInfo> p = connectors.iterator(); while(p.hasNext()) { - java.util.Set cbs = (java.util.Set)_pending.remove(p.next()); + java.util.Set<ConnectCallback> cbs = _pending.remove(p.next()); if(cbs != null) { callbacks.addAll(cbs); @@ -852,10 +857,10 @@ public final class OutgoingConnectionFactory // // Notify any waiting callbacks. // - java.util.Iterator p = callbacks.iterator(); + java.util.Iterator<ConnectCallback> p = callbacks.iterator(); while(p.hasNext()) { - ((ConnectCallback)p.next()).getConnection(); + p.next().getConnection(); } } @@ -899,7 +904,7 @@ public final class OutgoingConnectionFactory // synchronized(this) { - java.util.LinkedList connectionList = (java.util.LinkedList)_connections.get(ci); + java.util.List<Ice.ConnectionI> connectionList = _connections.get(ci); if(connectionList != null) // It might have already been reaped! { connectionList.remove(connection); @@ -909,7 +914,7 @@ public final class OutgoingConnectionFactory } } - connectionList = (java.util.LinkedList)_connectionsByEndpoint.get(ci.endpoint); + connectionList = _connectionsByEndpoint.get(ci.endpoint); if(connectionList != null) // It might have already been reaped! { connectionList.remove(connection); @@ -983,7 +988,7 @@ public final class OutgoingConnectionFactory private static class ConnectCallback implements Ice.ConnectionI.StartCallback, EndpointI_connectors { - ConnectCallback(OutgoingConnectionFactory f, java.util.List endpoints, boolean more, + ConnectCallback(OutgoingConnectionFactory f, java.util.List<EndpointI> endpoints, boolean more, CreateConnectionCallback cb, Ice.EndpointSelectionType selType, boolean threadPerConnection) { _factory = f; @@ -1045,7 +1050,7 @@ public final class OutgoingConnectionFactory // Methods from EndpointI_connectors // public void - connectors(java.util.List cons) + connectors(java.util.List<Connector> cons) { // // Shuffle connectors if endpoint selection type is Random. @@ -1055,10 +1060,10 @@ public final class OutgoingConnectionFactory java.util.Collections.shuffle(cons); } - java.util.Iterator q = cons.iterator(); + java.util.Iterator<Connector> q = cons.iterator(); while(q.hasNext()) { - _connectors.add(new ConnectorInfo((Connector)q.next(), _currentEndpoint, _threadPerConnection)); + _connectors.add(new ConnectorInfo(q.next(), _currentEndpoint, _threadPerConnection)); } if(_endpointsIter.hasNext()) @@ -1129,7 +1134,7 @@ public final class OutgoingConnectionFactory try { assert(_endpointsIter.hasNext()); - _currentEndpoint = (EndpointI)_endpointsIter.next(); + _currentEndpoint = _endpointsIter.next(); _currentEndpoint.connectors_async(this); } catch(Ice.LocalException ex) @@ -1177,7 +1182,7 @@ public final class OutgoingConnectionFactory try { assert(_iter.hasNext()); - _current = (ConnectorInfo)_iter.next(); + _current = _iter.next(); connection = _factory.createConnection(_current.connector.connect(0), _current); connection.start(this); } @@ -1190,21 +1195,24 @@ public final class OutgoingConnectionFactory private final OutgoingConnectionFactory _factory; private final boolean _hasMore; private final CreateConnectionCallback _callback; - private final java.util.List _endpoints; + private final java.util.List<EndpointI> _endpoints; private final Ice.EndpointSelectionType _selType; private final boolean _threadPerConnection; - private java.util.Iterator _endpointsIter; + private java.util.Iterator<EndpointI> _endpointsIter; private EndpointI _currentEndpoint; - private java.util.List _connectors = new java.util.ArrayList(); - private java.util.Iterator _iter; + private java.util.List<ConnectorInfo> _connectors = new java.util.ArrayList<ConnectorInfo>(); + private java.util.Iterator<ConnectorInfo> _iter; private ConnectorInfo _current; } private final Instance _instance; private boolean _destroyed; - private java.util.HashMap _connections = new java.util.HashMap(); - private java.util.HashMap _connectionsByEndpoint = new java.util.HashMap(); - private java.util.HashMap _pending = new java.util.HashMap(); + private java.util.Map<ConnectorInfo, java.util.List<Ice.ConnectionI> > _connections = + new java.util.HashMap<ConnectorInfo, java.util.List<Ice.ConnectionI> >(); + private java.util.Map<EndpointI, java.util.List<Ice.ConnectionI> > _connectionsByEndpoint = + new java.util.HashMap<EndpointI, java.util.List<Ice.ConnectionI> >(); + private java.util.Map<ConnectorInfo, java.util.HashSet<ConnectCallback> > _pending = + new java.util.HashMap<ConnectorInfo, java.util.HashSet<ConnectCallback> >(); private int _pendingConnectCount = 0; } diff --git a/java/src/IceInternal/PropertiesAdminI.java b/java/src/IceInternal/PropertiesAdminI.java index 950cf6e54f7..094c9eaf6ee 100644 --- a/java/src/IceInternal/PropertiesAdminI.java +++ b/java/src/IceInternal/PropertiesAdminI.java @@ -22,10 +22,10 @@ class PropertiesAdminI extends Ice._PropertiesAdminDisp return _properties.getProperty(name); } - public java.util.TreeMap + public java.util.TreeMap<String, String> getPropertiesForPrefix(String name, Ice.Current current) { - return new java.util.TreeMap(_properties.getPropertiesForPrefix(name)); + return new java.util.TreeMap<String, String>(_properties.getPropertiesForPrefix(name)); } private final Ice.Properties _properties; diff --git a/java/src/IceInternal/Reference.java b/java/src/IceInternal/Reference.java index 12723c2fd55..26253b67daf 100644 --- a/java/src/IceInternal/Reference.java +++ b/java/src/IceInternal/Reference.java @@ -54,7 +54,7 @@ public abstract class Reference implements Cloneable return _instance; } - public final java.util.Map + public final java.util.Map<String, String> getContext() { return _context; @@ -92,7 +92,7 @@ public abstract class Reference implements Cloneable // corresponding value changed. // public final Reference - changeContext(java.util.Map newContext) + changeContext(java.util.Map<String, String> newContext) { if(newContext == null) { @@ -105,7 +105,7 @@ public abstract class Reference implements Cloneable } else { - r._context = new java.util.HashMap(newContext); + r._context = new java.util.HashMap<String, String>(newContext); } return r; } @@ -423,7 +423,7 @@ public abstract class Reference implements Cloneable protected int _hashValue; protected boolean _hashInitialized; - private static java.util.HashMap _emptyContext = new java.util.HashMap(); + private static java.util.Map<String, String> _emptyContext = new java.util.HashMap<String, String>(); final private Instance _instance; final private Ice.Communicator _communicator; @@ -431,7 +431,7 @@ public abstract class Reference implements Cloneable private int _mode; private boolean _secure; private Ice.Identity _identity; - private java.util.Map _context; + private java.util.Map<String, String> _context; private String _facet; protected boolean _overrideCompress; protected boolean _compress; // Only used if _overrideCompress == true @@ -440,7 +440,7 @@ public abstract class Reference implements Cloneable Reference(Instance instance, Ice.Communicator communicator, Ice.Identity identity, - java.util.Map context, + java.util.Map<String, String> context, String facet, int mode, boolean secure) diff --git a/java/src/IceInternal/ReferenceFactory.java b/java/src/IceInternal/ReferenceFactory.java index 958f82e34a8..2e5ed274c90 100644 --- a/java/src/IceInternal/ReferenceFactory.java +++ b/java/src/IceInternal/ReferenceFactory.java @@ -345,11 +345,11 @@ public final class ReferenceFactory return create(ident, facet, mode, secure, null, null, propertyPrefix); } - java.util.ArrayList endpoints = new java.util.ArrayList(); + java.util.ArrayList<EndpointI> endpoints = new java.util.ArrayList<EndpointI>(); if(s.charAt(beg) == ':') { - java.util.ArrayList unknownEndpoints = new java.util.ArrayList(); + java.util.ArrayList<String> unknownEndpoints = new java.util.ArrayList<String>(); end = beg; while(end < s.length() && s.charAt(end) == ':') @@ -413,17 +413,17 @@ public final class ReferenceFactory if(endpoints.size() == 0) { Ice.EndpointParseException e = new Ice.EndpointParseException(); - e.str = (String)unknownEndpoints.get(0); + e.str = unknownEndpoints.get(0); throw e; } else if(unknownEndpoints.size() != 0 && _instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Endpoints", 1) > 0) { String msg = "Proxy contains unknown endpoints:"; - java.util.Iterator iter = unknownEndpoints.iterator(); + java.util.Iterator<String> iter = unknownEndpoints.iterator(); while(iter.hasNext()) { - msg += " `" + (String)iter.next() + "'"; + msg += " `" + iter.next() + "'"; } _instance.initializationData().logger.warning(msg); } @@ -618,22 +618,22 @@ public final class ReferenceFactory // WeakHashMap class internally creates a weak reference for the // key, and we use a weak reference for the value as well. // - java.lang.ref.WeakReference w = (java.lang.ref.WeakReference)_references.get(ref); + java.lang.ref.WeakReference<Reference> w = _references.get(ref); if(w != null) { - Reference r = (Reference)w.get(); + Reference r = w.get(); if(r != null) { ref = r; } else { - _references.put(ref, new java.lang.ref.WeakReference(ref)); + _references.put(ref, new java.lang.ref.WeakReference<Reference>(ref)); } } else { - _references.put(ref, new java.lang.ref.WeakReference(ref)); + _references.put(ref, new java.lang.ref.WeakReference<Reference>(ref)); } return ref; @@ -665,13 +665,14 @@ public final class ReferenceFactory } } - java.util.ArrayList unknownProps = new java.util.ArrayList(); - java.util.Map props = _instance.initializationData().properties.getPropertiesForPrefix(prefix + "."); - java.util.Iterator p = props.entrySet().iterator(); + java.util.ArrayList<String> unknownProps = new java.util.ArrayList<String>(); + java.util.Map<String, String> props = + _instance.initializationData().properties.getPropertiesForPrefix(prefix + "."); + java.util.Iterator<java.util.Map.Entry<String, String> > p = props.entrySet().iterator(); while(p.hasNext()) { - java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); - String prop = (String)entry.getKey(); + java.util.Map.Entry<String, String> entry = p.next(); + String prop = entry.getKey(); boolean valid = false; for(int i = 0; i < _suffixes.length; ++i) @@ -692,10 +693,10 @@ public final class ReferenceFactory if(unknownProps.size() != 0) { String message = "found unknown properties for proxy '" + prefix + "':"; - p = unknownProps.iterator(); - while(p.hasNext()) + java.util.Iterator<String> q = unknownProps.iterator(); + while(q.hasNext()) { - message += "\n " + (String)p.next(); + message += "\n " + q.next(); } _instance.initializationData().logger.warning(message); } @@ -819,5 +820,6 @@ public final class ReferenceFactory final private Ice.Communicator _communicator; private Ice.RouterPrx _defaultRouter; private Ice.LocatorPrx _defaultLocator; - private java.util.WeakHashMap _references = new java.util.WeakHashMap(); + private java.util.WeakHashMap<Reference, java.lang.ref.WeakReference<Reference> > _references = + new java.util.WeakHashMap<Reference, java.lang.ref.WeakReference<Reference> >(); } diff --git a/java/src/IceInternal/RequestHandler.java b/java/src/IceInternal/RequestHandler.java index 61ca7daede6..2daa83c2325 100644 --- a/java/src/IceInternal/RequestHandler.java +++ b/java/src/IceInternal/RequestHandler.java @@ -28,7 +28,7 @@ public interface RequestHandler Ice.ConnectionI getConnection(boolean wait); - Outgoing getOutgoing(String operation, Ice.OperationMode mode, java.util.Map context) + Outgoing getOutgoing(String operation, Ice.OperationMode mode, java.util.Map<String, String> context) throws LocalExceptionWrapper; void reclaimOutgoing(Outgoing out); diff --git a/java/src/IceInternal/RoutableReference.java b/java/src/IceInternal/RoutableReference.java index 996611d0dd4..6bf1640750e 100644 --- a/java/src/IceInternal/RoutableReference.java +++ b/java/src/IceInternal/RoutableReference.java @@ -609,7 +609,7 @@ public class RoutableReference extends Reference RoutableReference(Instance instance, Ice.Communicator communicator, Ice.Identity identity, - java.util.Map context, + java.util.Map<String, String> context, String facet, int mode, boolean secure, @@ -672,7 +672,7 @@ public class RoutableReference extends Reference private EndpointI[] filterEndpoints(EndpointI[] allEndpoints) { - java.util.ArrayList endpoints = new java.util.ArrayList(); + java.util.List<EndpointI> endpoints = new java.util.ArrayList<EndpointI>(); // // Filter out unknown endpoints. @@ -697,10 +697,10 @@ public class RoutableReference extends Reference // // Filter out datagram endpoints. // - java.util.Iterator i = endpoints.iterator(); + java.util.Iterator<EndpointI> i = endpoints.iterator(); while(i.hasNext()) { - EndpointI endpoint = (EndpointI)i.next(); + EndpointI endpoint = i.next(); if(endpoint.datagram()) { i.remove(); @@ -715,10 +715,10 @@ public class RoutableReference extends Reference // // Filter out non-datagram endpoints. // - java.util.Iterator i = endpoints.iterator(); + java.util.Iterator<EndpointI> i = endpoints.iterator(); while(i.hasNext()) { - EndpointI endpoint = (EndpointI)i.next(); + EndpointI endpoint = i.next(); if(!endpoint.datagram()) { i.remove(); @@ -759,10 +759,10 @@ public class RoutableReference extends Reference DefaultsAndOverrides overrides = getInstance().defaultsAndOverrides(); if(overrides.overrideSecure ? overrides.overrideSecureValue : getSecure()) { - java.util.Iterator i = endpoints.iterator(); + java.util.Iterator<EndpointI> i = endpoints.iterator(); while(i.hasNext()) { - EndpointI endpoint = (EndpointI)i.next(); + EndpointI endpoint = i.next(); if(!endpoint.secure()) { i.remove(); @@ -951,7 +951,7 @@ public class RoutableReference extends Reference } } - static class EndpointComparator implements java.util.Comparator + static class EndpointComparator implements java.util.Comparator<EndpointI> { EndpointComparator(boolean preferSecure) { @@ -959,10 +959,8 @@ public class RoutableReference extends Reference } public int - compare(java.lang.Object l, java.lang.Object r) + compare(EndpointI le, EndpointI re) { - IceInternal.EndpointI le = (IceInternal.EndpointI)l; - IceInternal.EndpointI re = (IceInternal.EndpointI)r; boolean ls = le.secure(); boolean rs = re.secure(); if((ls && rs) || (!ls && !rs)) diff --git a/java/src/IceInternal/RouterInfo.java b/java/src/IceInternal/RouterInfo.java index 0029a4d45f3..b266d65b1c0 100644 --- a/java/src/IceInternal/RouterInfo.java +++ b/java/src/IceInternal/RouterInfo.java @@ -281,6 +281,6 @@ public final class RouterInfo private EndpointI[] _clientEndpoints; private EndpointI[] _serverEndpoints; private Ice.ObjectAdapter _adapter; - private java.util.HashSet _identities = new java.util.HashSet(); - private java.util.List _evictedIdentities = new java.util.ArrayList(); + private java.util.Set<Ice.Identity> _identities = new java.util.HashSet<Ice.Identity>(); + private java.util.List<Ice.Identity> _evictedIdentities = new java.util.ArrayList<Ice.Identity>(); } diff --git a/java/src/IceInternal/RouterManager.java b/java/src/IceInternal/RouterManager.java index b853684ff55..05e25147c2e 100644 --- a/java/src/IceInternal/RouterManager.java +++ b/java/src/IceInternal/RouterManager.java @@ -18,10 +18,10 @@ public final class RouterManager synchronized void destroy() { - java.util.Iterator i = _table.values().iterator(); + java.util.Iterator<RouterInfo> i = _table.values().iterator(); while(i.hasNext()) { - RouterInfo info = (RouterInfo)i.next(); + RouterInfo info = i.next(); info.destroy(); } _table.clear(); @@ -46,7 +46,7 @@ public final class RouterManager synchronized(this) { - RouterInfo info = (RouterInfo)_table.get(router); + RouterInfo info = _table.get(router); if(info == null) { info = new RouterInfo(router); @@ -68,11 +68,11 @@ public final class RouterManager synchronized(this) { - info = (RouterInfo)_table.remove(router); + info = _table.remove(router); } } return info; } - private java.util.HashMap _table = new java.util.HashMap(); + private java.util.HashMap<Ice.RouterPrx, RouterInfo> _table = new java.util.HashMap<Ice.RouterPrx, RouterInfo>(); } diff --git a/java/src/IceInternal/SelectorThread.java b/java/src/IceInternal/SelectorThread.java index c0e93d24b87..f3a824bfdc0 100644 --- a/java/src/IceInternal/SelectorThread.java +++ b/java/src/IceInternal/SelectorThread.java @@ -168,9 +168,10 @@ public class SelectorThread public void run() { - java.util.HashMap socketMap = new java.util.HashMap(); - java.util.LinkedList readyList = new java.util.LinkedList(); - java.util.LinkedList finishedList = new java.util.LinkedList(); + java.util.Map<java.nio.channels.SelectableChannel, SocketInfo> socketMap = + new java.util.HashMap<java.nio.channels.SelectableChannel, SocketInfo>(); + java.util.LinkedList<SocketInfo> readyList = new java.util.LinkedList<SocketInfo>(); + java.util.LinkedList<SocketInfo> finishedList = new java.util.LinkedList<SocketInfo>(); while(true) { int ret = 0; @@ -236,7 +237,7 @@ public class SelectorThread _keys.remove(_fdIntrReadKey); clearInterrupt(); - SocketInfo info = (SocketInfo)_changes.removeFirst(); + SocketInfo info = _changes.removeFirst(); if(info.cb != null) // Registration { try @@ -252,7 +253,7 @@ public class SelectorThread } else // Unregistration { - info = (SocketInfo)socketMap.get(info.fd); + info = socketMap.get(info.fd); if(info != null && info.status != SocketStatus.Finished) { if(info.timeout >= 0) @@ -279,13 +280,13 @@ public class SelectorThread // // Examine the selection key set. // - java.util.Iterator iter = _keys.iterator(); + java.util.Iterator<java.nio.channels.SelectionKey> iter = _keys.iterator(); while(iter.hasNext()) { // // Ignore selection keys that have been cancelled or timed out. // - java.nio.channels.SelectionKey key = (java.nio.channels.SelectionKey)iter.next(); + java.nio.channels.SelectionKey key = iter.next(); iter.remove(); assert(key != _fdIntrReadKey); SocketInfo info = (SocketInfo)key.attachment(); @@ -298,10 +299,10 @@ public class SelectorThread } } - java.util.Iterator iter = readyList.iterator(); + java.util.Iterator<SocketInfo> iter = readyList.iterator(); while(iter.hasNext()) { - SocketInfo info = (SocketInfo)iter.next(); + SocketInfo info = iter.next(); SocketStatus status; try { @@ -318,7 +319,7 @@ public class SelectorThread _instance.initializationData().logger.error(s); status = SocketStatus.Finished; } - + if(status == SocketStatus.Finished) { finishedList.add(info); @@ -351,7 +352,7 @@ public class SelectorThread iter = finishedList.iterator(); while(iter.hasNext()) { - SocketInfo info = (SocketInfo)iter.next(); + SocketInfo info = iter.next(); if(info.status != SocketStatus.Finished) { try @@ -430,8 +431,8 @@ public class SelectorThread private java.nio.channels.SelectionKey _fdIntrReadKey; private java.nio.channels.WritableByteChannel _fdIntrWrite; private java.nio.channels.Selector _selector; - private java.util.Set _keys; - private java.util.LinkedList _changes = new java.util.LinkedList(); + private java.util.Set<java.nio.channels.SelectionKey> _keys; + private java.util.LinkedList<SocketInfo> _changes = new java.util.LinkedList<SocketInfo>(); private final class SocketInfo implements TimerTask { diff --git a/java/src/IceInternal/ServantManager.java b/java/src/IceInternal/ServantManager.java index 61ce81b58b2..8e4dcc1374a 100644 --- a/java/src/IceInternal/ServantManager.java +++ b/java/src/IceInternal/ServantManager.java @@ -21,10 +21,10 @@ public final class ServantManager facet = ""; } - java.util.HashMap m = (java.util.HashMap)_servantMapMap.get(ident); + java.util.Map<String, Ice.Object> m = _servantMapMap.get(ident); if(m == null) { - m = new java.util.HashMap(); + m = new java.util.HashMap<String, Ice.Object>(); _servantMapMap.put(ident, m); } else @@ -55,9 +55,9 @@ public final class ServantManager facet = ""; } - java.util.HashMap m = (java.util.HashMap)_servantMapMap.get(ident); + java.util.Map<String, Ice.Object> m = _servantMapMap.get(ident); Ice.Object obj = null; - if(m == null || (obj = (Ice.Object)m.remove(facet)) == null) + if(m == null || (obj = m.remove(facet)) == null) { Ice.NotRegisteredException ex = new Ice.NotRegisteredException(); ex.id = _instance.identityToString(ident); @@ -76,12 +76,12 @@ public final class ServantManager return obj; } - public synchronized java.util.Map + public synchronized java.util.Map<String, Ice.Object> removeAllFacets(Ice.Identity ident) { assert(_instance != null); // Must not be called after destruction. - java.util.HashMap m = (java.util.HashMap)_servantMapMap.get(ident); + java.util.Map<String, Ice.Object> m = _servantMapMap.get(ident); if(m == null) { Ice.NotRegisteredException ex = new Ice.NotRegisteredException(); @@ -111,28 +111,28 @@ public final class ServantManager facet = ""; } - java.util.HashMap m = (java.util.HashMap)_servantMapMap.get(ident); + java.util.Map<String, Ice.Object> m = _servantMapMap.get(ident); Ice.Object obj = null; if(m != null) { - obj = (Ice.Object)m.get(facet); + obj = m.get(facet); } return obj; } - public synchronized java.util.Map + public synchronized java.util.Map<String, Ice.Object> findAllFacets(Ice.Identity ident) { assert(_instance != null); // Must not be called after destruction. - java.util.HashMap m = (java.util.HashMap)_servantMapMap.get(ident); + java.util.Map<String, Ice.Object> m = _servantMapMap.get(ident); if(m != null) { - return new java.util.HashMap(m); + return new java.util.HashMap<String, Ice.Object>(m); } - return new java.util.HashMap(); + return new java.util.HashMap<String, Ice.Object>(); } public synchronized boolean @@ -146,7 +146,7 @@ public final class ServantManager // //assert(_instance != null); // Must not be called after destruction. - java.util.HashMap m = (java.util.HashMap)_servantMapMap.get(ident); + java.util.Map<String, Ice.Object> m = _servantMapMap.get(ident); if(m == null) { return false; @@ -163,7 +163,7 @@ public final class ServantManager { assert(_instance != null); // Must not be called after destruction. - Ice.ServantLocator l = (Ice.ServantLocator)_locatorMap.get(category); + Ice.ServantLocator l = _locatorMap.get(category); if(l != null) { Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException(); @@ -186,7 +186,7 @@ public final class ServantManager // //assert(_instance != null); // Must not be called after destruction. - return (Ice.ServantLocator)_locatorMap.get(category); + return _locatorMap.get(category); } // @@ -223,14 +223,14 @@ public final class ServantManager _servantMapMap.clear(); - java.util.Iterator p = _locatorMap.entrySet().iterator(); + java.util.Iterator<java.util.Map.Entry<String, Ice.ServantLocator> > p = _locatorMap.entrySet().iterator(); while(p.hasNext()) { - java.util.Map.Entry e = (java.util.Map.Entry)p.next(); - Ice.ServantLocator locator = (Ice.ServantLocator)e.getValue(); + java.util.Map.Entry<String, Ice.ServantLocator> e = p.next(); + Ice.ServantLocator locator = e.getValue(); try { - locator.deactivate((String)e.getKey()); + locator.deactivate(e.getKey()); } catch(java.lang.Exception ex) { @@ -251,6 +251,7 @@ public final class ServantManager private Instance _instance; final private String _adapterName; - private java.util.HashMap _servantMapMap = new java.util.HashMap(); - private java.util.HashMap _locatorMap = new java.util.HashMap(); + private java.util.Map<Ice.Identity, java.util.Map<String, Ice.Object> > _servantMapMap = + new java.util.HashMap<Ice.Identity, java.util.Map<String, Ice.Object> >(); + private java.util.Map<String, Ice.ServantLocator> _locatorMap = new java.util.HashMap<String, Ice.ServantLocator>(); } diff --git a/java/src/IceInternal/TcpEndpointI.java b/java/src/IceInternal/TcpEndpointI.java index 0bb27127ad7..c0cc50c8388 100644 --- a/java/src/IceInternal/TcpEndpointI.java +++ b/java/src/IceInternal/TcpEndpointI.java @@ -356,7 +356,7 @@ final class TcpEndpointI extends EndpointI // Return connectors for this endpoint, or empty list if no connector // is available. // - public java.util.List + public java.util.List<Connector> connectors() { return connectors(Network.getAddresses(_host, _port, _instance.protocolSupport())); @@ -388,21 +388,21 @@ final class TcpEndpointI extends EndpointI // Expand endpoint out in to separate endpoints for each local // host if listening on INADDR_ANY. // - public java.util.List + public java.util.List<EndpointI> expand() { - java.util.ArrayList endps = new java.util.ArrayList(); - java.util.ArrayList hosts = Network.getHostsForEndpointExpand(_host, _instance.protocolSupport()); + java.util.List<EndpointI> endps = new java.util.ArrayList<EndpointI>(); + java.util.List<String> hosts = Network.getHostsForEndpointExpand(_host, _instance.protocolSupport()); if(hosts == null || hosts.isEmpty()) { endps.add(this); } else { - java.util.Iterator p = hosts.iterator(); + java.util.Iterator<String> p = hosts.iterator(); while(p.hasNext()) { - endps.add(new TcpEndpointI(_instance, (String)p.next(), _port, _timeout, _connectionId, _compress)); + endps.add(new TcpEndpointI(_instance, p.next(), _port, _timeout, _connectionId, _compress)); } } return endps; @@ -438,11 +438,19 @@ final class TcpEndpointI extends EndpointI public boolean equals(java.lang.Object obj) { - return compareTo(obj) == 0; + try + { + return compareTo((EndpointI)obj) == 0; + } + catch(ClassCastException ee) + { + assert(false); + return false; + } } public int - compareTo(java.lang.Object obj) // From java.lang.Comparable + compareTo(EndpointI obj) // From java.lang.Comparable { TcpEndpointI p = null; @@ -452,15 +460,7 @@ final class TcpEndpointI extends EndpointI } catch(ClassCastException ex) { - try - { - EndpointI e = (EndpointI)obj; - return type() < e.type() ? -1 : 1; - } - catch(ClassCastException ee) - { - assert(false); - } + return type() < obj.type() ? -1 : 1; } if(this == p) @@ -503,14 +503,14 @@ final class TcpEndpointI extends EndpointI return _host.compareTo(p._host); } - public java.util.List - connectors(java.util.List addresses) + public java.util.List<Connector> + connectors(java.util.List<java.net.InetSocketAddress> addresses) { - java.util.ArrayList connectors = new java.util.ArrayList(); - java.util.Iterator p = addresses.iterator(); + java.util.List<Connector> connectors = new java.util.ArrayList<Connector>(); + java.util.Iterator<java.net.InetSocketAddress> p = addresses.iterator(); while(p.hasNext()) { - connectors.add(new TcpConnector(_instance, (java.net.InetSocketAddress)p.next(), _timeout, _connectionId)); + connectors.add(new TcpConnector(_instance, p.next(), _timeout, _connectionId)); } return connectors; } diff --git a/java/src/IceInternal/ThreadPool.java b/java/src/IceInternal/ThreadPool.java index 3a8173da69e..8c7a74cdc1d 100644 --- a/java/src/IceInternal/ThreadPool.java +++ b/java/src/IceInternal/ThreadPool.java @@ -103,7 +103,7 @@ public final class ThreadPool try { - _threads = new java.util.ArrayList(); + _threads = new java.util.ArrayList<EventHandlerThread>(); for(int i = 0; i < _size; i++) { EventHandlerThread thread = new EventHandlerThread(_programNamePrefix + _prefix + "-" + @@ -261,10 +261,10 @@ public final class ThreadPool // wouldn't be possible here anyway, because otherwise the // other threads would never terminate.) // - java.util.Iterator i = _threads.iterator(); + java.util.Iterator<EventHandlerThread> i = _threads.iterator(); while(i.hasNext()) { - EventHandlerThread thread = (EventHandlerThread)i.next(); + EventHandlerThread thread = i.next(); while(true) { @@ -467,12 +467,12 @@ public final class ThreadPool { if(TRACE_REGISTRATION) { - java.util.Set keys = _selector.keys(); + java.util.Set<java.nio.channels.SelectionKey> keys = _selector.keys(); trace("selecting on " + keys.size() + " channels:"); - java.util.Iterator i = keys.iterator(); + java.util.Iterator<java.nio.channels.SelectionKey> i = keys.iterator(); while(i.hasNext()) { - java.nio.channels.SelectionKey key = (java.nio.channels.SelectionKey)i.next(); + java.nio.channels.SelectionKey key = i.next(); trace(" " + key.channel()); } } @@ -486,7 +486,7 @@ public final class ThreadPool // if(!_pendingHandlers.isEmpty()) { - handler = (EventHandler)_pendingHandlers.removeFirst(); + handler = _pendingHandlers.removeFirst(); } else { @@ -542,7 +542,7 @@ public final class ThreadPool _keys.remove(_fdIntrReadKey); clearInterrupt(); assert(!_workItems.isEmpty()); - workItem = (ThreadPoolWorkItem)_workItems.removeFirst(); + workItem = _workItems.removeFirst(); } else if(_destroyed) { @@ -568,7 +568,7 @@ public final class ThreadPool // An event handler must have been registered or unregistered. // assert(!_changes.isEmpty()); - FdHandlerPair change = (FdHandlerPair)_changes.removeFirst(); + FdHandlerPair change = _changes.removeFirst(); if(change.handler != null) // Addition if handler is set. { @@ -615,7 +615,7 @@ public final class ThreadPool } else // Removal if handler is not set. { - HandlerKeyPair pair = (HandlerKeyPair)_handlerMap.remove(change.fd); + HandlerKeyPair pair = _handlerMap.remove(change.fd); assert(pair != null); handler = pair.handler; finished = true; @@ -639,13 +639,13 @@ public final class ThreadPool else { java.nio.channels.SelectionKey key = null; - java.util.Iterator iter = _keys.iterator(); + java.util.Iterator<java.nio.channels.SelectionKey> iter = _keys.iterator(); while(iter.hasNext()) { // // Ignore selection keys that have been cancelled // - java.nio.channels.SelectionKey k = (java.nio.channels.SelectionKey)iter.next(); + java.nio.channels.SelectionKey k = iter.next(); iter.remove(); if(k.isValid() && k != _fdIntrReadKey) { @@ -885,10 +885,10 @@ public final class ThreadPool assert(_running <= sz); if(_running < sz) { - java.util.Iterator i = _threads.iterator(); + java.util.Iterator<EventHandlerThread> i = _threads.iterator(); while(i.hasNext()) { - EventHandlerThread thread = (EventHandlerThread)i.next(); + EventHandlerThread thread = i.next(); if(!thread.isAlive()) { @@ -1108,10 +1108,10 @@ public final class ThreadPool if(_keys.size() > 0) { trace("after selectNow, there are " + _keys.size() + " selected keys:"); - java.util.Iterator i = _keys.iterator(); + java.util.Iterator<java.nio.channels.SelectionKey> i = _keys.iterator(); while(i.hasNext()) { - java.nio.channels.SelectionKey key = (java.nio.channels.SelectionKey)i.next(); + java.nio.channels.SelectionKey key = i.next(); trace(" " + keyToString(key)); } } @@ -1271,12 +1271,13 @@ public final class ThreadPool private java.nio.channels.SelectionKey _fdIntrReadKey; private java.nio.channels.WritableByteChannel _fdIntrWrite; private java.nio.channels.Selector _selector; - private java.util.Set _keys; + private java.util.Set<java.nio.channels.SelectionKey> _keys; - private java.util.LinkedList _changes = new java.util.LinkedList(); - private java.util.LinkedList _workItems = new java.util.LinkedList(); + private java.util.LinkedList<FdHandlerPair> _changes = new java.util.LinkedList<FdHandlerPair>(); + private java.util.LinkedList<ThreadPoolWorkItem> _workItems = new java.util.LinkedList<ThreadPoolWorkItem>(); - private java.util.HashMap _handlerMap = new java.util.HashMap(); + private java.util.Map<java.nio.channels.SelectableChannel, HandlerKeyPair> _handlerMap = + new java.util.HashMap<java.nio.channels.SelectableChannel, HandlerKeyPair>(); private int _timeout; @@ -1286,7 +1287,7 @@ public final class ThreadPool // the thread pool to read more data before it re-enters a blocking call to // select(). // - private java.util.LinkedList _pendingHandlers = new java.util.LinkedList(); + private java.util.LinkedList<EventHandler> _pendingHandlers = new java.util.LinkedList<EventHandler>(); private final class EventHandlerThread extends Thread { @@ -1362,7 +1363,7 @@ public final class ThreadPool private final int _sizeMax; // Maximum number of threads. private final int _sizeWarn; // If _inUse reaches _sizeWarn, a "low on threads" warning will be printed. - private java.util.ArrayList _threads; // All threads, running or not. + private java.util.List<EventHandlerThread> _threads; // All threads, running or not. private int _threadIndex; // For assigning thread names. private int _running; // Number of running threads. private int _inUse; // Number of threads that are currently in use. diff --git a/java/src/IceInternal/Timer.java b/java/src/IceInternal/Timer.java index 02ebcd81267..319129232c4 100644 --- a/java/src/IceInternal/Timer.java +++ b/java/src/IceInternal/Timer.java @@ -20,7 +20,7 @@ public final class Timer extends Thread // Renamed from destroy to _destroy to avoid a deprecation warning caused // by the destroy method inherited from Thread. // - public void + public void _destroy() { synchronized(this) @@ -32,11 +32,11 @@ public final class Timer extends Thread _instance = null; notify(); - + _tokens.clear(); _tasks.clear(); } - + while(true) { try @@ -60,7 +60,7 @@ public final class Timer extends Thread final Token token = new Token(IceInternal.Time.currentMonotonicTimeMillis() + delay, ++_tokenId, 0, task); - Object previous = _tasks.put(task, token); + Token previous = _tasks.put(task, token); assert previous == null; _tokens.add(token); @@ -80,7 +80,7 @@ public final class Timer extends Thread final Token token = new Token(IceInternal.Time.currentMonotonicTimeMillis() + period, ++_tokenId, period, task); - Object previous = _tasks.put(task, token); + Token previous = _tasks.put(task, token); assert previous == null; _tokens.add(token); @@ -98,7 +98,7 @@ public final class Timer extends Thread return false; } - Token token = (Token)_tasks.remove(task); + Token token = _tasks.remove(task); if(token == null) { return false; @@ -130,7 +130,7 @@ public final class Timer extends Thread throws Throwable { IceUtilInternal.Assert.FinalizerAssert(_instance == null); - + super.finalize(); } @@ -179,16 +179,16 @@ public final class Timer extends Thread } } } - + if(_instance == null) { break; } - + while(!_tokens.isEmpty() && _instance != null) { long now = IceInternal.Time.currentMonotonicTimeMillis(); - Token first = (Token)_tokens.first(); + Token first = _tokens.first(); if(first.scheduledTime <= now) { _tokens.remove(first); @@ -199,7 +199,7 @@ public final class Timer extends Thread } break; } - + _wakeUpTime = first.scheduledTime; while(true) { @@ -213,7 +213,7 @@ public final class Timer extends Thread } } } - + if(_instance == null) { break; @@ -240,14 +240,14 @@ public final class Timer extends Thread _instance.initializationData().logger.error(s); } } - } + } } } } static private class Token implements Comparable { - public + public Token(long scheduledTime, int id, long delay, TimerTask task) { this.scheduledTime = scheduledTime; @@ -256,7 +256,7 @@ public final class Timer extends Thread this.task = task; } - public int + public int compareTo(Object o) { // @@ -280,7 +280,7 @@ public final class Timer extends Thread { return 1; } - + return 0; } @@ -290,8 +290,8 @@ public final class Timer extends Thread TimerTask task; } - private final java.util.SortedSet _tokens = new java.util.TreeSet(); - private final java.util.Map _tasks = new java.util.HashMap(); + private final java.util.SortedSet<Token> _tokens = new java.util.TreeSet<Token>(); + private final java.util.Map<TimerTask, Token> _tasks = new java.util.HashMap<TimerTask, Token>(); private Instance _instance; private long _wakeUpTime = Long.MAX_VALUE; private int _tokenId = 0; diff --git a/java/src/IceInternal/TraceUtil.java b/java/src/IceInternal/TraceUtil.java index 68c894fa482..a239bf044f4 100644 --- a/java/src/IceInternal/TraceUtil.java +++ b/java/src/IceInternal/TraceUtil.java @@ -62,7 +62,7 @@ public final class TraceUtil } } - private static java.util.Set slicingIds = new java.util.HashSet(); + private static java.util.Set<String> slicingIds = new java.util.HashSet<String>(); synchronized static void traceSlicing(String kind, String typeId, String slicingCat, Ice.Logger logger) diff --git a/java/src/IceInternal/UdpEndpointI.java b/java/src/IceInternal/UdpEndpointI.java index 3f5f76d390a..eba1981d803 100644 --- a/java/src/IceInternal/UdpEndpointI.java +++ b/java/src/IceInternal/UdpEndpointI.java @@ -522,7 +522,7 @@ final class UdpEndpointI extends EndpointI // Return connectors for this endpoint, or empty list if no connector // is available. // - public java.util.List + public java.util.List<Connector> connectors() { return connectors(Network.getAddresses(_host, _port, _instance.protocolSupport())); @@ -552,21 +552,21 @@ final class UdpEndpointI extends EndpointI // Expand endpoint out in to separate endpoints for each local // host if listening on INADDR_ANY. // - public java.util.List + public java.util.List<EndpointI> expand() { - java.util.ArrayList endps = new java.util.ArrayList(); - java.util.ArrayList hosts = Network.getHostsForEndpointExpand(_host, _instance.protocolSupport()); + java.util.ArrayList<EndpointI> endps = new java.util.ArrayList<EndpointI>(); + java.util.ArrayList<String> hosts = Network.getHostsForEndpointExpand(_host, _instance.protocolSupport()); if(hosts == null || hosts.isEmpty()) { endps.add(this); } else { - java.util.Iterator p = hosts.iterator(); + java.util.Iterator<String> p = hosts.iterator(); while(p.hasNext()) { - endps.add(new UdpEndpointI(_instance, (String)p.next(), _port, _mcastInterface, _mcastTtl, + endps.add(new UdpEndpointI(_instance, p.next(), _port, _mcastInterface, _mcastTtl, _protocolMajor, _protocolMinor, _encodingMajor, _encodingMinor, _connect, _connectionId, _compress)); } @@ -605,11 +605,19 @@ final class UdpEndpointI extends EndpointI public boolean equals(java.lang.Object obj) { - return compareTo(obj) == 0; + try + { + return compareTo((EndpointI)obj) == 0; + } + catch(ClassCastException ee) + { + assert(false); + return false; + } } public int - compareTo(java.lang.Object obj) // From java.lang.Comparable + compareTo(EndpointI obj) // From java.lang.Comparable { UdpEndpointI p = null; @@ -619,15 +627,7 @@ final class UdpEndpointI extends EndpointI } catch(ClassCastException ex) { - try - { - EndpointI e = (EndpointI)obj; - return type() < e.type() ? -1 : 1; - } - catch(ClassCastException ee) - { - assert(false); - } + return type() < obj.type() ? -1 : 1; } if(this == p) @@ -721,16 +721,16 @@ final class UdpEndpointI extends EndpointI return _host.compareTo(p._host); } - public java.util.List - connectors(java.util.List addresses) + public java.util.List<Connector> + connectors(java.util.List<java.net.InetSocketAddress> addresses) { - java.util.ArrayList connectors = new java.util.ArrayList(); - java.util.Iterator p = addresses.iterator(); + java.util.ArrayList<Connector> connectors = new java.util.ArrayList<Connector>(); + java.util.Iterator<java.net.InetSocketAddress> p = addresses.iterator(); while(p.hasNext()) { connectors.add( - new UdpConnector(_instance, (java.net.InetSocketAddress)p.next(), _mcastInterface, _mcastTtl, - _protocolMajor, _protocolMinor, _encodingMajor, _encodingMinor, _connectionId)); + new UdpConnector(_instance, p.next(), _mcastInterface, _mcastTtl, _protocolMajor, _protocolMinor, + _encodingMajor, _encodingMinor, _connectionId)); } return connectors; } diff --git a/java/src/IceInternal/UnknownEndpointI.java b/java/src/IceInternal/UnknownEndpointI.java index 231d040864d..6e940af8ed7 100644 --- a/java/src/IceInternal/UnknownEndpointI.java +++ b/java/src/IceInternal/UnknownEndpointI.java @@ -238,16 +238,16 @@ final class UnknownEndpointI extends EndpointI // Return connectors for this endpoint, or empty list if no connector // is available. // - public java.util.List + public java.util.List<Connector> connectors() { - return new java.util.ArrayList(); + return new java.util.ArrayList<Connector>(); } public void connectors_async(EndpointI_connectors callback) { - callback.connectors(new java.util.ArrayList()); + callback.connectors(new java.util.ArrayList<Connector>()); } // @@ -269,10 +269,10 @@ final class UnknownEndpointI extends EndpointI // host if listening on INADDR_ANY on server side or if no host // was specified on client side. // - public java.util.List + public java.util.List<EndpointI> expand() { - java.util.ArrayList endps = new java.util.ArrayList(); + java.util.List<EndpointI> endps = new java.util.ArrayList<EndpointI>(); endps.add(this); return endps; } @@ -298,11 +298,19 @@ final class UnknownEndpointI extends EndpointI public boolean equals(java.lang.Object obj) { - return compareTo(obj) == 0; + try + { + return compareTo((EndpointI)obj) == 0; + } + catch(ClassCastException ee) + { + assert(false); + return false; + } } public int - compareTo(java.lang.Object obj) // From java.lang.Comparable + compareTo(EndpointI obj) // From java.lang.Comparable { UnknownEndpointI p = null; diff --git a/java/src/IceInternal/ValueWriter.java b/java/src/IceInternal/ValueWriter.java index aab0b88c137..63efa63640a 100644 --- a/java/src/IceInternal/ValueWriter.java +++ b/java/src/IceInternal/ValueWriter.java @@ -18,7 +18,8 @@ public final class ValueWriter } private static void - writeValue(String name, java.lang.Object value, java.util.Map objectTable, IceUtilInternal.OutputBase out) + writeValue(String name, java.lang.Object value, java.util.Map<java.lang.Object, java.lang.Object> objectTable, + IceUtilInternal.OutputBase out) { if(value == null) { @@ -27,7 +28,7 @@ public final class ValueWriter } else { - Class c = value.getClass(); + Class<?> c = value.getClass(); if(c.equals(Byte.class) || c.equals(Short.class) || c.equals(Integer.class) || c.equals(Long.class) || c.equals(Double.class) || c.equals(Float.class) || c.equals(Boolean.class)) { @@ -99,7 +100,7 @@ public final class ValueWriter { if(objectTable == null) { - objectTable = new java.util.IdentityHashMap(); + objectTable = new java.util.IdentityHashMap<java.lang.Object, java.lang.Object>(); } objectTable.put(value, null); writeFields(name, value, c, objectTable, out); @@ -178,7 +179,8 @@ public final class ValueWriter } private static void - writeFields(String name, java.lang.Object obj, Class c, java.util.Map objectTable, IceUtilInternal.OutputBase out) + writeFields(String name, java.lang.Object obj, Class c, + java.util.Map<java.lang.Object, java.lang.Object> objectTable, IceUtilInternal.OutputBase out) { if(!c.equals(java.lang.Object.class)) { diff --git a/java/src/IceSSL/EndpointI.java b/java/src/IceSSL/EndpointI.java index 1e1572d493d..f9a64fe1b49 100644 --- a/java/src/IceSSL/EndpointI.java +++ b/java/src/IceSSL/EndpointI.java @@ -356,7 +356,7 @@ final class EndpointI extends IceInternal.EndpointI // Return connectors for this endpoint, or empty list if no connector // is available. // - public java.util.List + public java.util.List<IceInternal.Connector> connectors() { return connectors(IceInternal.Network.getAddresses(_host, _port, _instance.protocolSupport())); @@ -388,21 +388,22 @@ final class EndpointI extends IceInternal.EndpointI // Expand endpoint out in to separate endpoints for each local // host if listening on INADDR_ANY. // - public java.util.List + public java.util.List<IceInternal.EndpointI> expand() { - java.util.ArrayList endps = new java.util.ArrayList(); - java.util.ArrayList hosts = IceInternal.Network.getHostsForEndpointExpand(_host, _instance.protocolSupport()); + java.util.ArrayList<IceInternal.EndpointI> endps = new java.util.ArrayList<IceInternal.EndpointI>(); + java.util.ArrayList<String> hosts = + IceInternal.Network.getHostsForEndpointExpand(_host, _instance.protocolSupport()); if(hosts == null || hosts.isEmpty()) { endps.add(this); } else { - java.util.Iterator p = hosts.iterator(); + java.util.Iterator<String> p = hosts.iterator(); while(p.hasNext()) { - endps.add(new EndpointI(_instance, (String)p.next(), _port, _timeout, _connectionId, _compress)); + endps.add(new EndpointI(_instance, p.next(), _port, _timeout, _connectionId, _compress)); } } return endps; @@ -438,11 +439,19 @@ final class EndpointI extends IceInternal.EndpointI public boolean equals(java.lang.Object obj) { - return compareTo(obj) == 0; + try + { + return compareTo((IceInternal.EndpointI)obj) == 0; + } + catch(ClassCastException ee) + { + assert(false); + return false; + } } public int - compareTo(java.lang.Object obj) // From java.lang.Comparable + compareTo(IceInternal.EndpointI obj) // From java.lang.Comparable { EndpointI p = null; @@ -452,15 +461,7 @@ final class EndpointI extends IceInternal.EndpointI } catch(ClassCastException ex) { - try - { - IceInternal.EndpointI e = (IceInternal.EndpointI)obj; - return type() < e.type() ? -1 : 1; - } - catch(ClassCastException ee) - { - assert(false); - } + return type() < obj.type() ? -1 : 1; } if(this == p) @@ -503,14 +504,14 @@ final class EndpointI extends IceInternal.EndpointI return _host.compareTo(p._host); } - public java.util.List - connectors(java.util.List addresses) + public java.util.List<IceInternal.Connector> + connectors(java.util.List<java.net.InetSocketAddress> addresses) { - java.util.ArrayList connectors = new java.util.ArrayList(); - java.util.Iterator p = addresses.iterator(); + java.util.List<IceInternal.Connector> connectors = new java.util.ArrayList<IceInternal.Connector>(); + java.util.Iterator<java.net.InetSocketAddress> p = addresses.iterator(); while(p.hasNext()) { - connectors.add(new ConnectorI(_instance, (java.net.InetSocketAddress)p.next(), _timeout, _connectionId)); + connectors.add(new ConnectorI(_instance, p.next(), _timeout, _connectionId)); } return connectors; } diff --git a/java/src/IceSSL/Instance.java b/java/src/IceSSL/Instance.java index 001a4af5863..7da138e6c78 100644 --- a/java/src/IceSSL/Instance.java +++ b/java/src/IceSSL/Instance.java @@ -659,10 +659,10 @@ class Instance CipherExpression ce = (CipherExpression)_ciphers[i]; if(ce.not) { - java.util.Iterator e = result.iterator(); + java.util.Iterator<String> e = result.iterator(); while(e.hasNext()) { - String cipher = (String)e.next(); + String cipher = e.next(); if(ce.cipher != null) { if(ce.cipher.equals(cipher)) @@ -752,16 +752,16 @@ class Instance { try { - java.util.Collection subjectAltNames = + java.util.Collection<java.util.List<?> > subjectAltNames = ((java.security.cert.X509Certificate)info.certs[0]).getSubjectAlternativeNames(); java.util.ArrayList<String> ipAddresses = new java.util.ArrayList<String>(); java.util.ArrayList<String> dnsNames = new java.util.ArrayList<String>(); if(subjectAltNames != null) { - java.util.Iterator i = subjectAltNames.iterator(); + java.util.Iterator<java.util.List<?> > i = subjectAltNames.iterator(); while(i.hasNext()) { - java.util.List l = (java.util.List)i.next(); + java.util.List<?> l = i.next(); assert(!l.isEmpty()); Integer n = (Integer)l.get(0); if(n.intValue() == 7) diff --git a/java/src/IceSSL/RFC2253.java b/java/src/IceSSL/RFC2253.java index 938210e963c..f7659f11b17 100644 --- a/java/src/IceSSL/RFC2253.java +++ b/java/src/IceSSL/RFC2253.java @@ -46,12 +46,12 @@ class RFC2253 int pos; } - public static java.util.List + public static java.util.List<java.util.List<RDNPair> > parse(String data) throws ParseException { - java.util.List results = new java.util.LinkedList(); - java.util.List current = new java.util.LinkedList(); + java.util.List<java.util.List<RDNPair> > results = new java.util.LinkedList<java.util.List<RDNPair> >(); + java.util.List<RDNPair> current = new java.util.LinkedList<RDNPair>(); ParseState state = new ParseState(); state.data = data; state.pos = 0; @@ -67,7 +67,7 @@ class RFC2253 { ++state.pos; results.add(current); - current = new java.util.LinkedList(); + current = new java.util.LinkedList<RDNPair>(); } else if(state.pos < state.data.length()) { @@ -82,11 +82,11 @@ class RFC2253 return results; } - public static java.util.List + public static java.util.List<RDNPair> parseStrict(String data) throws ParseException { - java.util.List results = new java.util.LinkedList(); + java.util.List<RDNPair> results = new java.util.LinkedList<RDNPair>(); ParseState state = new ParseState(); state.data = data; state.pos = 0; @@ -179,7 +179,7 @@ class RFC2253 // // Here we must also check for "oid." and "OID." before parsing // according to the ALPHA KEYCHAR* rule. - // + // // First the OID case. // if(Character.isDigit(state.data.charAt(state.pos)) || diff --git a/java/src/IceSSL/TrustManager.java b/java/src/IceSSL/TrustManager.java index 67b0066ac1d..443e3bc6b66 100644 --- a/java/src/IceSSL/TrustManager.java +++ b/java/src/IceSSL/TrustManager.java @@ -26,14 +26,14 @@ class TrustManager _client = parse(properties.getProperty(key)); key = "IceSSL.TrustOnly.Server"; _allServer = parse(properties.getProperty(key)); - java.util.Map dict = properties.getPropertiesForPrefix("IceSSL.TrustOnly.Server."); - java.util.Iterator p = dict.entrySet().iterator(); + java.util.Map<String, String> dict = properties.getPropertiesForPrefix("IceSSL.TrustOnly.Server."); + java.util.Iterator<java.util.Map.Entry<String, String> > p = dict.entrySet().iterator(); while(p.hasNext()) { - java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); - key = (String)entry.getKey(); + java.util.Map.Entry<String, String> entry = p.next(); + key = entry.getKey(); String name = key.substring("IceSSL.TrustOnly.Server.".length()); - _server.put(name, parse((String)entry.getValue())); + _server.put(name, parse(entry.getValue())); } } catch(RFC2253.ParseException e) @@ -47,7 +47,8 @@ class TrustManager boolean verify(ConnectionInfo info) { - java.util.List trustset = new java.util.LinkedList(); + java.util.List<java.util.List<java.util.List<RFC2253.RDNPair> > > trustset = + new java.util.LinkedList<java.util.List<java.util.List<RFC2253.RDNPair> > >(); if(!_all.isEmpty()) { trustset.add(_all); @@ -61,7 +62,7 @@ class TrustManager } if(info.adapterName.length() > 0) { - java.util.List p = (java.util.List)_server.get(info.adapterName); + java.util.List<java.util.List<RFC2253.RDNPair> > p = _server.get(info.adapterName); if(p != null) { trustset.add(p); @@ -116,19 +117,19 @@ class TrustManager "remote addr = " + IceInternal.Network.addrToString(info.remoteAddr)); } } - java.util.List dn = RFC2253.parseStrict(subjectName); + java.util.List<RFC2253.RDNPair> dn = RFC2253.parseStrict(subjectName); // // Try matching against everything in the trust set. // - java.util.Iterator p = trustset.iterator(); + java.util.Iterator<java.util.List<java.util.List<RFC2253.RDNPair> > > p = trustset.iterator(); while(p.hasNext()) { - java.util.List matchSet = (java.util.List)p.next(); + java.util.List<java.util.List<RFC2253.RDNPair> > matchSet = p.next(); if(_traceLevel > 1) { String s = "trust manager matching PDNs:\n"; - java.util.Iterator q = matchSet.iterator(); + java.util.Iterator<java.util.List<RFC2253.RDNPair> > q = matchSet.iterator(); boolean addSemi = false; while(q.hasNext()) { @@ -137,8 +138,8 @@ class TrustManager s += ';'; } addSemi = true; - java.util.List rdnSet = (java.util.List)q.next(); - java.util.Iterator r = rdnSet.iterator(); + java.util.List<RFC2253.RDNPair> rdnSet = q.next(); + java.util.Iterator<RFC2253.RDNPair> r = rdnSet.iterator(); boolean addComma = false; while(r.hasNext()) { @@ -147,7 +148,7 @@ class TrustManager s += ','; } addComma = true; - RFC2253.RDNPair rdn = (RFC2253.RDNPair)r.next(); + RFC2253.RDNPair rdn = r.next(); s += rdn.key; s += '='; s += rdn.value; @@ -172,12 +173,12 @@ class TrustManager } private boolean - match(java.util.List matchSet, java.util.List subject) + match(java.util.List<java.util.List<RFC2253.RDNPair> > matchSet, java.util.List<RFC2253.RDNPair> subject) { - java.util.Iterator r = matchSet.iterator(); + java.util.Iterator<java.util.List<RFC2253.RDNPair> > r = matchSet.iterator(); while(r.hasNext()) { - if(matchRDNs((java.util.List)r.next(), subject)) + if(matchRDNs(r.next(), subject)) { return true; } @@ -186,17 +187,17 @@ class TrustManager } private boolean - matchRDNs(java.util.List match, java.util.List subject) + matchRDNs(java.util.List<RFC2253.RDNPair> match, java.util.List<RFC2253.RDNPair> subject) { - java.util.Iterator p = match.iterator(); + java.util.Iterator<RFC2253.RDNPair> p = match.iterator(); while(p.hasNext()) { - RFC2253.RDNPair matchRDN = (RFC2253.RDNPair)p.next(); + RFC2253.RDNPair matchRDN = p.next(); boolean found = false; - java.util.Iterator q = subject.iterator(); + java.util.Iterator<RFC2253.RDNPair> q = subject.iterator(); while(q.hasNext()) { - RFC2253.RDNPair subjectRDN = (RFC2253.RDNPair)q.next(); + RFC2253.RDNPair subjectRDN = q.next(); if(matchRDN.key.equals(subjectRDN.key)) { found = true; @@ -214,7 +215,7 @@ class TrustManager return true; } - java.util.List + java.util.List<java.util.List<RFC2253.RDNPair> > parse(String value) throws RFC2253.ParseException { @@ -257,15 +258,16 @@ class TrustManager // DNs on ';' which cannot be blindly split because of quotes, // \ and such. // - java.util.List l = RFC2253.parse(value); - java.util.List result = new java.util.LinkedList(); - java.util.Iterator p = l.iterator(); + java.util.List<java.util.List<RFC2253.RDNPair> > l = RFC2253.parse(value); + java.util.List<java.util.List<RFC2253.RDNPair> > result = + new java.util.LinkedList<java.util.List<RFC2253.RDNPair> >(); + java.util.Iterator<java.util.List<RFC2253.RDNPair> > p = l.iterator(); while(p.hasNext()) { - java.util.List dn = (java.util.List)p.next(); + java.util.List<RFC2253.RDNPair> dn = p.next(); String v = new String(); boolean first = true; - java.util.Iterator q = dn.iterator(); + java.util.Iterator<RFC2253.RDNPair> q = dn.iterator(); while(q.hasNext()) { if(!first) @@ -273,7 +275,7 @@ class TrustManager v += ","; } first = false; - RFC2253.RDNPair pair = (RFC2253.RDNPair)q.next(); + RFC2253.RDNPair pair = q.next(); v += pair.key; v += "="; v += pair.value; @@ -288,8 +290,9 @@ class TrustManager private Ice.Communicator _communicator; private int _traceLevel; - private java.util.List _all; - private java.util.List _client; - private java.util.List _allServer; - private java.util.Map _server = new java.util.HashMap(); + private java.util.List<java.util.List<RFC2253.RDNPair> > _all; + private java.util.List<java.util.List<RFC2253.RDNPair> > _client; + private java.util.List<java.util.List<RFC2253.RDNPair> > _allServer; + private java.util.Map<String, java.util.List<java.util.List<RFC2253.RDNPair> > > _server = + new java.util.HashMap<String, java.util.List<java.util.List<RFC2253.RDNPair> > >(); } diff --git a/java/src/IceUtil/Cache.java b/java/src/IceUtil/Cache.java index 3fc15b078e2..f832645c00a 100644 --- a/java/src/IceUtil/Cache.java +++ b/java/src/IceUtil/Cache.java @@ -20,8 +20,8 @@ public class Cache { _store = store; } - - public Object + + public Object getIfPinned(Object key) { synchronized(_map) @@ -30,7 +30,7 @@ public class Cache return val == null ? null : val.obj; } } - + public Object unpin(Object key) { @@ -49,7 +49,7 @@ public class Cache _map.clear(); } } - + public int size() { @@ -105,7 +105,6 @@ public class Cache return pinImpl(key, newObj); } - static private class CacheValue { CacheValue() @@ -128,34 +127,34 @@ public class Cache { CacheValue val = null; java.util.concurrent.CountDownLatch latch = null; - + synchronized(_map) { - val = (CacheValue)_map.get(key); - if(val == null) - { - val = new CacheValue(); - _map.put(key, val); - } - else - { - if(val.obj != null) - { - return val.obj; - } - if(val.latch == null) - { - // - // The first queued thread creates the latch - // - val.latch = new java.util.concurrent.CountDownLatch(1); - } - latch = val.latch; - } + val = (CacheValue)_map.get(key); + if(val == null) + { + val = new CacheValue(); + _map.put(key, val); + } + else + { + if(val.obj != null) + { + return val.obj; + } + if(val.latch == null) + { + // + // The first queued thread creates the latch + // + val.latch = new java.util.concurrent.CountDownLatch(1); + } + latch = val.latch; + } } - - if(latch != null) - { + + if(latch != null) + { try { latch.await(); @@ -164,16 +163,16 @@ public class Cache { // Ignored } - - // - // val could be stale now, e.g. some other thread pinned and unpinned the - // object while we were waiting. - // So start over. - // + + // + // val could be stale now, e.g. some other thread pinned and unpinned the + // object while we were waiting. + // So start over. + // continue; - } - else - { + } + else + { Object obj; try { @@ -181,37 +180,37 @@ public class Cache } catch(RuntimeException e) { - synchronized(_map) + synchronized(_map) { _map.remove(key); - latch = val.latch; - val.latch = null; + latch = val.latch; + val.latch = null; } - if(latch != null) - { + if(latch != null) + { latch.countDown(); assert latch.getCount() == 0; } throw e; } - - synchronized(_map) - { - if(obj != null) - { - val.obj = obj; - } - else - { + + synchronized(_map) + { + if(obj != null) + { + val.obj = obj; + } + else + { if(newObj == null) { // // pin() did not find the object // - - // - // The waiting threads will have to call load() to see by themselves. - // + + // + // The waiting threads will have to call load() to see by themselves. + // _map.remove(key); } else @@ -221,23 +220,21 @@ public class Cache // val.obj = newObj; } - } - - latch = val.latch; - val.latch = null; - } - if(latch != null) - { + } + + latch = val.latch; + val.latch = null; + } + if(latch != null) + { latch.countDown(); assert latch.getCount() == 0; - } + } return obj; - } + } } } - - private final java.util.Map _map = new java.util.HashMap(); + private final java.util.Map<Object, CacheValue> _map = new java.util.HashMap<Object, CacheValue>(); private final Store _store; - } diff --git a/java/src/IceUtilInternal/Options.java b/java/src/IceUtilInternal/Options.java index 114e434e881..cc9058fa046 100644 --- a/java/src/IceUtilInternal/Options.java +++ b/java/src/IceUtilInternal/Options.java @@ -38,7 +38,7 @@ public final class Options int state = NormalState; StringBuffer arg = new StringBuffer(); - java.util.List vec = new java.util.ArrayList(); + java.util.List<String> vec = new java.util.ArrayList<String>(); for(int i = 0; i < line.length(); ++i) { diff --git a/java/src/IceUtilInternal/OutputBase.java b/java/src/IceUtilInternal/OutputBase.java index 2a160aab72c..895f231f620 100644 --- a/java/src/IceUtilInternal/OutputBase.java +++ b/java/src/IceUtilInternal/OutputBase.java @@ -107,14 +107,14 @@ public class OutputBase public void useCurrentPosAsIndent() { - _indentSave.addFirst(new Integer(_indent)); + _indentSave.addFirst(_indent); _indent = _pos; } public void zeroIndent() { - _indentSave.addFirst(new Integer(_indent)); + _indentSave.addFirst(_indent); _indent = 0; } @@ -122,7 +122,7 @@ public class OutputBase restoreIndent() { assert(!_indentSave.isEmpty()); - _indent = ((Integer)_indentSave.removeFirst()).intValue(); + _indent = _indentSave.removeFirst().intValue(); } public void @@ -182,8 +182,7 @@ public class OutputBase protected int _pos; protected int _indent; protected int _indentSize; - protected java.util.LinkedList _indentSave = new java.util.LinkedList(); + protected java.util.LinkedList<Integer> _indentSave = new java.util.LinkedList<Integer>(); protected boolean _useTab; protected boolean _separator; - } diff --git a/java/src/IceUtilInternal/XMLOutput.java b/java/src/IceUtilInternal/XMLOutput.java index e4562608d76..dec906ae4a7 100644 --- a/java/src/IceUtilInternal/XMLOutput.java +++ b/java/src/IceUtilInternal/XMLOutput.java @@ -132,7 +132,7 @@ public class XMLOutput extends OutputBase public XMLOutput ee() { - String element = (String)_elementStack.removeFirst(); + String element = _elementStack.removeFirst(); dec(); if(_se) @@ -202,7 +202,7 @@ public class XMLOutput extends OutputBase { if(_elementStack.size() > 0) { - return (String)_elementStack.getFirst(); + return _elementStack.getFirst(); } else { @@ -263,7 +263,7 @@ public class XMLOutput extends OutputBase return v; } - private java.util.LinkedList _elementStack = new java.util.LinkedList(); + private java.util.LinkedList<String> _elementStack = new java.util.LinkedList<String>(); boolean _se; boolean _text; |