diff options
author | Noel Grandin <noel@peralex.com> | 2012-06-28 11:27:57 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-06-29 22:03:03 +0200 |
commit | 7af400558072e2f328f078e39a121a95bb928804 (patch) | |
tree | 464515102ce5d6cad3b5a304e77737532d206e83 /jurt/com | |
parent | 9def9b4674b9610004e915635578d26a48d98300 (diff) |
Java5 update - convert code to use generics
Change-Id: Iff078cea287d0c508d2442d65cd9314ec3231c15
Diffstat (limited to 'jurt/com')
19 files changed, 114 insertions, 117 deletions
diff --git a/jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java b/jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java index ccb59106d89c..b3d5a4dfb494 100644 --- a/jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java +++ b/jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java @@ -20,7 +20,6 @@ package com.sun.star.comp.bridgefactory; import java.math.BigInteger; import java.util.ArrayList; -import java.util.Vector; import com.sun.star.bridge.BridgeExistsException; import com.sun.star.bridge.XBridge; @@ -168,7 +167,7 @@ public class BridgeFactory implements XBridgeFactory/*, XEventListener*/ { * @see com.sun.star.bridge.XBridgeFactory */ public synchronized XBridge[] getExistingBridges() throws com.sun.star.uno.RuntimeException { - ArrayList vector = new ArrayList(); + ArrayList<XBridge> vector = new ArrayList<XBridge>(); IBridge iBridges[] = UnoRuntime.getBridges(); for(int i = 0; i < iBridges.length; ++ i) { @@ -180,7 +179,7 @@ public class BridgeFactory implements XBridgeFactory/*, XEventListener*/ { XBridge xBridges[]= new XBridge[vector.size()]; for(int i = 0; i < vector.size(); ++ i) - xBridges[i] = (XBridge)vector.get(i); + xBridges[i] = vector.get(i); return xBridges; } diff --git a/jurt/com/sun/star/comp/connections/Implementation.java b/jurt/com/sun/star/comp/connections/Implementation.java index 4ff6ee103211..49aba665d6fa 100644 --- a/jurt/com/sun/star/comp/connections/Implementation.java +++ b/jurt/com/sun/star/comp/connections/Implementation.java @@ -52,7 +52,7 @@ final class Implementation { */ public static Object getConnectionService(XMultiServiceFactory factory, String description, - Class serviceClass, + Class<?> serviceClass, String serviceType) throws ConnectionSetupException { diff --git a/jurt/com/sun/star/comp/loader/FactoryHelper.java b/jurt/com/sun/star/comp/loader/FactoryHelper.java index 5353b11e4455..72ce9171a51e 100644 --- a/jurt/com/sun/star/comp/loader/FactoryHelper.java +++ b/jurt/com/sun/star/comp/loader/FactoryHelper.java @@ -56,7 +56,7 @@ public class FactoryHelper { static protected class Factory implements XSingleServiceFactory, XSingleComponentFactory, XServiceInfo, XTypeProvider { - protected static Class __objectArray; + protected static Class<?> __objectArray; static { try { @@ -72,14 +72,14 @@ public class FactoryHelper { protected XMultiServiceFactory _xMultiServiceFactory; protected XRegistryKey _xRegistryKey; protected int _nCode; - protected Constructor _constructor; + protected Constructor<?> _constructor; protected String _implName; protected String _serviceName; // keeps the Id for XTypeProvider protected static Object _mutex= new Object(); private static byte[] _implementationId; - protected Factory(Class implClass, + protected Factory(Class<?> implClass, String serviceName, XMultiServiceFactory xMultiServiceFactory, XRegistryKey xRegistryKey) @@ -89,9 +89,9 @@ public class FactoryHelper { _implName = implClass.getName(); _serviceName = serviceName; - Constructor constructors[] = implClass.getConstructors(); + Constructor<?> constructors[] = implClass.getConstructors(); for(int i = 0; i < constructors.length && _constructor == null; ++i) { - Class parameters[] = constructors[i].getParameterTypes(); + Class<?> parameters[] = constructors[i].getParameterTypes(); if(parameters.length == 3 && parameters[0].equals(XComponentContext.class) @@ -433,7 +433,7 @@ public class FactoryHelper { * @param regKey the given registry key * @see com.sun.star.lang.XServiceInfo */ - static public XSingleServiceFactory getServiceFactory(Class implClass, + static public XSingleServiceFactory getServiceFactory(Class<?> implClass, XMultiServiceFactory multiFactory, XRegistryKey regKey) { @@ -471,7 +471,7 @@ public class FactoryHelper { * @param regKey the given registry key * @see com.sun.star.lang.XServiceInfo */ - static public XSingleServiceFactory getServiceFactory(Class implClass, + static public XSingleServiceFactory getServiceFactory(Class<?> implClass, String serviceName, XMultiServiceFactory multiFactory, XRegistryKey regKey) @@ -484,7 +484,7 @@ public class FactoryHelper { @return returns a factory object @param implClass the implementing class */ - static public Object createComponentFactory( Class implClass, String serviceName ) + static public Object createComponentFactory( Class<?> implClass, String serviceName ) { return new Factory( implClass, serviceName, null, null ); } diff --git a/jurt/com/sun/star/comp/loader/JavaLoader.java b/jurt/com/sun/star/comp/loader/JavaLoader.java index e4d97a3f7abb..9ac66d00211b 100644 --- a/jurt/com/sun/star/comp/loader/JavaLoader.java +++ b/jurt/com/sun/star/comp/loader/JavaLoader.java @@ -255,7 +255,7 @@ public class JavaLoader implements XImplementationLoader, locationUrl = expand_url( locationUrl ); Object returnObject = null; - Class clazz ; + Class<?> clazz ; DEBUG("try to get factory for " + implementationName); @@ -299,7 +299,7 @@ public class JavaLoader implements XImplementationLoader, throw cae; } - Class[] paramTypes = {String.class, XMultiServiceFactory.class, XRegistryKey.class}; + Class<?>[] paramTypes = {String.class, XMultiServiceFactory.class, XRegistryKey.class}; Object[] params = { implementationName, multiServiceFactory, xKey }; // try to get factory from implemetation class @@ -339,7 +339,7 @@ public class JavaLoader implements XImplementationLoader, throw new CannotActivateFactoryException( "No factory object for " + implementationName ); } - return (XSingleComponentFactory)ret; + return ret; } else { @@ -350,7 +350,7 @@ public class JavaLoader implements XImplementationLoader, Object oRet = method.invoke(clazz, params); if ( (oRet != null) && (oRet instanceof XSingleServiceFactory) ) { - returnObject = (XSingleServiceFactory) oRet; + returnObject = oRet; } } } @@ -401,14 +401,14 @@ public class JavaLoader implements XImplementationLoader, try { - Class clazz = RegistrationClassFinder.find(locationUrl); + Class<?> clazz = RegistrationClassFinder.find(locationUrl); if (null == clazz) { throw new CannotRegisterImplementationException( "Cannot determine registration class!" ); } - Class[] paramTypes = { XRegistryKey.class }; + Class<?>[] paramTypes = { XRegistryKey.class }; Object[] params = { regKey }; Method method = clazz.getMethod("__writeRegistryServiceInfo", paramTypes); diff --git a/jurt/com/sun/star/comp/loader/RegistrationClassFinder.java b/jurt/com/sun/star/comp/loader/RegistrationClassFinder.java index 6d3490a96be5..aef672457332 100644 --- a/jurt/com/sun/star/comp/loader/RegistrationClassFinder.java +++ b/jurt/com/sun/star/comp/loader/RegistrationClassFinder.java @@ -28,11 +28,11 @@ import java.util.StringTokenizer; import java.util.jar.Attributes; final class RegistrationClassFinder { - public static Class find(String locationUrl) + public static Class<?> find(String locationUrl) throws ClassNotFoundException, IOException { synchronized (map) { - Class c = (Class) WeakMap.getValue(map.get(locationUrl)); + Class<?> c = (Class<?>) WeakMap.getValue(map.get(locationUrl)); if (c != null) { return c; } @@ -52,9 +52,9 @@ final class RegistrationClassFinder { } else { cl2 = URLClassLoader.newInstance(new URL[] { url }, cl1); } - Class c = cl2.loadClass(name); + Class<?> c = cl2.loadClass(name); synchronized (map) { - Class c2 = (Class) WeakMap.getValue(map.get(locationUrl)); + Class<?> c2 = (Class<?>) WeakMap.getValue(map.get(locationUrl)); if (c2 != null) { return c2; } diff --git a/jurt/com/sun/star/comp/servicemanager/ServiceManager.java b/jurt/com/sun/star/comp/servicemanager/ServiceManager.java index 643b0cae5dac..673db0468c3c 100644 --- a/jurt/com/sun/star/comp/servicemanager/ServiceManager.java +++ b/jurt/com/sun/star/comp/servicemanager/ServiceManager.java @@ -79,9 +79,9 @@ public class ServiceManager implements XMultiServiceFactory, "com.sun.star.lang.ServiceManager" }; - ArrayList eventListener; - java.util.HashMap factoriesByImplNames; - java.util.HashMap factoriesByServiceNames; // keys: + ArrayList<XEventListener> eventListener; + java.util.HashMap<String, Object> factoriesByImplNames; + java.util.HashMap<String, ArrayList<Object>> factoriesByServiceNames; // keys: private com.sun.star.uno.XComponentContext m_xDefaultContext; @@ -89,18 +89,18 @@ public class ServiceManager implements XMultiServiceFactory, * Creates a new instance of the <code>ServiceManager</code>. */ public ServiceManager() { - eventListener = new ArrayList(); - factoriesByImplNames = new java.util.HashMap(); - factoriesByServiceNames = new java.util.HashMap(); + eventListener = new ArrayList<XEventListener>(); + factoriesByImplNames = new java.util.HashMap<String, Object>(); + factoriesByServiceNames = new java.util.HashMap<String, ArrayList<Object>>(); m_xDefaultContext = null; } /** * Creates a new instance of the <code>ServiceManager</code>. */ public ServiceManager( XComponentContext xContext ) { - eventListener = new ArrayList(); - factoriesByImplNames = new java.util.HashMap(); - factoriesByServiceNames = new java.util.HashMap(); + eventListener = new ArrayList<XEventListener>(); + factoriesByImplNames = new java.util.HashMap<String, Object>(); + factoriesByServiceNames = new java.util.HashMap<String, ArrayList<Object>>(); m_xDefaultContext = xContext; } @@ -172,9 +172,9 @@ public class ServiceManager implements XMultiServiceFactory, try { // try to get the class of the implementation - Class clazz = Class.forName( newImpls[i] ); + Class<?> clazz = Class.forName( newImpls[i] ); - Class[] methodClassParam = { String.class, XMultiServiceFactory.class, XRegistryKey.class }; + Class<?>[] methodClassParam = { String.class, XMultiServiceFactory.class, XRegistryKey.class }; java.lang.reflect.Method getFactoryMeth ; try { getFactoryMeth = clazz.getMethod("__getServiceFactory", methodClassParam); @@ -305,14 +305,14 @@ public class ServiceManager implements XMultiServiceFactory, Object factory = null; if ( factoriesByServiceNames.containsKey( serviceName ) ) { - ArrayList aviableFact = (ArrayList) factoriesByServiceNames.get( serviceName ); + ArrayList<Object> availableFact = factoriesByServiceNames.get( serviceName ); DEBUG(""); - DEBUG("aviable factories for " + serviceName +" "+ aviableFact); + DEBUG("aviable factories for " + serviceName +" "+ availableFact); DEBUG(""); - if ( !aviableFact.isEmpty() ) - factory = aviableFact.get(aviableFact.size()-1); + if ( !availableFact.isEmpty() ) + factory = availableFact.get(availableFact.size()-1); } else // not found in list of services - now try the implementations factory = factoriesByImplNames.get( serviceName ); // return null if none is aviable @@ -341,10 +341,10 @@ public class ServiceManager implements XMultiServiceFactory, int i = 0; String[] availableServiceNames = new String[factoriesByServiceNames.size()]; - java.util.Iterator keys = factoriesByServiceNames.keySet().iterator(); + java.util.Iterator<String> keys = factoriesByServiceNames.keySet().iterator(); while (keys.hasNext()) - availableServiceNames[i++] = (String) keys.next(); + availableServiceNames[i++] = keys.next(); return availableServiceNames; } @@ -444,10 +444,10 @@ public class ServiceManager implements XMultiServiceFactory, throws com.sun.star.uno.RuntimeException { if (eventListener != null) { - java.util.Iterator enumer = eventListener.iterator(); + java.util.Iterator<XEventListener> enumer = eventListener.iterator(); while (enumer.hasNext()) { - XEventListener listener = (XEventListener) enumer.next(); + XEventListener listener = enumer.next(); listener.disposing(new com.sun.star.lang.EventObject(this)); } eventListener.clear(); @@ -552,15 +552,15 @@ public class ServiceManager implements XMultiServiceFactory, String[] serviceNames = xServiceInfo.getSupportedServiceNames(); - ArrayList vec ; + ArrayList<Object> vec ; for (int i=0; i<serviceNames.length; i++) { if ( !factoriesByServiceNames.containsKey( serviceNames[i] ) ) { DEBUG("> no registered services found under " + serviceNames[i] + ": adding..." ); - factoriesByServiceNames.put(serviceNames[i], new ArrayList()); + factoriesByServiceNames.put(serviceNames[i], new ArrayList<Object>()); } - vec = (ArrayList) factoriesByServiceNames.get( serviceNames[i] ); + vec = factoriesByServiceNames.get( serviceNames[i] ); if ( vec.contains( object ) ) System.err.println("The implementation " + xServiceInfo.getImplementationName() + @@ -613,7 +613,7 @@ public class ServiceManager implements XMultiServiceFactory, for ( int i=0; i<serviceNames.length; i++ ) { if ( factoriesByServiceNames.containsKey( serviceNames[i] ) ) { - ArrayList vec = (ArrayList) factoriesByServiceNames.get(serviceNames[i]); + ArrayList<Object> vec = factoriesByServiceNames.get(serviceNames[i]); if ( !vec.remove(object) ) System.err.println("The implementation " + xServiceInfo.getImplementationName() + @@ -675,7 +675,7 @@ public class ServiceManager implements XMultiServiceFactory, { XEnumeration enumer ; - ArrayList serviceList = (ArrayList) factoriesByServiceNames.get(serviceName); + ArrayList<Object> serviceList = factoriesByServiceNames.get(serviceName); if (serviceList != null) enumer = new ServiceEnumerationImpl( serviceList.iterator() ); @@ -737,7 +737,7 @@ public class ServiceManager implements XMultiServiceFactory, * @since UDK1.0 */ class ServiceEnumerationImpl implements XEnumeration { - java.util.Iterator enumeration = null; + java.util.Iterator<Object> enumeration = null; /** * Constructs a new empty instance. @@ -751,7 +751,7 @@ public class ServiceManager implements XMultiServiceFactory, * @param enumer is the enumeration which should been wrapped. * @see com.sun.star.container.XEnumeration */ - public ServiceEnumerationImpl(java.util.Enumeration enumer) { + public ServiceEnumerationImpl(java.util.Enumeration<Object> enumer) { enumeration = Collections.list(enumer).iterator(); } @@ -761,7 +761,7 @@ public class ServiceManager implements XMultiServiceFactory, * @param enumer is the enumeration which should been wrapped. * @see com.sun.star.container.XEnumeration */ - public ServiceEnumerationImpl(java.util.Iterator enumer) { + public ServiceEnumerationImpl(java.util.Iterator<Object> enumer) { enumeration = enumer; } diff --git a/jurt/com/sun/star/lib/connections/pipe/PipeConnection.java b/jurt/com/sun/star/lib/connections/pipe/PipeConnection.java index d4d6bdb83322..679359dea52f 100644 --- a/jurt/com/sun/star/lib/connections/pipe/PipeConnection.java +++ b/jurt/com/sun/star/lib/connections/pipe/PipeConnection.java @@ -51,7 +51,7 @@ public class PipeConnection implements XConnection, XConnectionBroadcaster { protected String _aDescription; protected long _nPipeHandle; - protected ArrayList _aListeners; + protected ArrayList<XStreamListener> _aListeners; protected boolean _bFirstRead; /** @@ -65,7 +65,7 @@ public class PipeConnection implements XConnection, XConnectionBroadcaster { { if (DEBUG) System.err.println("##### " + getClass().getName() + " - instantiated " + description ); - _aListeners = new ArrayList(); + _aListeners = new ArrayList<XStreamListener>(); _bFirstRead = true; // get pipe name from pipe descriptor @@ -105,25 +105,25 @@ public class PipeConnection implements XConnection, XConnectionBroadcaster { } private void notifyListeners_open() { - Iterator elements = _aListeners.iterator(); + Iterator<XStreamListener> elements = _aListeners.iterator(); while(elements.hasNext()) { - XStreamListener xStreamListener = (XStreamListener)elements.next(); + XStreamListener xStreamListener = elements.next(); xStreamListener.started(); } } private void notifyListeners_close() { - Iterator elements = _aListeners.iterator(); + Iterator<XStreamListener> elements = _aListeners.iterator(); while(elements.hasNext()) { - XStreamListener xStreamListener = (XStreamListener)elements.next(); + XStreamListener xStreamListener = elements.next(); xStreamListener.closed(); } } private void notifyListeners_error(com.sun.star.uno.Exception exception) { - Iterator elements = _aListeners.iterator(); + Iterator<XStreamListener> elements = _aListeners.iterator(); while(elements.hasNext()) { - XStreamListener xStreamListener = (XStreamListener)elements.next(); + XStreamListener xStreamListener = elements.next(); xStreamListener.error(exception); } } diff --git a/jurt/com/sun/star/lib/connections/socket/SocketConnection.java b/jurt/com/sun/star/lib/connections/socket/SocketConnection.java index 5207bade57ef..9809f0eeaba0 100644 --- a/jurt/com/sun/star/lib/connections/socket/SocketConnection.java +++ b/jurt/com/sun/star/lib/connections/socket/SocketConnection.java @@ -52,7 +52,7 @@ public class SocketConnection implements XConnection, XConnectionBroadcaster { protected Socket _socket; protected InputStream _inputStream; protected OutputStream _outputStream; - protected ArrayList _listeners; + protected ArrayList<XStreamListener> _listeners; protected boolean _firstRead; /** @@ -74,7 +74,7 @@ public class SocketConnection implements XConnection, XConnectionBroadcaster { _inputStream = new BufferedInputStream(socket.getInputStream()); _outputStream = new BufferedOutputStream(socket.getOutputStream()); - _listeners = new ArrayList(); + _listeners = new ArrayList<XStreamListener>(); _firstRead = true; } @@ -90,25 +90,25 @@ public class SocketConnection implements XConnection, XConnectionBroadcaster { } private void notifyListeners_open() { - Iterator elements = _listeners.iterator(); + Iterator<XStreamListener> elements = _listeners.iterator(); while(elements.hasNext()) { - XStreamListener xStreamListener = (XStreamListener)elements.next(); + XStreamListener xStreamListener = elements.next(); xStreamListener.started(); } } private void notifyListeners_close() { - Iterator elements = _listeners.iterator(); + Iterator<XStreamListener> elements = _listeners.iterator(); while(elements.hasNext()) { - XStreamListener xStreamListener = (XStreamListener)elements.next(); + XStreamListener xStreamListener = elements.next(); xStreamListener.closed(); } } private void notifyListeners_error(com.sun.star.uno.Exception exception) { - Iterator elements = _listeners.iterator(); + Iterator<XStreamListener> elements = _listeners.iterator(); while(elements.hasNext()) { - XStreamListener xStreamListener = (XStreamListener)elements.next(); + XStreamListener xStreamListener = elements.next(); xStreamListener.error(exception); } } diff --git a/jurt/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge.java b/jurt/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge.java index 36c66ffe66e7..7b57e87c0687 100644 --- a/jurt/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge.java +++ b/jurt/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge.java @@ -24,12 +24,10 @@ import java.io.OutputStream; import java.util.ArrayList; -import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.Map; -import java.util.Vector; import com.sun.star.lib.util.DisposeListener; import com.sun.star.lib.util.DisposeNotifier; @@ -167,7 +165,7 @@ public class java_remote_bridge protected MessageDispatcher _messageDispatcher; protected int _life_count = 0; // determines if this bridge is alife, which is controlled by acquire and release calls - private final ArrayList _listeners = new ArrayList(); + private final ArrayList<XEventListener> _listeners = new ArrayList<XEventListener>(); protected IThreadPool _iThreadPool; @@ -215,15 +213,15 @@ public class java_remote_bridge private int count = 1; } - private final HashMap refHolders = new HashMap(); + private final HashMap<String, LinkedList<RefHolder>> refHolders = new HashMap<String, LinkedList<RefHolder>>(); // from OID (String) to LinkedList of RefHolder private boolean hasRefHolder(String oid, Type type) { synchronized (refHolders) { - LinkedList l = (LinkedList) refHolders.get(oid); + LinkedList<RefHolder> l = refHolders.get(oid); if (l != null) { - for (Iterator i = l.iterator(); i.hasNext();) { - RefHolder rh = (RefHolder) i.next(); + for (Iterator<RefHolder> i = l.iterator(); i.hasNext();) { + RefHolder rh = i.next(); if (type.isSupertypeOf(rh.getType())) { return true; } @@ -235,14 +233,14 @@ public class java_remote_bridge final void addRefHolder(Object obj, Type type, String oid) { synchronized (refHolders) { - LinkedList l = (LinkedList) refHolders.get(oid); + LinkedList<RefHolder> l = refHolders.get(oid); if (l == null) { - l = new LinkedList(); + l = new LinkedList<RefHolder>(); refHolders.put(oid, l); } boolean found = false; - for (Iterator i = l.iterator(); !found && i.hasNext();) { - RefHolder rh = (RefHolder) i.next(); + for (Iterator<RefHolder> i = l.iterator(); !found && i.hasNext();) { + RefHolder rh = i.next(); if (rh.getType().equals(type)) { found = true; rh.acquire(); @@ -257,10 +255,10 @@ public class java_remote_bridge final void remRefHolder(Type type, String oid) { synchronized (refHolders) { - LinkedList l = (LinkedList) refHolders.get(oid); + LinkedList<RefHolder> l = refHolders.get(oid); if (l != null) { - for (Iterator i = l.iterator(); i.hasNext();) { - RefHolder rh = (RefHolder) i.next(); + for (Iterator<RefHolder> i = l.iterator(); i.hasNext();) { + RefHolder rh = i.next(); if (rh.getType().equals(type)) { try { if (rh.release()) { @@ -281,13 +279,13 @@ public class java_remote_bridge final void freeHolders() { synchronized (refHolders) { - for (Iterator i1 = refHolders.entrySet().iterator(); i1.hasNext();) + for (Iterator<Map.Entry<String,LinkedList<RefHolder>>> i1 = refHolders.entrySet().iterator(); i1.hasNext();) { - Map.Entry e = (Map.Entry) i1.next(); - String oid = (String) e.getKey(); - LinkedList l = (LinkedList) e.getValue(); - for (Iterator i2 = l.iterator(); i2.hasNext();) { - RefHolder rh = (RefHolder) i2.next(); + Map.Entry<String,LinkedList<RefHolder>> e = i1.next(); + String oid = e.getKey(); + LinkedList<RefHolder> l = e.getValue(); + for (Iterator<RefHolder> i2 = l.iterator(); i2.hasNext();) { + RefHolder rh = i2.next(); for (boolean done = false; !done;) { done = rh.release(); _java_environment.revokeInterface(oid, rh.getType()); @@ -341,9 +339,9 @@ public class java_remote_bridge private void notifyListeners() { EventObject eventObject = new EventObject(this); - Iterator elements = _listeners.iterator(); + Iterator<XEventListener> elements = _listeners.iterator(); while(elements.hasNext()) { - XEventListener xEventListener = (XEventListener)elements.next(); + XEventListener xEventListener = elements.next(); try { xEventListener.disposing(eventObject); @@ -485,8 +483,8 @@ public class java_remote_bridge } notifyListeners(); - for (Iterator i = disposeListeners.iterator(); i.hasNext();) { - ((DisposeListener) i.next()).notifyDispose(this); + for (Iterator<DisposeListener> i = disposeListeners.iterator(); i.hasNext();) { + i.next().notifyDispose(this); } _iProtocol.terminate(); @@ -698,5 +696,5 @@ public class java_remote_bridge private final ProxyFactory proxyFactory; // Access to disposeListeners must be synchronized on <CODE>this</CODE>: - private final ArrayList disposeListeners = new ArrayList(); + private final ArrayList<DisposeListener> disposeListeners = new ArrayList<DisposeListener>(); } diff --git a/jurt/com/sun/star/lib/uno/environments/java/java_environment.java b/jurt/com/sun/star/lib/uno/environments/java/java_environment.java index 427f24d7d36a..1fdfdf9e3d9b 100644 --- a/jurt/com/sun/star/lib/uno/environments/java/java_environment.java +++ b/jurt/com/sun/star/lib/uno/environments/java/java_environment.java @@ -263,7 +263,7 @@ public final class java_environment implements IEnvironment { private static final class Level2Entry extends WeakReference<Object> { public Level2Entry( - String oid, Type type, Object object, ReferenceQueue queue) + String oid, Type type, Object object, ReferenceQueue<Object> queue) { super(object, queue); this.oid = oid; @@ -288,7 +288,7 @@ public final class java_environment implements IEnvironment { private final HashMap<String, Level1Entry> level1map = new HashMap<String, Level1Entry>(); - private final ReferenceQueue queue = new ReferenceQueue(); + private final ReferenceQueue<Object> queue = new ReferenceQueue<Object>(); } private boolean isProxy(Object object) { diff --git a/jurt/com/sun/star/lib/uno/environments/remote/JavaThreadPoolFactory.java b/jurt/com/sun/star/lib/uno/environments/remote/JavaThreadPoolFactory.java index 6e9ea465b7fb..9d5fc2c6334b 100644 --- a/jurt/com/sun/star/lib/uno/environments/remote/JavaThreadPoolFactory.java +++ b/jurt/com/sun/star/lib/uno/environments/remote/JavaThreadPoolFactory.java @@ -43,7 +43,7 @@ final class JavaThreadPoolFactory { public JobQueue getJobQueue(ThreadId threadId) { synchronized (jobQueues) { - return (JobQueue) jobQueues.get(threadId); + return jobQueues.get(threadId); } } @@ -55,8 +55,8 @@ final class JavaThreadPoolFactory { public void dispose(Object disposeId, Throwable throwable) { JobQueue[] qs; synchronized (jobQueues) { - Collection c = jobQueues.values(); - qs = (JobQueue[]) c.toArray(new JobQueue[c.size()]); + Collection<JobQueue> c = jobQueues.values(); + qs = c.toArray(new JobQueue[c.size()]); } for (int i = 0; i < qs.length; ++i) { qs[i].dispose(disposeId, throwable); @@ -70,7 +70,7 @@ final class JavaThreadPoolFactory { } else { ThreadId id; synchronized (threadIdMap) { - id = (ThreadId) threadIdMap.get(t); + id = threadIdMap.get(t); if (id == null) { id = ThreadId.createFresh(); threadIdMap.put(t, id); @@ -80,6 +80,6 @@ final class JavaThreadPoolFactory { } } - private static final WeakHashMap threadIdMap = new WeakHashMap(); - private final HashMap jobQueues = new HashMap(); + private static final WeakHashMap<Thread, ThreadId> threadIdMap = new WeakHashMap<Thread, ThreadId>(); + private final HashMap<ThreadId, JobQueue> jobQueues = new HashMap<ThreadId, JobQueue>(); } diff --git a/jurt/com/sun/star/lib/uno/environments/remote/Job.java b/jurt/com/sun/star/lib/uno/environments/remote/Job.java index df1f49d7d525..cc8d142ed68f 100644 --- a/jurt/com/sun/star/lib/uno/environments/remote/Job.java +++ b/jurt/com/sun/star/lib/uno/environments/remote/Job.java @@ -67,7 +67,7 @@ public class Job { * @param o_out_sig the out signature as an out parameter */ protected Object dispatch_queryInterface(Type type) { - Class zInterface = type.getTypeDescription().getZClass(); + Class<?> zInterface = type.getTypeDescription().getZClass(); Object result = null; diff --git a/jurt/com/sun/star/lib/uno/protocols/urp/Cache.java b/jurt/com/sun/star/lib/uno/protocols/urp/Cache.java index 5a2670e50b7f..14affb5bd974 100644 --- a/jurt/com/sun/star/lib/uno/protocols/urp/Cache.java +++ b/jurt/com/sun/star/lib/uno/protocols/urp/Cache.java @@ -38,7 +38,7 @@ final class Cache { } public int add(boolean[] found, Object content) { - Entry e = (Entry) map.get(content); + Entry e = map.get(content); found[0] = e != null; if (e == null) { if (map.size() < maxSize) { @@ -105,7 +105,7 @@ final class Cache { // map contains the same entries; each entry has a unique index in the range // 0 to maxSize - 1 private final int maxSize; - private final HashMap map = new HashMap(); // from Object to Entry + private final HashMap<Object, Entry> map = new HashMap<Object, Entry>(); // from Object to Entry private Entry first = null; private Entry last = null; } diff --git a/jurt/com/sun/star/lib/uno/protocols/urp/PendingRequests.java b/jurt/com/sun/star/lib/uno/protocols/urp/PendingRequests.java index 72a72dab3815..18005bd817c7 100644 --- a/jurt/com/sun/star/lib/uno/protocols/urp/PendingRequests.java +++ b/jurt/com/sun/star/lib/uno/protocols/urp/PendingRequests.java @@ -27,17 +27,17 @@ final class PendingRequests { public PendingRequests() {} public synchronized void push(ThreadId tid, Item item) { - Stack s = (Stack) map.get(tid); + Stack<Item> s = map.get(tid); if (s == null) { - s = new Stack(); + s = new Stack<Item>(); map.put(tid, s); } s.push(item); } public synchronized Item pop(ThreadId tid) { - Stack s = (Stack) map.get(tid); - Item i = (Item) s.pop(); + Stack<Item> s = map.get(tid); + Item i = s.pop(); if (s.empty()) { map.remove(tid); } @@ -58,5 +58,5 @@ final class PendingRequests { public final Object[] arguments; } - private final HashMap map = new HashMap(); // from ThreadId to Stack of Item + private final HashMap<ThreadId, Stack<Item>> map = new HashMap<ThreadId, Stack<Item>>(); // from ThreadId to Stack of Item } diff --git a/jurt/com/sun/star/lib/uno/protocols/urp/urp.java b/jurt/com/sun/star/lib/uno/protocols/urp/urp.java index c9af603478fd..aac00536db92 100644 --- a/jurt/com/sun/star/lib/uno/protocols/urp/urp.java +++ b/jurt/com/sun/star/lib/uno/protocols/urp/urp.java @@ -602,7 +602,7 @@ public final class urp implements IProtocol { private void writeQueuedReleases() throws IOException { for (int i = releaseQueue.size(); i > 0;) { --i; - QueuedRelease r = (QueuedRelease) releaseQueue.get(i); + QueuedRelease r = releaseQueue.get(i); writeRequest( r.internal, r.objectId, r.type, r.method, r.threadId, null, false); @@ -733,5 +733,5 @@ public final class urp implements IProtocol { private String outL1Oid = null; private ITypeDescription outL1Type = null; - private final ArrayList releaseQueue = new ArrayList(); // of QueuedRelease + private final ArrayList<QueuedRelease> releaseQueue = new ArrayList<QueuedRelease>(); // of QueuedRelease } diff --git a/jurt/com/sun/star/lib/util/AsynchronousFinalizer.java b/jurt/com/sun/star/lib/util/AsynchronousFinalizer.java index 2608f3734da3..8839b1194255 100644 --- a/jurt/com/sun/star/lib/util/AsynchronousFinalizer.java +++ b/jurt/com/sun/star/lib/util/AsynchronousFinalizer.java @@ -64,7 +64,7 @@ public final class AsynchronousFinalizer { void run() throws Throwable; } - private static final LinkedList queue = new LinkedList(); + private static final LinkedList<Job> queue = new LinkedList<Job>(); static { Thread t = new Thread() { @@ -77,7 +77,7 @@ public final class AsynchronousFinalizer { queue.wait(); } catch (InterruptedException e) {} } - j = (Job) queue.remove(0); + j = queue.remove(0); } try { j.run(); diff --git a/jurt/com/sun/star/lib/util/UrlToFileMapper.java b/jurt/com/sun/star/lib/util/UrlToFileMapper.java index 57cc19ea04a9..252021c3064e 100644 --- a/jurt/com/sun/star/lib/util/UrlToFileMapper.java +++ b/jurt/com/sun/star/lib/util/UrlToFileMapper.java @@ -35,13 +35,13 @@ public final class UrlToFileMapper { // java.net.URLEncoder.encode(String, String) and java.net.URI are only // available since Java 1.4: private static Method urlEncoderEncode; - private static Constructor uriConstructor; - private static Constructor fileConstructor; + private static Constructor<?> uriConstructor; + private static Constructor<File> fileConstructor; static { try { urlEncoderEncode = URLEncoder.class.getMethod( "encode", new Class[] { String.class, String.class }); - Class uriClass = Class.forName("java.net.URI"); + Class<?> uriClass = Class.forName("java.net.URI"); uriConstructor = uriClass.getConstructor( new Class[] { String.class }); fileConstructor = File.class.getConstructor( @@ -90,7 +90,7 @@ public final class UrlToFileMapper { Object uri = uriConstructor.newInstance( new Object[] { encodedUrl }); try { - return (File) fileConstructor.newInstance( + return fileConstructor.newInstance( new Object[] { uri }); } catch (InvocationTargetException e) { if (e.getTargetException() instanceof diff --git a/jurt/com/sun/star/uno/AnyConverter.java b/jurt/com/sun/star/uno/AnyConverter.java index a52ea3784a64..8d23dfd41c22 100644 --- a/jurt/com/sun/star/uno/AnyConverter.java +++ b/jurt/com/sun/star/uno/AnyConverter.java @@ -354,7 +354,7 @@ public class AnyConverter * @throws com.sun.star.lang.IllegalArgumentException * in case conversion is not possible */ - static public Object toObject(Class clazz, Object object) + static public Object toObject(Class<?> clazz, Object object) throws com.sun.star.lang.IllegalArgumentException { return toObject( new Type( clazz ), object ); diff --git a/jurt/com/sun/star/uno/WeakReference.java b/jurt/com/sun/star/uno/WeakReference.java index e112a62a8251..9d39e61029ee 100644 --- a/jurt/com/sun/star/uno/WeakReference.java +++ b/jurt/com/sun/star/uno/WeakReference.java @@ -52,7 +52,7 @@ public class WeakReference XWeak weak= UnoRuntime.queryInterface(XWeak.class, weakImpl); if (weak != null) { - XAdapter adapter= (XAdapter) weak.queryAdapter(); + XAdapter adapter= weak.queryAdapter(); if (adapter != null) m_listener= new OWeakRefListener(adapter); } @@ -68,7 +68,7 @@ public class WeakReference XWeak weak= UnoRuntime.queryInterface(XWeak.class, obj); if (weak != null) { - XAdapter adapter= (XAdapter) weak.queryAdapter(); + XAdapter adapter= weak.queryAdapter(); if (adapter != null) m_listener= new OWeakRefListener(adapter); } |