You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gh...@apache.org on 2006/06/21 23:56:52 UTC
svn commit: r416121 - in
/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java:
java/lang/ org/apache/harmony/luni/internal/net/www/protocol/http/
org/apache/harmony/luni/internal/reflect/ org/apache/harmony/luni/net/
org/apache/harmony...
Author: gharley
Date: Wed Jun 21 14:56:51 2006
New Revision: 416121
URL: http://svn.apache.org/viewvc?rev=416121&view=rev
Log:
Fix up type safety warnings. Added in stub implementation of SuppressWarnings annotation whose meta annotations do not currently compile on Eclipse (OK on modern compiler).
Added:
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/SuppressWarnings.java (with props)
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/Header.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyClassFile.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyMethod.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/NetUtil.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainDatagramSocketImpl.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/AbstractMemorySpy.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/AdapterManager.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/PriviAction.java
Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/SuppressWarnings.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/SuppressWarnings.java?rev=416121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/SuppressWarnings.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/SuppressWarnings.java Wed Jun 21 14:56:51 2006
@@ -0,0 +1,22 @@
+/**
+ *
+ */
+package java.lang;
+
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.ElementType;
+
+/**
+ * Stub implementation
+ */
+// GCH -- below lines do not compile inside Eclipse (OK with RI javac & jsr14
+// target)
+//@Target( { ElementType.TYPE, ElementType.FIELD, ElementType.METHOD,
+// ElementType.PARAMETER, ElementType.CONSTRUCTOR,
+// ElementType.LOCAL_VARIABLE })
+//@Retention(RetentionPolicy.SOURCE)
+public @interface SuppressWarnings {
+ public String[] value();
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/SuppressWarnings.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/Header.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/Header.java?rev=416121&r1=416120&r2=416121&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/Header.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/Header.java Wed Jun 21 14:56:51 2006
@@ -76,6 +76,7 @@
}
}
+ @SuppressWarnings("unchecked")
public Object clone() {
try {
Header clone = (Header) super.clone();
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java?rev=416121&r1=416120&r2=416121&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java Wed Jun 21 14:56:51 2006
@@ -32,11 +32,13 @@
import java.net.ProxySelector;
import java.net.ResponseCache;
import java.net.Socket;
-import java.net.SocketAddress;
import java.net.SocketPermission;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+import java.net.UnknownServiceException;
import java.security.AccessController;
import java.security.Permission;
import java.text.SimpleDateFormat;
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyClassFile.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyClassFile.java?rev=416121&r1=416120&r2=416121&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyClassFile.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyClassFile.java Wed Jun 21 14:56:51 2006
@@ -261,7 +261,7 @@
allMethods.add(new ProxyMethod(ObjectHashCodeMethod));
allMethods.add(new ProxyMethod(ObjectToStringMethod));
- HashSet interfacesSeen = new HashSet();
+ HashSet<Class> interfacesSeen = new HashSet<Class>();
for (int i = 0, length = interfaces.length; i < length; i++)
findMethods(interfaces[i], allMethods, interfacesSeen);
@@ -270,7 +270,7 @@
}
private void findMethods(Class nextInterface, ArrayList<ProxyMethod> allMethods,
- HashSet interfacesSeen) {
+ HashSet<Class> interfacesSeen) {
// add the nextInterface's methods to allMethods
// if an equivalent method already exists then return types must be
// identical... don't replace it
@@ -284,7 +284,7 @@
nextMethod: for (int i = 0, length = methods.length; i < length; i++) {
Method method = methods[i];
for (int j = 0; j < existingMethodCount; j++)
- if (((ProxyMethod) allMethods.get(j)).matchMethod(method))
+ if (allMethods.get(j).matchMethod(method))
continue nextMethod;
allMethods.add(new ProxyMethod(method));
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyMethod.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyMethod.java?rev=416121&r1=416120&r2=416121&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyMethod.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyMethod.java Wed Jun 21 14:56:51 2006
@@ -80,9 +80,9 @@
} else {
int cLength = commonExceptions.length;
nextException: for (int c = 0, cL = cLength, oL = otherExceptions.length; c < cL; c++) {
- Class cException = commonExceptions[c];
+ Class<?> cException = commonExceptions[c];
for (int o = 0; o < oL; o++) {
- Class oException = otherExceptions[o];
+ Class<?> oException = otherExceptions[o];
if (cException == oException)
continue nextException;
if (oException.isAssignableFrom(cException))
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/NetUtil.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/NetUtil.java?rev=416121&r1=416120&r2=416121&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/NetUtil.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/NetUtil.java Wed Jun 21 14:56:51 2006
@@ -46,12 +46,13 @@
if(null != proxy && Proxy.Type.SOCKS == proxy.type()){
return true;
}
- String proxySet = (String) AccessController
- .doPrivileged(new PriviAction("socksProxySet")); //$NON-NLS-1$
+ String proxySet = AccessController
+ .doPrivileged(new PriviAction<String>("socksProxySet")); //$NON-NLS-1$
if (proxySet != null) {
return proxySet.toLowerCase().equals("true"); //$NON-NLS-1$
}
- return AccessController.doPrivileged(new PriviAction("socksProxyHost")) != null; //$NON-NLS-1$
+ return AccessController.doPrivileged(new PriviAction<String>(
+ "socksProxyHost")) != null; //$NON-NLS-1$
}
/**
@@ -60,7 +61,7 @@
* @return boolean
*/
public static boolean preferIPv6Addresses() {
- String result = (String) AccessController.doPrivileged(new PriviAction(
+ String result = AccessController.doPrivileged(new PriviAction<String>(
"java.net.preferIPv6Addresses")); //$NON-NLS-1$
return "true".equals(result); //$NON-NLS-1$
}
@@ -71,7 +72,7 @@
* @return boolean
*/
public static boolean preferIPv4Stack() {
- String result = (String) AccessController.doPrivileged(new PriviAction(
+ String result = AccessController.doPrivileged(new PriviAction<String>(
"java.net.preferIPv4Stack")); //$NON-NLS-1$
return "true".equals(result); //$NON-NLS-1$
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainDatagramSocketImpl.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainDatagramSocketImpl.java?rev=416121&r1=416120&r2=416121&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainDatagramSocketImpl.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainDatagramSocketImpl.java Wed Jun 21 14:56:51 2006
@@ -131,7 +131,7 @@
* already bound
*/
public void bind(int port, InetAddress addr) throws SocketException {
- String prop = (String) AccessController.doPrivileged(new PriviAction(
+ String prop = AccessController.doPrivileged(new PriviAction<String>(
"bindToDevice"));
boolean useBindToDevice = prop != null
&& prop.toLowerCase().equals("true");
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java?rev=416121&r1=416120&r2=416121&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java Wed Jun 21 14:56:51 2006
@@ -404,8 +404,8 @@
return addr.getPort();
}
- String proxyPort = (String) AccessController
- .doPrivileged(new PriviAction("socksProxyPort"));
+ String proxyPort = AccessController
+ .doPrivileged(new PriviAction<String>("socksProxyPort"));
if (proxyPort != null) {
portValue = Integer.parseInt(proxyPort);
@@ -431,8 +431,8 @@
}
}else{
// get from system properties
- proxyName = (String) AccessController
- .doPrivileged(new PriviAction("socksProxyHost"));
+ proxyName = AccessController
+ .doPrivileged(new PriviAction<String>("socksProxyHost"));
}
InetAddress anAddr = netImpl.getHostByName(proxyName,
NetUtil.preferIPv6Addresses());
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/AbstractMemorySpy.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/AbstractMemorySpy.java?rev=416121&r1=416120&r2=416121&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/AbstractMemorySpy.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/AbstractMemorySpy.java Wed Jun 21 14:56:51 2006
@@ -29,11 +29,11 @@
abstract class AbstractMemorySpy implements IMemorySpy {
// TODO: figure out how to prevent this being a synchronization bottleneck
- protected Map<PlatformAddress,AddressWrapper> memoryInUse = new HashMap(); // Shadow to Wrapper
+ protected Map<PlatformAddress,AddressWrapper> memoryInUse = new HashMap<PlatformAddress, AddressWrapper>(); // Shadow to Wrapper
- protected Map<Reference,PlatformAddress> refToShadow = new HashMap(); // Reference to Shadow
+ protected Map<Reference,PlatformAddress> refToShadow = new HashMap<Reference, PlatformAddress>(); // Reference to Shadow
- protected ReferenceQueue notifyQueue = new ReferenceQueue();
+ protected ReferenceQueue<Object> notifyQueue = new ReferenceQueue<Object>();
protected Object lock = new Object();
@@ -42,7 +42,7 @@
final long size;
- final PhantomReference wrAddress;
+ final PhantomReference<PlatformAddress> wrAddress;
volatile boolean autoFree = false;
@@ -50,7 +50,7 @@
super();
this.shadow = PlatformAddress.on(address);
this.size = size;
- this.wrAddress = new PhantomReference(address, notifyQueue);
+ this.wrAddress = new PhantomReference<PlatformAddress>(address, notifyQueue);
}
}
@@ -69,7 +69,7 @@
public boolean free(PlatformAddress address) {
AddressWrapper wrapper;
synchronized (lock) {
- wrapper = (AddressWrapper) memoryInUse.remove(address);
+ wrapper = memoryInUse.remove(address);
}
if (wrapper == null) {
// Attempt to free memory we didn't alloc
@@ -92,7 +92,7 @@
public void autoFree(PlatformAddress address) {
AddressWrapper wrapper;
synchronized (lock) {
- wrapper = (AddressWrapper) memoryInUse.get(address);
+ wrapper = memoryInUse.get(address);
}
if (wrapper != null) {
wrapper.autoFree = true;
@@ -103,7 +103,7 @@
AddressWrapper wrapper;
synchronized (lock) {
PlatformAddress shadow = refToShadow.remove(ref);
- wrapper = (AddressWrapper) memoryInUse.remove(shadow);
+ wrapper = memoryInUse.remove(shadow);
}
ref.clear();
if (wrapper != null) {
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/AdapterManager.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/AdapterManager.java?rev=416121&r1=416120&r2=416121&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/AdapterManager.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/AdapterManager.java Wed Jun 21 14:56:51 2006
@@ -31,10 +31,10 @@
* key is adaptable type, and value is list of adapter factories for that
* type.
*/
- private final HashMap factories = new HashMap();
+ private final HashMap<Class, List<IAdapterFactory>> factories = new HashMap<Class, List<IAdapterFactory>>();
public Object getAdapter(IAdaptable adaptable, Class adapterType) {
- List factoryList = (List) factories.get(adaptable);
+ List factoryList = factories.get(adaptable);
if (factoryList != null) {
for (Iterator factoryItr = factoryList.iterator(); factoryItr
.hasNext();) {
@@ -53,25 +53,25 @@
}
public void registerAdapters(IAdapterFactory factory, Class adaptable) {
- List factoryList = (List) factories.get(adaptable);
+ List<IAdapterFactory> factoryList = factories.get(adaptable);
if (factoryList == null) {
- factoryList = new ArrayList();
+ factoryList = new ArrayList<IAdapterFactory>();
factories.put(adaptable, factoryList);
}
factoryList.add(factory);
}
public void unregisterAdapters(IAdapterFactory factory, Class adaptable) {
- List factoryList = (List) factories.get(adaptable);
+ List factoryList = factories.get(adaptable);
if (factoryList != null) {
factoryList.remove(factory);
}
}
public void unregisterAdapters(IAdapterFactory factory) {
- for (Iterator knownAdaptablesItr = factories.keySet().iterator(); knownAdaptablesItr
+ for (Iterator<Class> knownAdaptablesItr = factories.keySet().iterator(); knownAdaptablesItr
.hasNext();) {
- Class adaptable = (Class) knownAdaptablesItr.next();
+ Class adaptable = knownAdaptablesItr.next();
unregisterAdapters(factory, adaptable);
}
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/PriviAction.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/PriviAction.java?rev=416121&r1=416120&r2=416121&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/PriviAction.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/PriviAction.java Wed Jun 21 14:56:51 2006
@@ -120,7 +120,8 @@
*
* @see java.security.PrivilegedAction#run()
*/
- public T run() {
+ @SuppressWarnings("unchecked")
+ public T run() {
switch (action) {
case GET_SYSTEM_PROPERTY:
return (T)System.getProperty((String) arg1, (String) arg2);