You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/06/17 06:26:59 UTC

svn commit: r414997 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java: lang/ lang/reflect/ net/

Author: ndbeyer
Date: Fri Jun 16 21:26:56 2006
New Revision: 414997

URL: http://svn.apache.org/viewvc?rev=414997&view=rev
Log:
Code cleanup; generification, etc

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/InstantiationError.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/InstantiationException.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/SecurityManager.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Void.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Proxy.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ContentHandler.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Inet6Address.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/MulticastSocket.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NegativeCache.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NetworkInterface.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ProxySelectorImpl.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/InstantiationError.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/InstantiationError.java?rev=414997&r1=414996&r2=414997&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/InstantiationError.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/InstantiationError.java Fri Jun 16 21:26:56 2006
@@ -21,7 +21,7 @@
  * create a new instance of a class which has no visible constructors from the
  * location where new is invoked.
  * <p>
- * Note that this can only occur when inconsistant class files are being loaded.
+ * Note that this can only occur when inconsistent class files are being loaded.
  * 
  */
 public class InstantiationError extends IncompatibleClassChangeError {
@@ -53,7 +53,7 @@
 	 * @param clazz
 	 *            Class The class which cannot be instantiated.
 	 */
-	InstantiationError(Class clazz) {
+	InstantiationError(Class<?> clazz) {
 		super(clazz.getName());
 	}
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/InstantiationException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/InstantiationException.java?rev=414997&r1=414996&r2=414997&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/InstantiationException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/InstantiationException.java Fri Jun 16 21:26:56 2006
@@ -50,7 +50,7 @@
 	 * @param clazz
 	 *            Class The class which cannot be instantiated.
 	 */
-	InstantiationException(Class clazz) {
+	InstantiationException(Class<?> clazz) {
 		super(clazz.getName());
 	}
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/SecurityManager.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/SecurityManager.java?rev=414997&r1=414996&r2=414997&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/SecurityManager.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/SecurityManager.java Fri Jun 16 21:26:56 2006
@@ -60,10 +60,13 @@
 	 */
 	public SecurityManager() {
 		SecurityManager security = System.getSecurityManager();
-		if (security != null)
-			security
-					.checkPermission(RuntimePermission.permissionToCreateSecurityManager);
-		Class type = Security.class; // initialize Security properties
+		if (security != null) {
+            security.checkPermission(RuntimePermission.permissionToCreateSecurityManager);
+        }
+		Class<?> type = Security.class; // initialize Security properties
+        if (type == null) {
+            throw new AssertionError();
+        }
 	}
 
 	/**
@@ -76,8 +79,9 @@
 	 *            the port number to check
 	 */
 	public void checkAccept(String host, int port) {
-		if (host == null)
-			throw new NullPointerException();
+		if (host == null) {
+            throw new NullPointerException();
+        }
 		checkPermission(new SocketPermission(host + ':' + port, "accept"));
 	}
 
@@ -90,8 +94,9 @@
 	public void checkAccess(Thread thread) {
 		// Only worry about system threads. Dead threads have a null group.
 		ThreadGroup group = thread.getThreadGroup();
-		if ((group != null) && (group.parent == null))
-			checkPermission(RuntimePermission.permissionToModifyThread);
+		if ((group != null) && (group.parent == null)) {
+            checkPermission(RuntimePermission.permissionToModifyThread);
+        }
 	}
 
 	/**
@@ -103,10 +108,12 @@
 	 */
 	public void checkAccess(ThreadGroup group) {
 		// Only worry about system threads.
-		if (group == null)
-			throw new NullPointerException();
-		if (group.parent == null)
-			checkPermission(RuntimePermission.permissionToModifyThreadGroup);
+		if (group == null) {
+            throw new NullPointerException();
+        }
+		if (group.parent == null) {
+            checkPermission(RuntimePermission.permissionToModifyThreadGroup);
+        }
 	}
 
 	/**
@@ -120,12 +127,14 @@
 	 *            int the port number to check, or -1 for resolve.
 	 */
 	public void checkConnect(String host, int port) {
-		if (host == null)
-			throw new NullPointerException();
-		if (port > 0)
-			checkPermission(new SocketPermission(host + ':' + port, "connect"));
-		else
-			checkPermission(new SocketPermission(host, "resolve"));
+		if (host == null) {
+            throw new NullPointerException();
+        }
+		if (port > 0) {
+            checkPermission(new SocketPermission(host + ':' + port, "connect"));
+        } else {
+            checkPermission(new SocketPermission(host, "resolve"));
+        }
 	}
 
 	/**
@@ -141,11 +150,12 @@
 	 *            Object the security context to use for the check.
 	 */
 	public void checkConnect(String host, int port, Object context) {
-		if (port > 0)
-			checkPermission(new SocketPermission(host + ':' + port, "connect"),
+		if (port > 0) {
+            checkPermission(new SocketPermission(host + ':' + port, "connect"),
 					context);
-		else
-			checkPermission(new SocketPermission(host, "resolve"), context);
+        } else {
+            checkPermission(new SocketPermission(host, "resolve"), context);
+        }
 	}
 
 	/**
@@ -189,15 +199,16 @@
 	}
 
 	/**
-	 * Checks whether the running program is allowed to load the specifed native
+	 * Checks whether the running program is allowed to load the specified native
 	 * library.
 	 * 
 	 * @param libName
 	 *            the name of the library to load
 	 */
 	public void checkLink(String libName) {
-		if (libName == null)
-			throw new NullPointerException();
+		if (libName == null) {
+            throw new NullPointerException();
+        }
 		checkPermission(new RuntimePermission("loadLibrary." + libName));
 	}
 
@@ -209,12 +220,13 @@
 	 *            int the port number to check
 	 */
 	public void checkListen(int port) {
-		if (port == 0)
-			checkPermission(new SocketPermission("localhost:1024-",
+		if (port == 0) {
+            checkPermission(new SocketPermission("localhost:1024-",
 					"listen"));
-		else
-			checkPermission(new SocketPermission("localhost:" + port,
+        } else {
+            checkPermission(new SocketPermission("localhost:" + port,
 					"listen"));
+        }
 	}
 
 	/**
@@ -232,10 +244,12 @@
 	 *            Either java.lang.reflect.Member.PUBLIC or DECLARED
 	 */
 	public void checkMemberAccess(Class<?> cls, int type) {
-		if (cls == null)
-			throw new NullPointerException();
-		if (type == Member.PUBLIC)
-			return;
+		if (cls == null) {
+            throw new NullPointerException();
+        }
+		if (type == Member.PUBLIC) {
+            return;
+        }
 		//
 		// Need to compare the classloaders.
 		// Stack shape is
@@ -246,8 +260,9 @@
 		//
 		// Use getClassLoaderImpl() since getClassLoader()
 		// returns null for the bootstrap class loader.
-		if (ClassLoader.getStackClassLoader(3) == cls.getClassLoaderImpl())
-			return;
+		if (ClassLoader.getStackClassLoader(3) == cls.getClassLoaderImpl()) {
+            return;
+        }
 
 		// Forward off to the permission mechanism.
 		checkPermission(new RuntimePermission("accessDeclaredMembers"));
@@ -281,8 +296,9 @@
 	 *            the name of the package to be accessed.
 	 */
 	public void checkPackageAccess(String packageName) {
-		if (packageName == null)
-			throw new NullPointerException();
+		if (packageName == null) {
+            throw new NullPointerException();
+        }
 		if (securePackageList == null) {
 			String securePackages = getSecurityProperty("package.access");
 			if (securePackages != null) {
@@ -314,8 +330,9 @@
 	 *            the name of the package to add a class to.
 	 */
 	public void checkPackageDefinition(String packageName) {
-		if (packageName == null)
-			throw new NullPointerException();
+		if (packageName == null) {
+            throw new NullPointerException();
+        }
 		String securePackages = getSecurityProperty("package.definition");
 		if (securePackages != null) {
 			StringTokenizer tokenizer = new StringTokenizer(securePackages,
@@ -362,8 +379,9 @@
 	 *            the file descriptor of the file to check
 	 */
 	public void checkRead(FileDescriptor fd) {
-		if (fd == null)
-			throw new NullPointerException();
+		if (fd == null) {
+            throw new NullPointerException();
+        }
 		checkPermission(RuntimePermission.permissionToReadFileDescriptor);
 	}
 
@@ -418,12 +436,13 @@
 	 *            The non-null window for which to check access
 	 */
 	public boolean checkTopLevelWindow(Object window) {
-		if (window == null)
-			throw new NullPointerException();
+		if (window == null) {
+            throw new NullPointerException();
+        }
 		try {
-			Class awtPermission = Class.forName("java.awt.AWTPermission");
+			Class<?> awtPermission = Class.forName("java.awt.AWTPermission");
 			Class[] args = new Class[] { java.lang.String.class };
-			Constructor constructor = awtPermission.getConstructor(args);
+			Constructor<?> constructor = awtPermission.getConstructor(args);
 			Object[] constructorArgs = new Object[] { "showWindowWithoutWarningBanner" };
 			Permission perm = (Permission) constructor.newInstance(constructorArgs);
 			checkPermission(perm);
@@ -444,9 +463,9 @@
 	 */
 	public void checkSystemClipboardAccess() {
 		try {
-			Class awtPermission = Class.forName("java.awt.AWTPermission");
+			Class<?> awtPermission = Class.forName("java.awt.AWTPermission");
 			Class[] args = new Class[] { String.class };
-			Constructor constructor = awtPermission.getConstructor(args);
+			Constructor<?> constructor = awtPermission.getConstructor(args);
 			Object[] constructorArgs = new Object[] { "accessClipboard" };
 			Permission perm = (Permission) constructor.newInstance(constructorArgs);
 			checkPermission(perm);
@@ -466,9 +485,9 @@
 	 */
 	public void checkAwtEventQueueAccess() {
 		try {
-			Class awtPermission = Class.forName("java.awt.AWTPermission");
+			Class<?> awtPermission = Class.forName("java.awt.AWTPermission");
 			Class[] ar = new Class[] { String.class };
-			Constructor constructor = awtPermission.getConstructor(ar);
+			Constructor<?> constructor = awtPermission.getConstructor(ar);
 			Object[] constructorArgs = new Object[] { "accessEventQueue" };
 			Permission perm = (Permission) constructor.newInstance(constructorArgs);
 			checkPermission(perm);
@@ -497,8 +516,9 @@
 	 *            the file descriptor of the file to check
 	 */
 	public void checkWrite(FileDescriptor fd) {
-		if (fd == null)
-			throw new NullPointerException();
+		if (fd == null) {
+            throw new NullPointerException();
+        }
 		checkPermission(RuntimePermission.permissionToWriteFileDescriptor);
 	}
 
@@ -560,14 +580,15 @@
 		Class[] classes = Class.getStackClasses(-1, true);
 		for (int i = 0; i < classes.length; i++) {
 			ClassLoader cl = classes[i].getClassLoaderImpl();
-			if (!cl.isSystemClassLoader())
-				return cl;
+			if (!cl.isSystemClassLoader()) {
+                return cl;
+            }
 		}
 		return null;
 	}
 
 	/**
-	 * Answers the index in the stack of thee first class whose class loader is
+	 * Answers the index in the stack of three first class whose class loader is
 	 * not a system class loader.
 	 * 
 	 * @return int the frame index of the first method whose class was loaded by
@@ -591,8 +612,9 @@
 		Class[] classes = Class.getStackClasses(-1, true);
 		for (int i = 0; i < classes.length; i++) {
 			ClassLoader cl = classes[i].getClassLoaderImpl();
-			if (!cl.isSystemClassLoader())
-				return i;
+			if (!cl.isSystemClassLoader()) {
+                return i;
+            }
 		}
 		return -1;
 	}
@@ -621,8 +643,9 @@
 		Class[] classes = Class.getStackClasses(-1, true);
 		for (int i = 0; i < classes.length; i++) {
 			ClassLoader cl = classes[i].getClassLoaderImpl();
-			if (!cl.isSystemClassLoader())
-				return classes[i];
+			if (!cl.isSystemClassLoader()) {
+                return classes[i];
+            }
 		}
 		return null;
 	}
@@ -640,9 +663,11 @@
 	 */
 	protected int classDepth(String name) {
 		Class[] classes = Class.getStackClasses(-1, false);
-		for (int i = 0; i < classes.length; i++)
-			if (classes[i].getName().equals(name))
-				return i;
+		for (int i = 0; i < classes.length; i++) {
+            if (classes[i].getName().equals(name)) {
+                return i;
+            }
+        }
 		return -1;
 	}
 
@@ -720,10 +745,11 @@
 			// Must be an AccessControlContext. If we don't check
 			// this, then applications could pass in an arbitrary
 			// object which circumvents the security check.
-			if (context instanceof AccessControlContext)
-				((AccessControlContext) context).checkPermission(permission);
-			else
-				throw new SecurityException();
+			if (context instanceof AccessControlContext) {
+                ((AccessControlContext) context).checkPermission(permission);
+            } else {
+                throw new SecurityException();
+            }
 		} finally {
 			inCheck = false;
 		}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Void.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Void.java?rev=414997&r1=414996&r2=414997&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Void.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Void.java Fri Jun 16 21:26:56 2006
@@ -15,6 +15,8 @@
 
 package java.lang;
 
+import java.lang.reflect.Method;
+
 /**
  * This class is a placeholder class for the Java keyword <code>void</code>
  * @since 1.1
@@ -30,16 +32,15 @@
 	// defined to be "java.lang.Void.TYPE";
 
 	static {
-		Class voidType = null;
-		try {
-			java.lang.reflect.Method method = Runnable.class.getMethod("run",
-					new Class[0]);
-			voidType = method.getReturnType();
-		} catch (Exception e) {
-			throw new RuntimeException(e);
-		}
-		TYPE = voidType;
-	}
+        Class<?> voidType = null;
+        try {
+            Method method = Runnable.class.getMethod("run", new Class[0]);
+            voidType = method.getReturnType();
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        TYPE = (Class<Void>) voidType;
+    }
 
 	private Void() {
 	}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Proxy.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Proxy.java?rev=414997&r1=414996&r2=414997&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Proxy.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Proxy.java Fri Jun 16 21:26:56 2006
@@ -75,45 +75,53 @@
 	public static Class<?> getProxyClass(ClassLoader loader, Class<?>[] interfaces)
 			throws IllegalArgumentException {
 		// check that interfaces are a valid array of visible interfaces
-		if (interfaces == null)
-			throw new NullPointerException();
+		if (interfaces == null) {
+            throw new NullPointerException();
+        }
 		String commonPackageName = null;
 		for (int i = 0, length = interfaces.length; i < length; i++) {
-			Class next = interfaces[i];
-			if (next == null)
-				throw new NullPointerException();
+			Class<?> next = interfaces[i];
+			if (next == null) {
+                throw new NullPointerException();
+            }
 			String name = next.getName();
-			if (!next.isInterface())
-				throw new IllegalArgumentException(Msg.getString("K00ed", name));
+			if (!next.isInterface()) {
+                throw new IllegalArgumentException(Msg.getString("K00ed", name));
+            }
 			if (loader != next.getClassLoader()) {
 				try {
-					if (next != Class.forName(name, false, loader))
-						throw new IllegalArgumentException(Msg.getString(
+					if (next != Class.forName(name, false, loader)) {
+                        throw new IllegalArgumentException(Msg.getString(
 								"K00ee", name));
+                    }
 				} catch (ClassNotFoundException ex) {
 					throw new IllegalArgumentException(Msg.getString("K00ee",
 							name));
 				}
 			}
-			for (int j = i + 1; j < length; j++)
-				if (next == interfaces[j])
-					throw new IllegalArgumentException(Msg.getString("K00ef",
+			for (int j = i + 1; j < length; j++) {
+                if (next == interfaces[j]) {
+                    throw new IllegalArgumentException(Msg.getString("K00ef",
 							name));
+                }
+            }
 			if (!Modifier.isPublic(next.getModifiers())) {
 				int last = name.lastIndexOf('.');
 				String p = last == -1 ? "" : name.substring(0, last);
-				if (commonPackageName == null)
-					commonPackageName = p;
-				else if (!commonPackageName.equals(p))
-					throw new IllegalArgumentException(Msg.getString("K00f0"));
+				if (commonPackageName == null) {
+                    commonPackageName = p;
+                } else if (!commonPackageName.equals(p)) {
+                    throw new IllegalArgumentException(Msg.getString("K00f0"));
+                }
 			}
 		}
 
 		// search cache for matching proxy class using the class loader
 		synchronized (loaderCache) {
 			Map<String, WeakReference<Class<?>>> interfaceCache = loaderCache.get(loader);
-			if (interfaceCache == null)
-				loaderCache.put(loader, (interfaceCache = new HashMap<String, WeakReference<Class<?>>>()));
+			if (interfaceCache == null) {
+                loaderCache.put(loader, (interfaceCache = new HashMap<String, WeakReference<Class<?>>>()));
+            }
 
 			String interfaceKey = "";
 			if (interfaces.length == 1) {
@@ -131,12 +139,14 @@
 			WeakReference<Class<?>> ref = interfaceCache.get(interfaceKey);
 			if (ref == null) {
 				String nextClassName = "$Proxy" + NextClassNameIndex++;
-				if (commonPackageName != null)
-					nextClassName = commonPackageName + "." + nextClassName;
+				if (commonPackageName != null) {
+                    nextClassName = commonPackageName + "." + nextClassName;
+                }
 				byte[] classFileBytes = ProxyClassFile.generateBytes(
 						nextClassName, interfaces);
-				if (loader == null)
-					loader = ClassLoader.getSystemClassLoader();
+				if (loader == null) {
+                    loader = ClassLoader.getSystemClassLoader();
+                }
 				newClass = defineClassImpl(loader, nextClassName.replace('.',
 						'/'), classFileBytes);
 				// Need a weak reference to the class so it can
@@ -223,8 +233,9 @@
 	 */
 	public static InvocationHandler getInvocationHandler(Object proxy)
 			throws IllegalArgumentException {
-		if (isProxyClass(proxy.getClass()))
-			return ((Proxy) proxy).h;
+		if (isProxyClass(proxy.getClass())) {
+            return ((Proxy) proxy).h;
+        }
 
 		throw new IllegalArgumentException(Msg.getString("K00f1"));
 	}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ContentHandler.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ContentHandler.java?rev=414997&r1=414996&r2=414997&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ContentHandler.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ContentHandler.java Fri Jun 16 21:26:56 2006
@@ -15,7 +15,6 @@
 
 package java.net;
 
-
 import java.io.IOException;
 
 /**
@@ -27,16 +26,16 @@
  * @see URL
  * @see URLConnection#getContent()
  */
-abstract public class ContentHandler {
+public abstract class ContentHandler {
 	/**
 	 * Answers the object pointed by the specified URL Connection
 	 * <code>uConn</code>.
 	 * 
-	 * @return java.lang.Object the object refered by <code>uConn</code>
+	 * @return java.lang.Object the object referred by <code>uConn</code>
 	 * @param uConn
-	 *            java.net.URLConnection the url connection that points to the
+	 *            URLConnection the URL connection that points to the
 	 *            desired object
-	 * @exception java.io.IOException
+	 * @throws IOException
 	 *                thrown if an IO error occurs during the retrieval of the
 	 *                object
 	 */
@@ -47,25 +46,25 @@
 	 * <code>uConn</code>.
 	 * 
 	 * @param uConn
-	 *            java.net.URLConnection the url connection that points to the
+	 *            java.net.URLConnection the URL connection that points to the
 	 *            desired object
 	 * @param types
 	 *            The list of acceptable content types
 	 * @return Object The object of the resource pointed by this URL, or null if
 	 *         the content does not match a specified content type.
 	 * 
-	 * @exception IOException
-	 *                If an error occured obtaining the content.
+	 * @throws IOException
+	 *                If an error occurred obtaining the content.
 	 */
 	public Object getContent(URLConnection uConn, Class[] types)
-			throws IOException {
-		Object content = getContent(uConn);
-		Class cl = content.getClass();
-		for (int i = 0; i < types.length; i++) {
-			if (cl == types[i]) {
-				return content;
-			}
-		}
-		return null;
-	}
+            throws IOException {
+        Object content = getContent(uConn);
+        Class<?> cl = content.getClass();
+        for (int i = 0; i < types.length; i++) {
+            if (cl == types[i]) {
+                return content;
+            }
+        }
+        return null;
+    }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Inet6Address.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Inet6Address.java?rev=414997&r1=414996&r2=414997&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Inet6Address.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Inet6Address.java Fri Jun 16 21:26:56 2006
@@ -15,7 +15,6 @@
 
 package java.net;
 
-
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
@@ -131,9 +130,9 @@
 		
 		// find the first address which matches the type addr,
 		// then set the scope_id, ifname and scopedIf.
-		Enumeration addressList = nif.getInetAddresses();
+		Enumeration<InetAddress> addressList = nif.getInetAddresses();
 		while (addressList.hasMoreElements()) {
-			InetAddress ia = (InetAddress) addressList.nextElement();
+			InetAddress ia = addressList.nextElement();
 			if (ia.getAddress().length == 16) {
 				Inet6Address v6ia = (Inet6Address) ia;
 				boolean isSameType = v6ia.compareLocalType(address);
@@ -156,7 +155,7 @@
 	}
 	
 
-	/*
+	/**
 	 * Returns true if one of following cases is true:
 	 * 1. both addresses are site local;
 	 * 2. both addresses are link local;
@@ -203,20 +202,21 @@
 	 */
 	public boolean isMulticastAddress() {
 
-		// mutlicast addresses are prefixed with 11111111 (255)
+		// Multicast addresses are prefixed with 11111111 (255)
 		return ipaddress[0] == -1;
 	}
 
 	/**
-	 * Answer true if the InetAddress is the unspecified adddress "::".
+	 * Answer true if the InetAddress is the unspecified address "::".
 	 * 
 	 * @return boolean true, if the address is in the multicast group, false
 	 *         otherwise
 	 */
 	public boolean isAnyLocalAddress() {
 		for (int i = 0; i < ipaddress.length; i++) {
-			if (ipaddress[i] != 0)
-				return false;
+			if (ipaddress[i] != 0) {
+                return false;
+            }
 		}
 		return true;
 	}
@@ -276,7 +276,7 @@
 	 * 
 	 * A valid IPv6 global multicast address is 11111111xxxx1110 (i.e. FF0E)
 	 * 
-	 * @return boolean true, if it is a global mutlicast address, false
+	 * @return boolean true, if it is a global multicast address, false
 	 *         otherwise
 	 */
 	public boolean isMCGlobal() {
@@ -289,10 +289,10 @@
 	/**
 	 * Answer true if the InetAddress is a node-local multicast address.
 	 * 
-	 * A valid IPv6 node-local mutlicast address is prefixed with
+	 * A valid IPv6 node-local multicast address is prefixed with
 	 * 11111111xxxx0001
 	 * 
-	 * @return boolean true, if it is a node-local mutlicast address, false
+	 * @return boolean true, if it is a node-local multicast address, false
 	 *         otherwise
 	 */
 	public boolean isMCNodeLocal() {
@@ -306,10 +306,10 @@
 	/**
 	 * Answer true if the InetAddress is a link-local multicast address.
 	 * 
-	 * A valid IPv6 link-local mutlicast address is prefixed with
+	 * A valid IPv6 link-local multicast address is prefixed with
 	 * 11111111xxxx0010
 	 * 
-	 * @return boolean true, if it is a link-local mutlicast address, false
+	 * @return boolean true, if it is a link-local multicast address, false
 	 *         otherwise
 	 */
 	public boolean isMCLinkLocal() {
@@ -323,10 +323,10 @@
 	/**
 	 * Answer true if the InetAddress is a site-local multicast address.
 	 * 
-	 * A valid IPv6 site-local mutlicast address is prefixed with
+	 * A valid IPv6 site-local multicast address is prefixed with
 	 * 11111111xxxx0101
 	 * 
-	 * @return boolean true, if it is a site-local mutlicast address, false
+	 * @return boolean true, if it is a site-local multicast address, false
 	 *         otherwise
 	 */
 	public boolean isMCSiteLocal() {
@@ -340,10 +340,10 @@
 	/**
 	 * Answer true if the InetAddress is a org-local multicast address.
 	 * 
-	 * A valid IPv6 org-local mutlicast address is prefixed with
+	 * A valid IPv6 org-local multicast address is prefixed with
 	 * 11111111xxxx1000
 	 * 
-	 * @return boolean true, if it is a org-local mutlicast address, false
+	 * @return boolean true, if it is a org-local multicast address, false
 	 *         otherwise
 	 */
 	public boolean isMCOrgLocal() {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java?rev=414997&r1=414996&r2=414997&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java Fri Jun 16 21:26:56 2006
@@ -111,7 +111,7 @@
 	/**
 	 * Returns the IP address of the argument <code>addr</code> as an array.
 	 * The elements are in network order (the highest order address byte is in
-	 * the zeroeth element).
+	 * the zero-th element).
 	 * 
 	 * @return byte[] the network address as a byte array
 	 */
@@ -147,8 +147,9 @@
 		// now check if their byte arrays match...
 		byte[] objIPaddress = ((InetAddress) obj).ipaddress;
 		for (int i = 0; i < objIPaddress.length; i++) {
-			if (objIPaddress[i] != this.ipaddress[i])
-				return false;
+			if (objIPaddress[i] != this.ipaddress[i]) {
+                return false;
+            }
 		}
 		return true;
 	}
@@ -156,12 +157,12 @@
 	/**
 	 * Returns the IP address of this <code>InetAddress</code> as an array.
 	 * The elements are in network order (the highest order address byte is in
-	 * the zeroeth element).
+	 * the zero-th element).
 	 * 
 	 * @return byte[] the address as a byte array
 	 */
 	public byte[] getAddress() {
-		return (byte[]) ipaddress.clone();
+		return ipaddress.clone();
 	}
 
 	/**
@@ -182,13 +183,15 @@
 		if (host == null) {
 			return new InetAddress[]{preferIPv6Addresses() ? Inet6Address.LOOPBACK : LOOPBACK};
 		}
-		if (0 == host.length())
-			throw new UnknownHostException(Msg.getString("K0038"));
+		if (0 == host.length()) {
+            throw new UnknownHostException(Msg.getString("K0038"));
+        }
 
 		if (isHostName(host)) {
 			SecurityManager security = System.getSecurityManager();
-			if (security != null)
-				security.checkConnect(host, -1);
+			if (security != null) {
+                security.checkConnect(host, -1);
+            }
 			if (Socket.preferIPv4Stack()) {
 				return getAliasesByNameImpl(host);
 			}
@@ -249,16 +252,18 @@
 	 */
 	public static InetAddress getByName(String host)
 			throws UnknownHostException {
-		if (host == null || 0 == host.length())
-			return InetAddress.LOOPBACK;
+		if (host == null || 0 == host.length()) {
+            return InetAddress.LOOPBACK;
+        }
 		if (host.equals("0")) {
 			return InetAddress.ANY;
 		}
 
 		if (isHostName(host)) {
 			SecurityManager security = System.getSecurityManager();
-			if (security != null)
-				security.checkConnect(host, -1);
+			if (security != null) {
+                security.checkConnect(host, -1);
+            }
 			return lookupHostByName(host);
 		}
 		
@@ -303,8 +308,9 @@
 		SecurityManager security = System.getSecurityManager();
 		try {
 			// Only check host names, not addresses
-			if (security != null && isHostName(hostName))
-				security.checkConnect(hostName, -1);
+			if (security != null && isHostName(hostName)) {
+                security.checkConnect(hostName, -1);
+            }
 		} catch (SecurityException e) {
 			return Inet6Util.createIPAddrStringFromByteArray(ipaddress);
 		}
@@ -312,7 +318,7 @@
 }
 
 	/**
-	 * Answers canonical name for the host associated with the inet address
+	 * Answers canonical name for the host associated with the internet address
 	 * 
 	 * @return String string containing the host name
 	 */
@@ -333,8 +339,9 @@
 		SecurityManager security = System.getSecurityManager();
 		try {
 			// Only check host names, not addresses
-			if (security != null && isHostName(canonicalName))
-				security.checkConnect(canonicalName, -1);
+			if (security != null && isHostName(canonicalName)) {
+                security.checkConnect(canonicalName, -1);
+            }
 		} catch (SecurityException e) {
 			return Inet6Util.createIPAddrStringFromByteArray(ipaddress);
 		}
@@ -353,8 +360,9 @@
 		String host = getHostNameImpl();
 		SecurityManager security = System.getSecurityManager();
 		try {
-			if (security != null)
-				security.checkConnect(host, -1);
+			if (security != null) {
+                security.checkConnect(host, -1);
+            }
 		} catch (SecurityException e) {
 			return InetAddress.LOOPBACK;
 		}
@@ -383,26 +391,29 @@
 			throws UnknownHostException {
 		int ttl = -1;
 
-		String ttlValue = (String) AccessController
-				.doPrivileged(new PriviAction("networkaddress.cache.ttl"));
+		String ttlValue = AccessController.doPrivileged(
+                new PriviAction<String>("networkaddress.cache.ttl"));
 		try {
-			if (ttlValue != null)
-				ttl = Integer.decode(ttlValue).intValue();
+			if (ttlValue != null) {
+                ttl = Integer.decode(ttlValue).intValue();
+            }
 		} catch (NumberFormatException e) {
 		}
 		CacheElement element = null;
-		if (ttl == 0)
-			Cache.clear();
-		else {
+		if (ttl == 0) {
+            Cache.clear();
+        } else {
 			element = Cache.get(host);
 			if (element != null
 					&& ttl > 0
 					&& element.timeAdded + (ttl * 1000) < System
-							.currentTimeMillis())
-				element = null;
+							.currentTimeMillis()) {
+                element = null;
+            }
 		}
-		if (element != null)
-			return element.inetAddress();
+		if (element != null) {
+            return element.inetAddress();
+        }
 		
 		// now try the negative cache
 		String failedMessage = NegativeCache.getFailedMessage(host);
@@ -488,10 +499,12 @@
 	static native String getHostNameImpl();
 
 	static String getHostNameInternal(String host) throws UnknownHostException {
-		if (host == null || 0 == host.length())
-			return InetAddress.LOOPBACK.getHostAddress();
-		if (isHostName(host))
-			return lookupHostByName(host).getHostAddress();
+		if (host == null || 0 == host.length()) {
+            return InetAddress.LOOPBACK.getHostAddress();
+        }
+		if (isHostName(host)) {
+            return lookupHostByName(host).getHostAddress();
+        }
 		return host;
 	}
 
@@ -537,10 +550,11 @@
 
 		static void add(InetAddress value) {
 			CacheElement newElement = value.cacheElement();
-			if (size < maxSize)
-				size++;
-			else
-				deleteTail();
+			if (size < maxSize) {
+                size++;
+            } else {
+                deleteTail();
+            }
 			newElement.next = head; // If the head is null, this does no harm.
 			head = newElement;
 		}
@@ -554,17 +568,20 @@
 				previous = current;
 				current = current.next;
 			}
-			if (notFound)
-				return null;
+			if (notFound) {
+                return null;
+            }
 			moveToHead(current, previous);
 			return current;
 		}
 
 		private static void deleteTail() {
-			if (0 == size)
-				return;
-			if (1 == size)
-				head = null;
+			if (0 == size) {
+                return;
+            }
+			if (1 == size) {
+                head = null;
+            }
 
 			CacheElement previous = null;
 			CacheElement current = head;
@@ -641,7 +658,7 @@
 	 * of flags, and the additional 112 bits make up the global multicast
 	 * address space
 	 * 
-	 * Valid IPv4 global multi-cast addresses are between: 224.0.1.0 to
+	 * Valid IPv4 global multicast addresses are between: 224.0.1.0 to
 	 * 238.255.255.255
 	 * 
 	 * @return boolean
@@ -787,11 +804,11 @@
     private boolean isReachableByMultiThread(NetworkInterface netif,
             final int ttl, final int timeout, final boolean isICMP)
             throws IOException {
-        Enumeration addresses = netif.getInetAddresses();
+        Enumeration<InetAddress> addresses = netif.getInetAddresses();
         reached = false;
         addrCount = netif.addresses.length;
         while (addresses.hasMoreElements()) {
-            final InetAddress addr = (InetAddress) addresses.nextElement();
+            final InetAddress addr = addresses.nextElement();
             new Thread() {
                 public void run() {
                     boolean threadReached = false;
@@ -926,7 +943,7 @@
 				}
 				return new Inet4Address(copy_address);
 			}
-			copy_address = (byte[]) ipAddress.clone();
+			copy_address = ipAddress.clone();
 			return new Inet6Address(copy_address, scope_id);
 		}
 		throw new UnknownHostException(Msg.getString("K0339"));
@@ -990,7 +1007,7 @@
 	 * 
 	 * The high order byte is <code>ipAddress[0]</code>.
 	 *
-	 * @param 		hostName	string representation of hostname or ip address
+	 * @param 		hostName	string representation of hostname or IP address
 	 * @param 		ipAddress	either a 4 (IPv4) or 16 (IPv6) byte array
 	 * @param 		scope_id	the scope id for a scoped address.  If not a scoped address just pass
 	 * 							in 0
@@ -1035,7 +1052,7 @@
 	/**
 	 * Takes the integer and chops it into 4 bytes, putting it into the byte
 	 * array starting with the high order byte at the index start. This method
-	 * makes no checks on the validity of the paramaters.
+	 * makes no checks on the validity of the parameters.
 	 */
 	static void intToBytes(int value, byte bytes[], int start) {
 		// Shift the int so the current byte is right-most
@@ -1107,7 +1124,7 @@
 			int doubleColonIndex = -1; // If a double colon exists, we need to
 										// insert 0s.
 
-			// Go through the tokens, including the seperators ':' and '.'
+			// Go through the tokens, including the separators ':' and '.'
 			// When we hit a : or . the previous token will be added to either
 			// the hex list or decimal list. In the case where we hit a ::
 			// we will save the index of the hexStrings so we can add zeros
@@ -1175,14 +1192,14 @@
 
 			// Finally convert these strings to bytes...
 			for (int i = 0; i < hexStrings.size(); i++) {
-				Inet6Util.convertToBytes((String) hexStrings.get(i),
+				Inet6Util.convertToBytes(hexStrings.get(i),
 						ipByteArray, i * 2);
 			}
 
 			// Now if there are any decimal values, we know where they go...
 			for (int i = 0; i < decStrings.size(); i++) {
 				ipByteArray[i + 12] = (byte) (Integer
-						.parseInt((String) decStrings.get(i)) & 255);
+						.parseInt(decStrings.get(i)) & 255);
 			}
 
 			// now check to see if this guy is actually and IPv4 address
@@ -1224,8 +1241,8 @@
 	}
 
 	static boolean preferIPv6Addresses() {
-		String result = (String) AccessController.doPrivileged(new PriviAction(
-				"java.net.preferIPv6Addresses"));
+		String result = AccessController.doPrivileged(
+                new PriviAction<String>("java.net.preferIPv6Addresses"));
 		return "true".equals(result);
 	}
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/MulticastSocket.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/MulticastSocket.java?rev=414997&r1=414996&r2=414997&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/MulticastSocket.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/MulticastSocket.java Fri Jun 16 21:26:56 2006
@@ -76,14 +76,13 @@
 				// level
 				NetworkInterface theInterface = getNetworkInterface();
 				if (theInterface != null) {
-					Enumeration addresses = theInterface.getInetAddresses();
+					Enumeration<InetAddress> addresses = theInterface.getInetAddresses();
 					if (addresses != null) {
 						while (addresses.hasMoreElements()) {
-							InetAddress nextAddress = (InetAddress) addresses
-									.nextElement();
-							if (nextAddress instanceof Inet6Address) {
-								return nextAddress;
-							}
+							InetAddress nextAddress = addresses.nextElement();
+                            if (nextAddress instanceof Inet6Address) {
+                                return nextAddress;
+                            }
 						}
 					}
 				}
@@ -116,13 +115,12 @@
 		}
 
 		if (theIndex.intValue() != 0) {
-			Enumeration theInterfaces = NetworkInterface.getNetworkInterfaces();
+			Enumeration<NetworkInterface> theInterfaces = NetworkInterface.getNetworkInterfaces();
 			while (theInterfaces.hasMoreElements()) {
-				NetworkInterface nextInterface = (NetworkInterface) theInterfaces
-						.nextElement();
-				if (nextInterface.getIndex() == theIndex.intValue()) {
-					return nextInterface;
-				}
+				NetworkInterface nextInterface = theInterfaces.nextElement();
+                if (nextInterface.getIndex() == theIndex.intValue()) {
+                    return nextInterface;
+                }
 			}
 		}
 
@@ -142,7 +140,7 @@
 					&& (InetAddress.preferIPv6Addresses() == true)) {
 				theAddresses[0] = Inet6Address.ANY;
 			} else {
-				theAddresses[0] = Inet4Address.ANY;
+				theAddresses[0] = InetAddress.ANY;
 			}
 			return new NetworkInterface(null, null, theAddresses,
 					NetworkInterface.UNSET_INTERFACE_INDEX);
@@ -156,7 +154,7 @@
 	 * Answer the time-to-live (TTL) for multicast packets sent on this socket.
 	 * 
 	 * @return java.net.InetAddress
-	 * @exception java.io.IOException
+	 * @exception IOException
 	 *                The exception description.
 	 */
 	public int getTimeToLive() throws IOException {
@@ -168,7 +166,7 @@
 	 * Answer the time-to-live (TTL) for multicast packets sent on this socket.
 	 * 
 	 * @return java.net.InetAddress
-	 * @exception java.io.IOException
+	 * @exception IOException
 	 *                The exception description.
 	 * @deprecated Replaced by getTimeToLive
 	 * @see #getTimeToLive()
@@ -189,16 +187,18 @@
 	 * 
 	 * @param groupAddr
 	 *            the multicast group to be joined
-	 * @exception java.io.IOException
+	 * @exception IOException
 	 *                may be thrown while joining a group
 	 */
 	public void joinGroup(InetAddress groupAddr) throws IOException {
 		checkClosedAndBind(false);
-		if (!groupAddr.isMulticastAddress())
-			throw new IOException(Msg.getString("K0039"));
+		if (!groupAddr.isMulticastAddress()) {
+            throw new IOException(Msg.getString("K0039"));
+        }
 		SecurityManager security = System.getSecurityManager();
-		if (security != null)
-			security.checkMulticast(groupAddr);
+		if (security != null) {
+            security.checkMulticast(groupAddr);
+        }
 		impl.join(groupAddr);
 	}
 
@@ -211,7 +211,7 @@
 	 *            the multicast group to be joined
 	 * @param netInterface
 	 *            the network interface on which the addresses should be dropped
-	 * @exception java.io.IOException
+	 * @exception IOException
 	 *                will be thrown if address is not a multicast address
 	 * @exception java.lang.SecurityException
 	 *                will be thrown if caller is not authorized to join group
@@ -221,7 +221,7 @@
 	 * @since 1.4
 	 */
 	public void joinGroup(SocketAddress groupAddress,
-			NetworkInterface netInterface) throws java.io.IOException {
+			NetworkInterface netInterface) throws IOException {
 		checkClosedAndBind(false);
 		if (null == groupAddress) {
 			throw new IllegalArgumentException(Msg.getString("K0331"));
@@ -261,7 +261,7 @@
 	 * 
 	 * @param groupAddr
 	 *            the multicast group to be left
-	 * @exception java.io.IOException
+	 * @exception IOException
 	 *                will be thrown if address is not a multicast address
 	 * @exception java.lang.SecurityException
 	 *                will be thrown if caller is not authorized to join group
@@ -270,11 +270,13 @@
 	 */
 	public void leaveGroup(InetAddress groupAddr) throws IOException {
 		checkClosedAndBind(false);
-		if (!groupAddr.isMulticastAddress())
-			throw new IOException(Msg.getString("K003a"));
+		if (!groupAddr.isMulticastAddress()) {
+            throw new IOException(Msg.getString("K003a"));
+        }
 		SecurityManager security = System.getSecurityManager();
-		if (security != null)
-			security.checkMulticast(groupAddr);
+		if (security != null) {
+            security.checkMulticast(groupAddr);
+        }
 		impl.leave(groupAddr);
 	}
 
@@ -285,7 +287,7 @@
 	 *            the multicast group to be left
 	 * @param netInterface
 	 *            the network interface on which the addresses should be dropped
-	 * @exception java.io.IOException
+	 * @exception IOException
 	 *                will be thrown if address is not a multicast address
 	 * @exception java.lang.SecurityException
 	 *                will be thrown if caller is not authorized to join group
@@ -295,7 +297,7 @@
 	 * @since 1.4
 	 */
 	public void leaveGroup(SocketAddress groupAddress,
-			NetworkInterface netInterface) throws java.io.IOException {
+			NetworkInterface netInterface) throws IOException {
 		checkClosedAndBind(false);
 		if (null == groupAddress) {
 			throw new IllegalArgumentException(Msg.getString("K0331"));
@@ -336,10 +338,10 @@
 	 * @param pack
 	 *            the DatagramPacket to send
 	 * @param ttl
-	 *            the ttl setting for this transmission, overriding the socket
+	 *            the TTL setting for this transmission, overriding the socket
 	 *            default
 	 * 
-	 * @exception java.io.IOException
+	 * @exception IOException
 	 *                If a send error occurs.
 	 * 
 	 * @deprecated use MulticastSocket#setTimeToLive
@@ -349,10 +351,11 @@
 		InetAddress packAddr = pack.getAddress();
 		SecurityManager security = System.getSecurityManager();
 		if (security != null) {
-			if (packAddr.isMulticastAddress())
-				security.checkMulticast(packAddr, ttl);
-			else
-				security.checkConnect(packAddr.getHostName(), pack.getPort());
+			if (packAddr.isMulticastAddress()) {
+                security.checkMulticast(packAddr, ttl);
+            } else {
+                security.checkConnect(packAddr.getHostName(), pack.getPort());
+            }
 		}
 		int currTTL = getTimeToLive();
 		if (packAddr.isMulticastAddress() && (byte) currTTL != ttl) {
@@ -378,10 +381,11 @@
 	 */
 	public void setInterface(InetAddress addr) throws SocketException {
 		checkClosedAndBind(false);
-		if (addr == null)
-			throw new NullPointerException();
+		if (addr == null) {
+            throw new NullPointerException();
+        }
 		if (addr.isAnyLocalAddress()) {
-			impl.setOption(SocketOptions.IP_MULTICAST_IF, Inet4Address.ANY);
+			impl.setOption(SocketOptions.IP_MULTICAST_IF, InetAddress.ANY);
 		} else if (addr instanceof Inet4Address) {
 			impl.setOption(SocketOptions.IP_MULTICAST_IF, addr);
 			// keep the address used to do the set as we must return the same
@@ -389,11 +393,12 @@
 			interfaceSet = addr;
 		}
 
-		// now we should also make sure this works for IPV6
-		// get the network interface for the addresss and set the interface
-		// using its index
-		// however if IPV6 is not enabled then we may get an exception.
-		// if IPV6 is not enabled
+		/*
+         * now we should also make sure this works for IPV6 get the network
+         * interface for the address and set the interface using its index
+         * however if IPV6 is not enabled then we may get an exception. if IPV6
+         * is not enabled
+         */
 		NetworkInterface theInterface = NetworkInterface.getByInetAddress(addr);
 		if ((theInterface != null) && (theInterface.getIndex() != 0)) {
 			try {
@@ -449,20 +454,21 @@
 					}
 				}
 
-				// now try to set using IPV4 way. Howerver, if interface passed
-				// in has no ip addresses associated with it then we cannot do it.
-				// first we have to make sure there is an IPV4 address that we
-				// can use to call set interface otherwise we will not set it
-				Enumeration theAddresses = netInterface.getInetAddresses();
+				/*
+                 * Now try to set using IPV4 way. However, if interface passed
+                 * in has no IP addresses associated with it then we cannot do
+                 * it. first we have to make sure there is an IPV4 address that
+                 * we can use to call set interface otherwise we will not set it
+                 */
+				Enumeration<InetAddress> theAddresses = netInterface.getInetAddresses();
 				boolean found = false;
 				firstAddress = null;
 				while ((theAddresses.hasMoreElements()) && (found != true)) {
-					InetAddress theAddress = (InetAddress) theAddresses
-							.nextElement();
-					if (theAddress instanceof Inet4Address) {
-						firstAddress = theAddress;
-						found = true;
-					}
+					InetAddress theAddress = theAddresses.nextElement();
+                    if (theAddress instanceof Inet4Address) {
+                        firstAddress = theAddress;
+                        found = true;
+                    }
 				}
 				if (netInterface.getIndex() == NetworkInterface.NO_INTERFACE_INDEX) {
 					// the system does not support IPV6 and does not provide
@@ -472,11 +478,12 @@
 						impl.setOption(SocketOptions.IP_MULTICAST_IF,
 								firstAddress);
 					} else {
-						// we should never get here as there should not be any
-						// network interfaces
-						// which have no IPV4 address and which doe not have the
-						// network interface
-						// index not set correctly
+						/*
+                         * we should never get here as there should not be any
+                         * network interfaces which have no IPV4 address and
+                         * which does not have the network interface index not
+                         * set correctly
+                         */
 						throw new SocketException(Msg.getString("K0335"));
 					}
 				} else {
@@ -514,15 +521,16 @@
 	 * 
 	 * @param ttl
 	 *            the time-to-live, 0<ttl<= 255
-	 * @exception java.io.IOException
+	 * @exception IOException
 	 *                The exception thrown while setting the TTL
 	 */
 	public void setTimeToLive(int ttl) throws IOException {
 		checkClosedAndBind(false);
-		if (0 <= ttl && ttl <= 255)
-			impl.setTimeToLive(ttl);
-		else
-			throw new IllegalArgumentException(Msg.getString("K003c"));
+		if (0 <= ttl && ttl <= 255) {
+            impl.setTimeToLive(ttl);
+        } else {
+            throw new IllegalArgumentException(Msg.getString("K003c"));
+        }
 	}
 
 	/**
@@ -530,7 +538,7 @@
 	 * 
 	 * @param ttl
 	 *            the time-to-live, 0<ttl<= 255
-	 * @exception java.io.IOException
+	 * @exception IOException
 	 *                The exception thrown while setting the TTL
 	 * @deprecated Replaced by setTimeToLive
 	 * @see #setTimeToLive(int)

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NegativeCache.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NegativeCache.java?rev=414997&r1=414996&r2=414997&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NegativeCache.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NegativeCache.java Fri Jun 16 21:26:56 2006
@@ -25,17 +25,17 @@
 /**
  * This class is used to manage the negative name lookup cache.
  */
-class NegativeCache extends LinkedHashMap {
+class NegativeCache<K, V> extends LinkedHashMap<K, V> {
 
     private static final long serialVersionUID = 1L;
 
-    static NegativeCache negCache = null;
+    static NegativeCache<String, NegCacheElement> negCache;
 
 	// maximum number of entries in the cache
 	static final int MAX_NEGATIVE_ENTRIES = 5;
 
 	// the loading for the cache
-	static final float LOADING = (float) 0.75;
+	static final float LOADING = 0.75F;
 
 	/**
 	 * Answers the hostname for the cache element
@@ -53,9 +53,9 @@
 	 * entry
 	 * 
 	 * @param eldest
-	 *            the map enty which will be deleted if we return true
+	 *            the map entry which will be deleted if we return true
 	 */
-	protected boolean removeEldestEntry(Map.Entry eldest) {
+	protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
 		return size() > MAX_NEGATIVE_ENTRIES;
 	}
 
@@ -74,7 +74,7 @@
 	}
 
 	/**
-	 * Answers the message that occured when we failed to lookup the host if
+	 * Answers the message that occurred when we failed to lookup the host if
 	 * such a failure is within the cache and the entry has not yet expired
 	 * 
 	 * @param hostName
@@ -84,16 +84,16 @@
 	 */
 	static String getFailedMessage(String hostName) {
 		checkCacheExists();
-		NegCacheElement element = (NegCacheElement) negCache.get(hostName);
+		NegCacheElement element = negCache.get(hostName);
 		if (element != null) {
 			// check if element is still valid
-			String ttlValue = (String) AccessController
-					.doPrivileged(new PriviAction(
-							"networkaddress.cache.negative.ttl"));
+			String ttlValue = AccessController.doPrivileged(
+                    new PriviAction<String>("networkaddress.cache.negative.ttl"));
 			int ttl = 10;
 			try {
-				if (ttlValue != null)
-					ttl = Integer.decode(ttlValue).intValue();
+				if (ttlValue != null) {
+                    ttl = Integer.decode(ttlValue).intValue();
+                }
 			} catch (NumberFormatException e) {
 			}
 			if (ttl == 0) {
@@ -119,12 +119,14 @@
 	 */
 	static void checkCacheExists() {
 		if (negCache == null) {
-			// Create with the access order set so ordering is based on when the
-			// entries were last accessed. We make the default cache size one
-			// greater than the maximum number of entries as we will grow to one
-			// larger and then delete the LRU entry
-			negCache = new NegativeCache(MAX_NEGATIVE_ENTRIES + 1, LOADING,
-					true);
-		}
+            /*
+             * Create with the access order set so ordering is based on when the
+             * entries were last accessed. We make the default cache size one
+             * greater than the maximum number of entries as we will grow to one
+             * larger and then delete the LRU entry
+             */
+            negCache = new NegativeCache<String, NegCacheElement>(
+                    MAX_NEGATIVE_ENTRIES + 1, LOADING, true);
+        }
 	}
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NetworkInterface.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NetworkInterface.java?rev=414997&r1=414996&r2=414997&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NetworkInterface.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NetworkInterface.java Fri Jun 16 21:26:56 2006
@@ -61,14 +61,14 @@
 
     /**
      * This constructor is used by the native method in order to construct the
-     * NetworkInterface objects in the array tht it returns
+     * NetworkInterface objects in the array that it returns
      * 
      * @param name
      *            internal name associated with the interface
      * @param displayName
      *            a user interpretable name for the interface
      * @param addresses
-     *            the Inet addresses associated with the interface
+     *            the Internet addresses associated with the interface
      * @param interfaceIndex
      *            an index for the interface. Only set for platforms that
      *            support IPV6
@@ -115,9 +115,9 @@
     }
 
     /**
-     * Answers the list of inet addresses bound to the interface
+     * Answers the list of internet addresses bound to the interface
      * 
-     * @return list of inet addresses bound to the interface
+     * @return list of internet addresses bound to the interface
      */
     public Enumeration<InetAddress> getInetAddresses() {
         /*
@@ -170,7 +170,7 @@
             }
         }
 
-        Enumeration theAccessibleElements = accessibleAddresses.elements();
+        Enumeration<InetAddress> theAccessibleElements = accessibleAddresses.elements();
         if (theAccessibleElements.hasMoreElements()) {
             return accessibleAddresses.elements();
         }
@@ -230,12 +230,12 @@
     }
 
     /**
-     * Answers the network interface which has the specified inet address bound
+     * Answers the network interface which has the specified internet address bound
      * to it, if one exists.
      * 
      * @param address
      *            address of interest
-     * @return network interface for inet address specified if it exists,
+     * @return network interface for internet address specified if it exists,
      *         otherwise null
      * 
      * @throws SocketException
@@ -252,7 +252,7 @@
 
         /*
          * get the list of interfaces, and then loop through the list. For each
-         * interface loop through the associated set of inet addresses and see
+         * interface loop through the associated set of internet addresses and see
          * if one matches. If so return that network interface
          */
         Enumeration<NetworkInterface> interfaces = getNetworkInterfaces();
@@ -265,7 +265,7 @@
                  */
                 // Enumeration netifAddresses = netif.getInetAddresses();
                 if ((netif.addresses != null) && (netif.addresses.length != 0)) {
-                    Enumeration netifAddresses = (new Vector<InetAddress>(
+                    Enumeration<InetAddress> netifAddresses = (new Vector<InetAddress>(
                             Arrays.asList(netif.addresses))).elements();
                     if (netifAddresses != null) {
                         while (netifAddresses.hasMoreElements()) {
@@ -354,7 +354,7 @@
                 return false;
             }
 
-            // now check that the inet addresses are the same
+            // now check that the internet addresses are the same
             Enumeration<InetAddress> netifAddresses = netif.getInetAddresses();
             Enumeration<InetAddress> localifAddresses = getInetAddresses();
             if ((netifAddresses == null) && (localifAddresses != null)) {
@@ -375,8 +375,8 @@
                     }
                 }
                 /*
-                 * now make sure that they had the same number of inet
-                 * addresses, if not they are not the same interfac
+                 * now make sure that they had the same number of internet
+                 * addresses, if not they are not the same interface
                  */
                 if (netifAddresses.hasMoreElements()
                         || localifAddresses.hasMoreElements()) {
@@ -409,8 +409,12 @@
      * @return a printable representation for the network interface
      */
     public String toString() {
-        StringBuffer stringRepresentation = new StringBuffer("[" + name + "]["
-                + displayName + "]");
+        StringBuilder string = new StringBuilder(25);
+        string.append("[");
+        string.append(name);
+        string.append("][");
+        string.append(displayName);
+        string.append("]");
 
         /*
          * get the addresses through this call to make sure we only reveal those
@@ -420,10 +424,12 @@
         if (theAddresses != null) {
             while (theAddresses.hasMoreElements()) {
                 InetAddress nextAddress = theAddresses.nextElement();
-                stringRepresentation.append("[" + nextAddress.toString() + "]");
+                string.append("[");
+                string.append(nextAddress.toString());
+                string.append("]");
             }
         }
-        return stringRepresentation.toString();
+        return string.toString();
     }
 
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ProxySelectorImpl.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ProxySelectorImpl.java?rev=414997&r1=414996&r2=414997&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ProxySelectorImpl.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ProxySelectorImpl.java Fri Jun 16 21:26:56 2006
@@ -60,7 +60,7 @@
 	 * 
 	 * @see java.net.ProxySelector#select(java.net.URI)
 	 */
-	public List select(URI uri) {
+	public List<Proxy> select(URI uri) {
 		// argument check
 		if (null == uri) {
             // "KA001=Argument must not be null"
@@ -96,7 +96,7 @@
 	/*
 	 * Gets proxy for http request. 1. gets from "http.proxyHost", then gets
 	 * port from "http.proxyPort", or from "proxyPort" if "http.proxyPort" is
-	 * unavailable. 2. gets from "proxyHost" if 1 is unavaible,then get port
+	 * unavailable. 2. gets from "proxyHost" if 1 is unavailable,then get port
 	 * from "proxyPort", or from "http.proxyPort" if "proxyPort" is unavailable.
 	 * 3. gets from "socksProxyHost" if 2 is unavailable.
 	 */
@@ -280,18 +280,18 @@
 	 */
 	private String getSystemProperty(final String property,
 			final String defaultVaule) {
-		String value = (String) AccessController.doPrivileged(new PriviAction(
-				property));
-		if (null == value || "".equals(value)) {
-			value = defaultVaule;
-		}
-		return value;
+		String value = AccessController.doPrivileged(
+                new PriviAction<String>(property));
+        if (null == value || "".equals(value)) {
+            value = defaultVaule;
+        }
+        return value;
 	}
 
 	/*
 	 * gets system property, privileged operation. If the value of "key"
 	 * property is null, then retrieve value from "alternative" property.
-	 * Finllay, if the value is null or empty String, it returns defaultValue.
+	 * Finally, if the value is null or empty String, it returns defaultValue.
 	 */
 	private String getSystemPropertyOrAlternative(final String key,
 			final String alternativeKey, final String defaultValue) {