harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r414992 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java: io/ lang/
Date Sat, 17 Jun 2006 03:33:52 GMT
Author: ndbeyer
Date: Fri Jun 16 20:33:51 2006
New Revision: 414992

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

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermissionCollection.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamClass.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamField.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStreamWriter.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintStream.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintWriter.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SequenceInputStream.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SerializablePermission.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ClassCastException.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermissionCollection.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermissionCollection.java?rev=414992&r1=414991&r2=414992&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermissionCollection.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermissionCollection.java Fri Jun 16 20:33:51 2006
@@ -17,6 +17,8 @@
 
 
 import java.security.Permission;
+import java.security.PermissionCollection;
+import java.util.Enumeration;
 import java.util.Vector;
 
 /**
@@ -25,11 +27,11 @@
  * specific permissions is implied by a FilePermissionCollection.
  * 
  */
-final class FilePermissionCollection extends java.security.PermissionCollection
+final class FilePermissionCollection extends PermissionCollection
 		implements Serializable {
 	private static final long serialVersionUID = 2202956749081564585L;
 
-	Vector permissions = new Vector();
+	Vector<Permission> permissions = new Vector<Permission>();
 
 	/**
 	 * Construct a new FilePermissionCollection.
@@ -44,22 +46,22 @@
 	 * @see java.security.PermissionCollection#add(java.security.Permission)
 	 */
 	public void add(Permission permission) {
-		if (!isReadOnly()) {
-			if (permission instanceof FilePermission)
-				permissions.addElement(permission);
-			else
-				throw new java.lang.IllegalArgumentException(permission
-						.toString());
-		} else
-			throw new IllegalStateException();
-	}
+        if (!isReadOnly()) {
+            if (permission instanceof FilePermission) {
+                permissions.addElement(permission);
+            } else {
+                throw new IllegalArgumentException(permission.toString());
+            }
+        } else
+            throw new IllegalStateException();
+    }
 
 	/**
-	 * Answers an enumeration for the collection of permissions.
-	 * 
-	 * @see java.security.PermissionCollection#elements()
-	 */
-	public java.util.Enumeration elements() {
+     * Answers an enumeration for the collection of permissions.
+     * 
+     * @see java.security.PermissionCollection#elements()
+     */
+	public Enumeration<Permission> elements() {
 		return permissions.elements();
 	}
 
@@ -70,19 +72,19 @@
 	 * @see java.security.PermissionCollection#implies(java.security.Permission)
 	 */
 	public boolean implies(Permission permission) {
-		if (permission instanceof FilePermission) {
-			FilePermission fp = (FilePermission) permission;
-			int matchedMask = 0;
-			int i = 0;
-			while (i < permissions.size()
-					&& ((matchedMask & fp.mask) != fp.mask)) {
-				// Cast will not fail since we added it
-				matchedMask |= ((FilePermission) permissions.elementAt(i))
-						.impliesMask(permission);
-				i++;
-			}
-			return ((matchedMask & fp.mask) == fp.mask);
-		}
-		return false;
-	}
+        if (permission instanceof FilePermission) {
+            FilePermission fp = (FilePermission) permission;
+            int matchedMask = 0;
+            int i = 0;
+            while (i < permissions.size()
+                    && ((matchedMask & fp.mask) != fp.mask)) {
+                // Cast will not fail since we added it
+                matchedMask |= ((FilePermission) permissions.elementAt(i))
+                        .impliesMask(permission);
+                i++;
+            }
+            return ((matchedMask & fp.mask) == fp.mask);
+        }
+        return false;
+    }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamClass.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamClass.java?rev=414992&r1=414991&r2=414992&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamClass.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamClass.java Fri Jun 16 20:33:51 2006
@@ -22,10 +22,15 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.security.AccessController;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
 import java.util.WeakHashMap;
 
-import org.apache.harmony.luni.util.Sorter;
-
+import org.apache.harmony.luni.util.Msg;
 import org.apache.harmony.luni.util.PriviAction;
 
 /**
@@ -58,7 +63,7 @@
 
 	static final Class[] EMPTY_CONSTRUCTOR_PARAM_TYPES;
 
-	private static final Class VOID_CLASS;
+	private static final Class<Void> VOID_CLASS;
 
 	static final Class[] UNSHARED_PARAM_TYPES;
 
@@ -71,8 +76,8 @@
 				| Modifier.INTERFACE | Modifier.ABSTRACT;
 		READ_PARAM_TYPES = new Class[1];
 		WRITE_PARAM_TYPES = new Class[1];
-		READ_PARAM_TYPES[0] = java.io.ObjectInputStream.class;
-		WRITE_PARAM_TYPES[0] = java.io.ObjectOutputStream.class;
+		READ_PARAM_TYPES[0] = ObjectInputStream.class;
+		WRITE_PARAM_TYPES[0] = ObjectOutputStream.class;
 		EMPTY_CONSTRUCTOR_PARAM_TYPES = new Class[0];
 		VOID_CLASS = Void.TYPE;
 		UNSHARED_PARAM_TYPES = new Class[1];
@@ -84,15 +89,17 @@
 	 */
 	public static final ObjectStreamField[] NO_FIELDS = new ObjectStreamField[0];
 
-	static final Class ARRAY_OF_FIELDS; // used to fetch field
-										// serialPersistentFields and checking
-										// its type
+	/*
+     * used to fetch field serialPersistentFields and checking its type
+     */
+    static final Class<?> ARRAY_OF_FIELDS;
+    
 	static {
 		try {
 			ARRAY_OF_FIELDS = Class.forName("[Ljava.io.ObjectStreamField;"); //$NON-NLS-1$
 		} catch (ClassNotFoundException e) {
 			// This should not happen
-			throw new RuntimeException();
+			throw new AssertionError(e);
 		}
 	}
 
@@ -103,25 +110,25 @@
 	private static final String CLINIT_SIGNATURE = "()V"; //$NON-NLS-1$
 
 	// Used to determine if an object is Serializable or Externalizable
-	private static final Class SERIALIZABLE = java.io.Serializable.class;
+	private static final Class<Serializable> SERIALIZABLE = Serializable.class;
 
-	private static final Class EXTERNALIZABLE = java.io.Externalizable.class;
+	private static final Class<Externalizable> EXTERNALIZABLE = Externalizable.class;
 
 	// Used to test if the object is a String or a class.
-	static final Class STRINGCLASS = java.lang.String.class;
+	static final Class<String> STRINGCLASS = String.class;
 
-	static final Class CLASSCLASS = java.lang.Class.class;
+	static final Class<?> CLASSCLASS = Class.class;
 
-	static final Class OBJECTSTREAMCLASSCLASS = java.io.ObjectStreamClass.class;
+	static final Class<ObjectStreamClass> OBJECTSTREAMCLASSCLASS = ObjectStreamClass.class;
 
 	// Table mapping instances of java.lang.Class to to corresponding instances
 	// of ObjectStreamClass
-	private static final WeakHashMap classesAndDescriptors = new WeakHashMap();
+	private static final WeakHashMap<Class<?>, ObjectStreamClass> classesAndDescriptors = new WeakHashMap<Class<?>, ObjectStreamClass>();
 
 	// ClassDesc
 	private String className; // Name of the class this descriptor represents
 
-	private WeakReference resolvedClass; // Corresponding loaded class with
+	private WeakReference<Class<?>> resolvedClass; // Corresponding loaded class with
 											// the name above
 
 	private long svUID; // Serial version UID of the class the descriptor
@@ -143,14 +150,14 @@
 											// describing the serialized fields
 											// of this class
 
-	// If an ObjectStreamClass describes an Externalizable class, it (the
-	// descriptor) should not have
-	// field descriptors (ObjectStreamField) at all. The ObjectStreamClass that
-	// gets saved should simply
-	// have no field info. This is a footnote in page 1511 (class Serializable)
-	// of
-	// "The Java Class Libraries, Second Edition, Vol I".
-
+	/*
+     * If an ObjectStreamClass describes an Externalizable class, it (the
+     * descriptor) should not have field descriptors (ObjectStreamField) at all.
+     * The ObjectStreamClass that gets saved should simply have no field info.
+     * This is a footnote in page 1511 (class Serializable) of "The Java Class
+     * Libraries, Second Edition, Vol. I".
+     */
+    
 	/**
 	 * Constructs a new instance of this class.
 	 */
@@ -171,7 +178,7 @@
 	 *            a boolean indicating if SUID should be computed or not.
 	 * @return the computer class descriptor
 	 */
-	private static ObjectStreamClass addToCache(Class cl, boolean computeSUID) {
+	private static ObjectStreamClass addToCache(Class<?> cl, boolean computeSUID) {
 
 		ObjectStreamClass result = new ObjectStreamClass();
 		classesAndDescriptors.put(cl, result);
@@ -179,39 +186,42 @@
 		// Now we fill in the values
 		result.setName(cl.getName());
 		result.setClass(cl);
-		Class superclass = cl.getSuperclass();
-		if (superclass != null)
+		Class<?> superclass = cl.getSuperclass();
+		if (superclass != null) {
 			result.setSuperclass(lookup(superclass));
+        }
 
 		Field[] declaredFields = null;
-		if (computeSUID) {
-			declaredFields = cl.getDeclaredFields(); // Lazy computation, to
-														// save speed&space
-			result.setSerialVersionUID(computeSerialVersionUID(cl,
-					declaredFields));
-		}
-
-		boolean serializable = isSerializable(cl);
-		// Serializables need field descriptors
-		if (serializable && !cl.isArray()) {
-			if (declaredFields == null)
-				declaredFields = cl.getDeclaredFields(); // Lazy computation,
-															// to save
-															// speed&space
-			result.buildFieldDescriptors(declaredFields);
-		} else {
-			// Externalizables or arrays do not need FieldDesc info
-			result.setFields(new ObjectStreamField[0]);
-		}
+        if (computeSUID) {
+            // Lazy computation, to save speed & space
+            declaredFields = cl.getDeclaredFields();
+            result.setSerialVersionUID(computeSerialVersionUID(cl,
+                    declaredFields));
+        }
+
+        boolean serializable = isSerializable(cl);
+        // Serializables need field descriptors
+        if (serializable && !cl.isArray()) {
+            if (declaredFields == null) {
+
+                declaredFields = cl.getDeclaredFields();
+            }
+            result.buildFieldDescriptors(declaredFields);
+        } else {
+            // Externalizables or arrays do not need FieldDesc info
+            result.setFields(new ObjectStreamField[0]);
+        }
 
 		byte flags = 0;
 		boolean externalizable = isExternalizable(cl);
-		if (externalizable)
-			flags |= ObjectStreamConstants.SC_EXTERNALIZABLE;
-		else if (serializable)
-			flags |= ObjectStreamConstants.SC_SERIALIZABLE;
-		if (getPrivateWriteObjectMethod(cl) != null)
-			flags |= ObjectStreamConstants.SC_WRITE_METHOD;
+		if (externalizable) {
+            flags |= ObjectStreamConstants.SC_EXTERNALIZABLE;
+        } else if (serializable) {
+            flags |= ObjectStreamConstants.SC_SERIALIZABLE;
+        }
+		if (getPrivateWriteObjectMethod(cl) != null) {
+            flags |= ObjectStreamConstants.SC_WRITE_METHOD;
+        }
 		result.setFlags(flags);
 
 		return result;
@@ -237,23 +247,19 @@
 
 		if (!useReflectFields) {
 			// The user declared a collection of emulated fields. Use them.
-			AccessController.doPrivileged(new PriviAction(f)); // We have to be
-																// able to fetch
-																// its value,
-																// even if it is
-																// private
+		    // We have to be able to fetch its value, even if it is private
+			AccessController.doPrivileged(new PriviAction<Object>(f)); 
 			try {
-				fields = (ObjectStreamField[]) f.get(null); // static field,
-															// pass null
+			    //static field, pass null
+				fields = (ObjectStreamField[]) f.get(null); 
 			} catch (IllegalAccessException ex) {
 				// WARNING - what should we do if we have no access ? This
 				// should not happen.
-				throw new RuntimeException();
+				throw new RuntimeException(ex);
 			}
 		} else {
 			// Compute collection of dumpable fields based on reflect fields
-			java.util.Vector serializableFields = new java.util.Vector(
-					declaredFields.length);
+			List<ObjectStreamField> serializableFields = new ArrayList<ObjectStreamField>(declaredFields.length);
 			// Filter, we are only interested in fields that are serializable
 			for (int i = 0; i < declaredFields.length; i++) {
 				Field declaredField = declaredFields[i];
@@ -263,7 +269,7 @@
 				if (shouldBeSerialized) {
 					ObjectStreamField field = new ObjectStreamField(
 							declaredField.getName(), declaredField.getType());
-					serializableFields.addElement(field);
+					serializableFields.add(field);
 				}
 			}
 
@@ -273,14 +279,14 @@
 			} else {
 				// Now convert from Vector to array
 				fields = new ObjectStreamField[serializableFields.size()];
-				serializableFields.copyInto(fields);
+				fields = serializableFields.toArray(fields);
 			}
 		}
 		ObjectStreamField.sortFields(fields);
 		// assign offsets
 		int primOffset = 0, objectOffset = 0;
 		for (int i = 0; i < fields.length; i++) {
-			Class type = fields[i].getType();
+			Class<?> type = fields[i].getType();
 			if (type.isPrimitive()) {
 				fields[i].offset = primOffset;
 				primOffset += primitiveSize(type);
@@ -302,97 +308,101 @@
 	 * @return the value of SUID of this class
 	 * 
 	 */
-	private static long computeSerialVersionUID(Class cl, Field[] fields) {
-		// First we should try to fetch the static slot
-		// 'static final long serialVersionUID'. If it is defined,
-		// return it. If not defined, we really need to compute SUID
-		// using SHAOutputStream
-
+	private static long computeSerialVersionUID(Class<?> cl, Field[] fields) {
+		/*
+         * First we should try to fetch the static slot 'static final long
+         * serialVersionUID'. If it is defined, return it. If not defined, we
+         * really need to compute SUID using SHAOutputStream
+         */
 		for (int i = 0; i < fields.length; i++) {
 			final Field field = fields[i];
 			if (Long.TYPE == field.getType()) {
 				int modifiers = field.getModifiers();
 				if (Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers)) {
 					if (UID_FIELD_NAME.equals(field.getName())) {
-						// We need to be able to see it even if we have no
-						// visibility.
-						// That is why we set accessible first (new API in
-						// reflect 1.2)
-						AccessController.doPrivileged(new PriviAction(field));
+						/*
+                         * We need to be able to see it even if we have no
+                         * visibility. That is why we set accessible first (new
+                         * API in reflect 1.2)
+                         */
+                        AccessController.doPrivileged(new PriviAction<Object>(
+                                field));
 						try {
-							return field.getLong(null); // Static field,
-														// parameter is ignored
+                            // Static field, parameter is ignored
+							return field.getLong(null);
 						} catch (IllegalAccessException iae) {
-							throw new RuntimeException(org.apache.harmony.luni.util.Msg
-									.getString("K0071", iae.toString())); //$NON-NLS-1$
+							throw new RuntimeException(Msg.getString("K0071", iae)); //$NON-NLS-1$
 						}
 					}
 				}
 			}
 		}
 
-		java.security.MessageDigest digest;
+		MessageDigest digest;
 		try {
-			digest = java.security.MessageDigest.getInstance("SHA"); //$NON-NLS-1$
-		} catch (java.security.NoSuchAlgorithmException e) {
-			throw new Error(e.toString());
+			digest = MessageDigest.getInstance("SHA"); //$NON-NLS-1$
+		} catch (NoSuchAlgorithmException e) {
+			throw new Error(e);
 		}
 		ByteArrayOutputStream sha = new ByteArrayOutputStream();
 		try {
 			DataOutputStream output = new DataOutputStream(sha);
 			output.writeUTF(cl.getName());
 			int classModifiers = CLASS_MODIFIERS_MASK & cl.getModifiers();
-			// Workaround for 1F9LOQO. Arrays are ABSTRACT in JDK, but that is
-			// not in the spec.
-			// Since we want to be compatible for X-loading, we have to pretend
-			// we have the same shape
-			boolean isArray = cl.isArray();
+            /*
+             * Workaround for 1F9LOQO. Arrays are ABSTRACT in JDK, but that is
+             * not in the specification. Since we want to be compatible for
+             * X-loading, we have to pretend we have the same shape
+             */
+            boolean isArray = cl.isArray();
 			if (isArray) {
 				classModifiers |= Modifier.ABSTRACT;
 			}
 			// Required for JDK UID compatibility
-			if (cl.isInterface() && !Modifier.isPublic(classModifiers))
+			if (cl.isInterface() && !Modifier.isPublic(classModifiers)) {
 				classModifiers &= ~Modifier.ABSTRACT;
+            }
 			output.writeInt(classModifiers);
 
-			// Workaround for 1F9LOQO. In JDK1.2 arrays implement Cloneable and
-			// Serializable
-			// but not in JDK 1.1.7. So, JDK 1.2 "pretends" arrays have no
-			// interfaces when
-			// computing SHA-1 to be compatible.
+            /*
+             * Workaround for 1F9LOQO. In JDK1.2 arrays implement Cloneable and
+             * Serializable but not in JDK 1.1.7. So, JDK 1.2 "pretends" arrays
+             * have no interfaces when computing SHA-1 to be compatible.
+             * 
+             */
 			if (!isArray) {
 				// ------------------ Interface information
-				Class[] interfaces = cl.getInterfaces();
-				if (interfaces.length > 1) { // Only attempt to sort if
-												// really needed (saves object
-												// creation, etc)
-					// Sort them
-					Sorter.Comparator interfaceComparator = new Sorter.Comparator() {
-						public int compare(Object interface1, Object interface2) {
-							return ((Class) interface1).getName().compareTo(
-									((Class) interface2).getName());
-						}
-					};
-					Sorter.sort(interfaces, interfaceComparator);
+				Class<?>[] interfaces = cl.getInterfaces();
+				if (interfaces.length > 1) { 
+                    /*
+                     * Only attempt to sort if really needed (saves object
+                     * creation, etc)
+                     */
+					Comparator<Class<?>> interfaceComparator = new Comparator<Class<?>>() {
+                        public int compare(Class<?> itf1, Class<?> itf2) {
+                            return itf1.getName().compareTo(itf2.getName());
+                        }
+                    };
+                    Arrays.sort(interfaces, interfaceComparator);
 				}
 
 				// Dump them
-				for (int i = 0; i < interfaces.length; i++)
+				for (int i = 0; i < interfaces.length; i++) {
 					output.writeUTF(interfaces[i].getName());
+                }
 			}
 
 			// ------------------ Field information
 
-			if (fields.length > 1) {// Only attempt to sort if really needed
-									// (saves object creation, etc)
+			if (fields.length > 1) {
+                // Only attempt to sort if really needed (saves object creation, etc)
 				// Sort them
-				Sorter.Comparator fieldComparator = new Sorter.Comparator() {
-					public int compare(Object field1, Object field2) {
-						return ((Field) field1).getName().compareTo(
-								((Field) field2).getName());
-					}
-				};
-				Sorter.sort(fields, fieldComparator);
+				Comparator<Field> fieldComparator = new Comparator<Field>() {
+                    public int compare(Field field1, Field field2) {
+                        return field1.getName().compareTo(field2.getName());
+                    }
+                };
+                Arrays.sort(fields, fieldComparator);
 			}
 
 			// Dump them
@@ -412,10 +422,12 @@
 				}
 			}
 
-			// Normally constructors come before methods (because <init> <
-			// anyMethodName).
-			// However, <clinit> is an exception. Besides, reflect will not let
-			// us get to it.
+			/*
+             * Normally constructors come before methods (because <init> <
+             * anyMethodName). However, <clinit> is an exception. Besides,
+             * reflect will not let us get to it.
+             * 
+             */
 			if (hasClinit(cl)) {
 				// write name, modifier & "descriptor"
 				output.writeUTF(CLINIT_NAME);
@@ -424,58 +436,59 @@
 			}
 
 			// ------------------ Constructor information
-			Constructor[] constructors = cl.getDeclaredConstructors();
-			if (constructors.length > 1) {// Only attempt to sort if really
-											// needed (saves object creation,
-											// etc)
-				// Sort them
-				Sorter.Comparator constructorComparator = new Sorter.Comparator() {
-					public int compare(Object constructor1, Object constructor2) {
+			Constructor<?>[] constructors = cl.getDeclaredConstructors();
+			if (constructors.length > 1) {
+                /*
+                 * Only attempt to sort if really needed (saves object
+                 * creation, etc)
+                 */
+				Comparator<Constructor<?>> constructorComparator = new Comparator<Constructor<?>>() {
+					public int compare(Constructor<?> ctr1, Constructor<?> ctr2) {
 						// All constructors have same name, so we sort based on
 						// signature
-						return (getConstructorSignature((Constructor) constructor1)
-								.compareTo(getConstructorSignature((Constructor) constructor2)));
+						return (getConstructorSignature(ctr1)
+                                .compareTo(getConstructorSignature(ctr2)));
 					}
 				};
-				Sorter.sort(constructors, constructorComparator);
+				Arrays.sort(constructors, constructorComparator);
 			}
 
 			// Dump them
 			for (int i = 0; i < constructors.length; i++) {
-				Constructor constructor = constructors[i];
+				Constructor<?> constructor = constructors[i];
 				int modifiers = constructor.getModifiers();
 				boolean isPrivate = Modifier.isPrivate(modifiers);
 				if (!isPrivate) {
-					// write name, modifier & "descriptor" of all but private
-					// ones
-					output.writeUTF("<init>"); // constructor.getName() returns //$NON-NLS-1$
-												// the constructor name as
-												// typed, not the VM name
-					output.writeInt(modifiers);
-					output
-							.writeUTF(descriptorForSignature(getConstructorSignature(constructor)));
-				}
+                    /*
+                     * write name, modifier & "descriptor" of all but private
+                     * ones
+                     * 
+                     * constructor.getName() returns the constructor name as
+                     * typed, not the VM name
+                     */
+                    output.writeUTF("<init>"); //$NON-NLS-1$
+                    output.writeInt(modifiers);
+                    output.writeUTF(descriptorForSignature(
+                            getConstructorSignature(constructor)));
+                }
 			}
 
 			// ------------------ Method information
 			Method[] methods = cl.getDeclaredMethods();
-			if (methods.length > 1) {// Only attempt to sort if really needed
-										// (saves object creation, etc)
-				// Sort them
-				Sorter.Comparator methodComparator = new Sorter.Comparator() {
-					public int compare(Object method1, Object method2) {
-						int result = ((Method) method1).getName().compareTo(
-								((Method) method2).getName());
-						if (result == 0) {
-							// same name, signature will tell which one comes
-							// first
-							return (getMethodSignature((Method) method1)
-									.compareTo(getMethodSignature((Method) method2)));
-						}
-						return result;
-					}
-				};
-				Sorter.sort(methods, methodComparator);
+			if (methods.length > 1) {
+				Comparator<Method> methodComparator = new Comparator<Method>() {
+                    public int compare(Method m1, Method m2) {
+                        int result = m1.getName().compareTo(m2.getName());
+                        if (result == 0) {
+                            // same name, signature will tell which one comes
+                            // first
+                            return getMethodSignature(m1)
+                                    .compareTo(getMethodSignature(m2));
+                        }
+                        return result;
+                    }
+                };
+				Arrays.sort(methods, methodComparator);
 			}
 
 			// Dump them
@@ -488,13 +501,12 @@
 					// ones
 					output.writeUTF(method.getName());
 					output.writeInt(modifiers);
-					output
-							.writeUTF(descriptorForSignature(getMethodSignature(method)));
+					output.writeUTF(descriptorForSignature(
+                            getMethodSignature(method)));
 				}
 			}
 		} catch (IOException e) {
-			throw new RuntimeException(org.apache.harmony.luni.util.Msg.getString("K0072", //$NON-NLS-1$
-					e.toString()));
+			throw new RuntimeException(Msg.getString("K0072", e));//$NON-NLS-1$
 		}
 
 		// now compute the UID based on the SHA
@@ -539,14 +551,16 @@
 	 *         serialPersistentFields <code>null</code> if the class does not
 	 *         have serialPersistentFields
 	 */
-	static Field fieldSerialPersistentFields(Class cl) {
+	static Field fieldSerialPersistentFields(Class<?> cl) {
 		try {
 			Field f = cl.getDeclaredField("serialPersistentFields"); //$NON-NLS-1$
 			int modifiers = f.getModifiers();
 			if (Modifier.isStatic(modifiers) && Modifier.isPrivate(modifiers)
-					&& Modifier.isFinal(modifiers))
-				if (f.getType() == ARRAY_OF_FIELDS)
-					return f;
+					&& Modifier.isFinal(modifiers)) {
+                if (f.getType() == ARRAY_OF_FIELDS) {
+                    return f;
+                }
+            }
 		} catch (NoSuchFieldException nsm) {
 		}
 		return null;
@@ -561,7 +575,7 @@
 	 */
 	public Class<?> forClass() {
 		if (resolvedClass != null) {
-			return (Class) resolvedClass.get();
+			return resolvedClass.get();
 		}
 		return null;
 	}
@@ -576,7 +590,7 @@
 	 * @return the constructor's signature
 	 * 
 	 */
-	static native String getConstructorSignature(Constructor c);
+	static native String getConstructorSignature(Constructor<?> c);
 
 	/**
 	 * Answers a given field by name.
@@ -590,8 +604,9 @@
 		ObjectStreamField[] allFields = fields();
 		for (int i = 0; i < allFields.length; i++) {
 			ObjectStreamField f = allFields[i];
-			if (f.getName().equals(name))
-				return f;
+			if (f.getName().equals(name)) {
+                return f;
+            }
 		}
 		return null;
 	}
@@ -606,12 +621,13 @@
 
 	ObjectStreamField[] fields() {
 		if (fields == null) {
-			Class forCl = forClass();
-			if (forCl != null && isSerializable(forCl) && !forCl.isArray())
+			Class<?> forCl = forClass();
+			if (forCl != null && isSerializable(forCl) && !forCl.isArray()) {
 				buildFieldDescriptors(forCl.getDeclaredFields());
-			else
+            } else {
 				// Externalizables or arrays do not need FieldDesc info
 				setFields(new ObjectStreamField[0]);
+            }
 		}
 		return fields;
 	}
@@ -625,7 +641,7 @@
 	 */
 
 	public ObjectStreamField[] getFields() {
-		return (ObjectStreamField[]) fields().clone();
+		return fields().clone();
 	}
 
 	/**
@@ -715,7 +731,7 @@
 	 * @return <code>true</code> if the class has <clinit> <code>false</code>
 	 *         if the class does not have <clinit>
 	 */
-	private static native boolean hasClinit(Class cl);
+	private static native boolean hasClinit(Class<?> cl);
 
 	/**
 	 * Return true if the given class <code>cl</code> implements private
@@ -726,10 +742,9 @@
 	 * @return <code>true</code> if the class implements readObject
 	 *         <code>false</code> if the class does not implement readObject
 	 */
-	static Method getPrivateReadObjectMethod(Class cl) {
+	static Method getPrivateReadObjectMethod(Class<?> cl) {
 		try {
-			Method method = cl
-					.getDeclaredMethod("readObject", READ_PARAM_TYPES); //$NON-NLS-1$
+			Method method = cl.getDeclaredMethod("readObject", READ_PARAM_TYPES); //$NON-NLS-1$
 			if (Modifier.isPrivate(method.getModifiers())
 					&& method.getReturnType() == VOID_CLASS) {
 				return method;
@@ -748,7 +763,7 @@
 	 * @return <code>true</code> if the class implements readObject
 	 *         <code>false</code> if the class does not implement readObject
 	 */
-	static Method getPrivateReadObjectNoDataMethod(Class cl) {
+	static Method getPrivateReadObjectNoDataMethod(Class<?> cl) {
 		try {
 			Method method = cl.getDeclaredMethod("readObjectNoData", //$NON-NLS-1$
 					EMPTY_CONSTRUCTOR_PARAM_TYPES);
@@ -770,7 +785,7 @@
 	 * @return <code>true</code> if the class implements writeObject
 	 *         <code>false</code> if the class does not implement writeObject
 	 */
-	static Method getPrivateWriteObjectMethod(Class cl) {
+	static Method getPrivateWriteObjectMethod(Class<?> cl) {
 		try {
 			Method method = cl.getDeclaredMethod("writeObject", //$NON-NLS-1$
 					WRITE_PARAM_TYPES);
@@ -795,23 +810,23 @@
 	 * 
 	 * @see Object#hashCode
 	 */
-	static boolean isExternalizable(Class cl) {
+	static boolean isExternalizable(Class<?> cl) {
 		return EXTERNALIZABLE.isAssignableFrom(cl);
 	}
 
 	/**
-	 * Return true if the typecode
-	 * <code>typecode<code> describes a primitive type
-	 *
-	 * @param		typecode	a char describing the typecode
-	 * @return		<code>true</code> if the typecode represents a primitive type
-	 *				<code>false</code> if the typecode represents an Object type (including arrays)
-	 *
-	 * @see			Object#hashCode
-	 */
-	static boolean isPrimitiveType(char typecode) {
-		return !(typecode == '[' || typecode == 'L');
-	}
+     * Return true if the type code
+     * <code>typecode<code> describes a primitive type
+     *
+     * @param typecode a char describing the typecode
+     * @return <code>true</code> if the typecode represents a primitive type 
+     * <code>false</code> if the typecode represents an Object type (including arrays)
+     *
+     * @see	Object#hashCode
+     */
+    static boolean isPrimitiveType(char typecode) {
+        return !(typecode == '[' || typecode == 'L');
+    }
 
 	/**
 	 * Return true if instances of class <code>cl</code> are Serializable,
@@ -825,7 +840,7 @@
 	 * 
 	 * @see Object#hashCode
 	 */
-	static boolean isSerializable(Class cl) {
+	static boolean isSerializable(Class<?> cl) {
 		return SERIALIZABLE.isAssignableFrom(cl);
 	}
 
@@ -840,8 +855,9 @@
 	 */
 	private static long littleEndianLongAt(byte[] buffer, int position) {
 		long result = 0;
-		for (int i = position + 7; i >= position; i--)
-			result = (result << 8) + (buffer[i] & 0xff);
+		for (int i = position + 7; i >= position; i--) {
+            result = (result << 8) + (buffer[i] & 0xff);
+        }
 		return result;
 	}
 
@@ -863,8 +879,9 @@
 		boolean externalizable = isExternalizable(cl);
 
 		// Has to be either Serializable or Externalizable
-		if (!serializable && !externalizable)
-			return null;
+		if (!serializable && !externalizable) {
+            return null;
+        }
 
 		return lookupStreamClass(cl, true);
 	}
@@ -879,7 +896,7 @@
 	 *            descriptor
 	 * @return the corresponding descriptor
 	 */
-	static ObjectStreamClass lookupStreamClass(Class cl) {
+	static ObjectStreamClass lookupStreamClass(Class<?> cl) {
 		return lookupStreamClass(cl, isSerializable(cl) || isExternalizable(cl));
 	}
 
@@ -895,13 +912,14 @@
 	 *            a boolean indicating if SUID should be computed or not.
 	 * @return the corresponding descriptor
 	 */
-	private static synchronized ObjectStreamClass lookupStreamClass(Class cl,
+	private static synchronized ObjectStreamClass lookupStreamClass(Class<?> cl,
 			boolean computeSUID) {
 		// Synchronized because of the lookup table 'classesAndDescriptors'
-		ObjectStreamClass cachedValue = (ObjectStreamClass) classesAndDescriptors
+		ObjectStreamClass cachedValue = classesAndDescriptors
 				.get(cl);
-		if (cachedValue != null)
-			return cachedValue;
+		if (cachedValue != null) {
+            return cachedValue;
+        }
 		return addToCache(cl, computeSUID);
 	}
 
@@ -915,14 +933,15 @@
 	 *         readResolve <code>null</code> if the class does not implement
 	 *         readResolve
 	 */
-	static Method methodReadResolve(Class cl) {
-		Class search = cl;
+	static Method methodReadResolve(Class<?> cl) {
+        Class<?> search = cl;
 		while (search != null) {
 			try {
 				Method method = search.getDeclaredMethod("readResolve", (Class[])null); //$NON-NLS-1$
 				if (search == cl
-						|| (method.getModifiers() & Modifier.PRIVATE) == 0)
-					return method;
+						|| (method.getModifiers() & Modifier.PRIVATE) == 0) {
+                    return method;
+                }
 				return null;
 			} catch (NoSuchMethodException nsm) {
 			}
@@ -941,14 +960,15 @@
 	 *         writeReplace <code>null</code> if the class does not implement
 	 *         writeReplace
 	 */
-	static Method methodWriteReplace(Class cl) {
-		Class search = cl;
+	static Method methodWriteReplace(Class<?> cl) {
+        Class<?> search = cl;
 		while (search != null) {
 			try {
 				Method method = search.getDeclaredMethod("writeReplace", (Class[])null); //$NON-NLS-1$
 				if (search == cl
-						|| (method.getModifiers() & Modifier.PRIVATE) == 0)
-					return method;
+						|| (method.getModifiers() & Modifier.PRIVATE) == 0) {
+                    return method;
+                }
 				return null;
 			} catch (NoSuchMethodException nsm) {
 			}
@@ -963,8 +983,8 @@
 	 * @param c
 	 *            aClass, the new class that the receiver describes
 	 */
-	void setClass(Class c) {
-		resolvedClass = new WeakReference(c);
+	void setClass(Class<?> c) {
+		resolvedClass = new WeakReference<Class<?>>(c);
 	}
 
 	/**
@@ -1038,15 +1058,19 @@
 		superclass = c;
 	}
 
-	private int primitiveSize(Class type) {
-		if (type == Byte.TYPE || type == Boolean.TYPE)
-			return 1;
-		if (type == Short.TYPE || type == Character.TYPE)
-			return 2;
-		if (type == Integer.TYPE || type == Float.TYPE)
-			return 4;
-		if (type == Long.TYPE || type == Double.TYPE)
-			return 8;
+	private int primitiveSize(Class<?> type) {
+		if (type == Byte.TYPE || type == Boolean.TYPE) {
+            return 1;
+        }
+		if (type == Short.TYPE || type == Character.TYPE) {
+            return 2;
+        }
+		if (type == Integer.TYPE || type == Float.TYPE) {
+            return 4;
+        }
+		if (type == Long.TYPE || type == Double.TYPE) {
+            return 8;
+        }
 		return 0;
 	}
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamField.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamField.java?rev=414992&r1=414991&r2=414992&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamField.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamField.java Fri Jun 16 20:33:51 2006
@@ -16,8 +16,8 @@
 package java.io;
 
 import java.lang.ref.WeakReference;
-
-import org.apache.harmony.luni.util.Sorter;
+import java.util.Arrays;
+import java.util.Comparator;
 
 /**
  * This class represents object fields that are saved to the stream, by
@@ -42,7 +42,7 @@
 	// Cached version of intern'ed type String
 	private String typeString;
 
-	private boolean unshared = false;
+	private boolean unshared;
 
 	/**
 	 * Constructs an ObjectStreamField with the given name and the given type
@@ -148,7 +148,7 @@
 	 */
 	public Class<?> getType() {
 		if (type instanceof WeakReference) {
-			return ((WeakReference<Class<?>>) type).get();
+			return (Class<?>)((WeakReference) type).get();
 		}
 		return (Class<?>) type;
 	}
@@ -160,7 +160,7 @@
 	 * @return A char, the typecode of the class
 	 */
 	public char getTypeCode() {
-		Class t = getType();
+		Class<?> t = getType();
 		if (t == Integer.TYPE) {
 			return 'I';
 		}
@@ -202,7 +202,7 @@
 			return null;
 		}
 		if (typeString == null) {
-			Class t = getType();
+			Class<?> t = getType();
 			String typeName = t.getName().replace('.', '/');
 			String str = (t.isArray()) ? typeName : ("L" + typeName + ';'); //$NON-NLS-1$
 			typeString = str.intern();
@@ -218,7 +218,7 @@
 	 *         type of this field is a regular class.
 	 */
 	public boolean isPrimitive() {
-		Class t = getType();
+		Class<?> t = getType();
 		return t != null && t.isPrimitive();
 	}
 
@@ -253,14 +253,12 @@
 	static void sortFields(ObjectStreamField[] fields) {
 		// Sort if necessary
 		if (fields.length > 1) {
-			Sorter.Comparator fieldDescComparator = new Sorter.Comparator() {
-				public int compare(Object o1, Object o2) {
-					ObjectStreamField f1 = (ObjectStreamField) o1;
-					ObjectStreamField f2 = (ObjectStreamField) o2;
+			Comparator<ObjectStreamField> fieldDescComparator = new Comparator<ObjectStreamField>() {
+				public int compare(ObjectStreamField f1, ObjectStreamField f2) {
 					return f1.compareTo(f2);
 				}
 			};
-			Sorter.sort(fields, fieldDescComparator);
+			Arrays.sort(fields, fieldDescComparator);
 		}
 	}
 
@@ -299,7 +297,7 @@
 			className = className.substring(1, className.length() - 1);
 		}
 		try {
-			Class cl = Class.forName(className, false, loader);
+			Class<?> cl = Class.forName(className, false, loader);
 			type = (cl.getClassLoader() == null) ? cl : new WeakReference<Class<?>>(cl);
 		} catch (ClassNotFoundException e) {
 			// Ignored

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStreamWriter.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStreamWriter.java?rev=414992&r1=414991&r2=414992&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStreamWriter.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStreamWriter.java Fri Jun 16 20:33:51 2006
@@ -29,7 +29,7 @@
 /**
  * OutputStreamWriter is a class for turning a character output stream into a
  * byte output stream. The conversion of Unicode characters to their byte
- * equivalents is determinded by the converter used. By default, the encoding is
+ * equivalents is determined by the converter used. By default, the encoding is
  * ISO8859_1 (ISO-Latin-1) but can be changed by calling the constructor which
  * takes an encoding.
  * 
@@ -56,8 +56,9 @@
 	public OutputStreamWriter(OutputStream out) {
 		super(out);
 		this.out = out;
-		String encoding = (String) AccessController
-				.doPrivileged(new PriviAction("file.encoding", "ISO8859_1")); //$NON-NLS-1$ //$NON-NLS-2$
+		String encoding = AccessController
+                .doPrivileged(new PriviAction<String>(
+                        "file.encoding", "ISO8859_1")); //$NON-NLS-1$ //$NON-NLS-2$
 		encoder = Charset.forName(encoding).newEncoder();
 		encoder.onMalformedInput(CodingErrorAction.REPLACE);
 		encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintStream.java?rev=414992&r1=414991&r2=414992&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintStream.java Fri Jun 16 20:33:51 2006
@@ -15,7 +15,6 @@
 
 package java.io;
 
-
 import java.nio.charset.Charset;
 import java.security.AccessController;
 import java.util.Formatter;
@@ -29,7 +28,7 @@
  * PrintStream is a class which takes an OutputStream and provides convenience
  * methods for printing common data types in a human readable format on the
  * stream. This is not to be confused with DataOutputStream which is used for
- * encoding common datatypes so that they can be read back in. No IOExceptions
+ * encoding common data types so that they can be read back in. No IOExceptions
  * are thrown by this class. Instead, callers should call checkError() to see if
  * a problem has been encountered in this Stream.
  * 
@@ -45,18 +44,18 @@
 	/**
 	 * indicates whether or not this PrintStream has incurred an error.
 	 */
-	boolean ioError = false;
+	boolean ioError;
 
 	/**
 	 * indicates whether or not this PrintStream should flush its contents after
 	 * printing a new line.
 	 */
-	boolean autoflush = false;
+	boolean autoflush;
 
 	private String encoding;
 
-	private final String lineSeparator = (String) AccessController
-			.doPrivileged(new PriviAction("line.separator")); //$NON-NLS-1$
+	private final String lineSeparator = AccessController
+			.doPrivileged(new PriviAction<String>("line.separator")); //$NON-NLS-1$
 
 	static final String TOKEN_NULL = "null"; //$NON-NLS-1$
 
@@ -73,8 +72,9 @@
 	 */
 	public PrintStream(OutputStream out) {
 		super(out);
-		if (out == null)
-			throw new NullPointerException();
+		if (out == null) {
+            throw new NullPointerException();
+        }
 	}
 
 	/**
@@ -91,8 +91,9 @@
 	 */
 	public PrintStream(OutputStream out, boolean autoflush) {
 		super(out);
-		if (out == null)
-			throw new NullPointerException();
+		if (out == null) {
+            throw new NullPointerException();
+        }
 		this.autoflush = autoflush;
 	}
 
@@ -116,11 +117,13 @@
 	public PrintStream(OutputStream out, boolean autoflush, String enc)
 			throws UnsupportedEncodingException {
 		super(out);
-		if (out == null)
-			throw new NullPointerException();
+		if (out == null) {
+            throw new NullPointerException();
+        }
 		this.autoflush = autoflush;
-		if (!Charset.isSupported(enc))
-			throw new UnsupportedEncodingException(enc);
+		if (!Charset.isSupported(enc)) {
+            throw new UnsupportedEncodingException(enc);
+        }
 		encoding = enc;
 	}
 
@@ -163,10 +166,12 @@
 	public PrintStream(File file, String csn) throws FileNotFoundException,
 			UnsupportedEncodingException {
 		super(new FileOutputStream(file));
-		if (csn == null)
-			throw new NullPointerException();
-		if (!Charset.isSupported(csn))
-			throw new UnsupportedEncodingException();
+		if (csn == null) {
+            throw new NullPointerException();
+        }
+		if (!Charset.isSupported(csn)) {
+            throw new UnsupportedEncodingException();
+        }
 		encoding = csn;
 	}
 
@@ -216,15 +221,16 @@
 	/**
 	 * Answers a boolean indicating whether or not this PrintStream has
 	 * encountered an error. If so, the receiver should probably be closed since
-	 * futher writes will not actually take place. A side effect of calling
+	 * further writes will not actually take place. A side effect of calling
 	 * checkError is that the target OutputStream is flushed.
 	 * 
 	 * @return <code>true</code> if an error occurred in this PrintStream,
 	 *         <code>false</code> otherwise.
 	 */
 	public boolean checkError() {
-		if (out != null)
-			flush();
+		if (out != null) {
+            flush();
+        }
 		return ioError;
 	}
 
@@ -473,10 +479,11 @@
 			}
 
 			try {
-				if (encoding == null)
-					write(str.getBytes());
-				else
-					write(str.getBytes(encoding));
+				if (encoding == null) {
+                    write(str.getBytes());
+                } else {
+                    write(str.getBytes(encoding));
+                }
 			} catch (IOException e) {
 				setError();
 			}
@@ -648,17 +655,19 @@
 					}
 					try {
 						out.write(buffer, offset, count);
-						if (autoflush)
-							flush();
+						if (autoflush) {
+                            flush();
+                        }
 					} catch (IOException e) {
 						setError();
 					}
 				}
-			} else
-				throw new ArrayIndexOutOfBoundsException(org.apache.harmony.luni.util.Msg
-						.getString("K002f")); //$NON-NLS-1$
-		} else
-			throw new NullPointerException();
+			} else {
+                throw new ArrayIndexOutOfBoundsException(Msg.getString("K002f")); //$NON-NLS-1$
+            }
+		} else {
+            throw new NullPointerException();
+        }
 	}
 
 	/**
@@ -680,8 +689,9 @@
 			}
 			try {
 				out.write(oneByte);
-				if (autoflush && (oneByte & 0xFF) == '\n')
-					flush();
+				if (autoflush && (oneByte & 0xFF) == '\n') {
+                    flush();
+                }
 			} catch (IOException e) {
 				setError();
 			}
@@ -723,27 +733,24 @@
 	}
 
 	/**
-	 * Append a subsequence of a CharSequence <code>csq</code> to the
-	 * PrintStream. The first char and the last char of the subsequnce is
-	 * specified by the parameter <code>start</code> and <code>end</code>.
-	 * The PrintStream.append(<code>csq</code>) works the same way as
-	 * PrintStream.print (<code>csq</code>csq.subSequence(<code>start</code>,<code>end</code>).toString).If
-	 * <code>csq</code> is null, then "null" will be substituted for
-	 * <code>csq</code>.
-	 * 
-	 * @param csq
-	 *            The CharSequence appended to the PrintStream.
-	 * @param start
-	 *            The index of the first char in the CharSequence appended to
-	 *            the PrintStream.
-	 * @param end
-	 *            The index of the char after the last one in the CharSequence
-	 *            appended to the PrintStream.
-	 * @return The PrintStream.
-	 * @throws IndexOutOfBoundsException
-	 *             If start is less than end, end is greater than the length of
-	 *             the CharSequence, or start or end is negative.
-	 */
+     * Append a subsequence of a CharSequence <code>csq</code> to the
+     * PrintStream. The first char and the last char of the subsequnce is
+     * specified by the parameter <code>start</code> and <code>end</code>.
+     * The PrintStream.append(<code>csq</code>) works the same way as
+     * PrintStream.print (<code>csq</code>csq.subSequence(<code>start</code>,
+     * <code>end</code>).toString). If <code>csq</code> is null, then
+     * "null" will be substituted for <code>csq</code>.
+     * 
+     * @param csq The CharSequence appended to the PrintStream.
+     * @param start The index of the first char in the CharSequence appended to
+     *        the PrintStream.
+     * @param end The index of the char after the last one in the CharSequence
+     *        appended to the PrintStream.
+     * @return The PrintStream.
+     * @throws IndexOutOfBoundsException If start is less than end, end is
+     *         greater than the length of the CharSequence, or start or end is
+     *         negative.
+     */
 	public PrintStream append(CharSequence csq, int start, int end) {
 		if (null == csq) {
 			print(TOKEN_NULL.substring(start, end));

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintWriter.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintWriter.java?rev=414992&r1=414991&r2=414992&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintWriter.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintWriter.java Fri Jun 16 20:33:51 2006
@@ -15,7 +15,6 @@
 
 package java.io;
 
-
 import java.security.AccessController;
 import java.util.Formatter;
 import java.util.IllegalFormatException;
@@ -41,16 +40,16 @@
 	/**
 	 * indicates whether or not this PrintWriter has incurred an error.
 	 */
-	boolean ioError = false;
+	boolean ioError;
 
 	/**
 	 * indicates whether or not this PrintWriter should flush its contents after
 	 * printing a new line.
 	 */
-	boolean autoflush = false;
+	boolean autoflush;
 
-	private final String lineSeparator = (String) AccessController
-			.doPrivileged(new PriviAction("line.separator")); //$NON-NLS-1$
+	private final String lineSeparator = AccessController
+            .doPrivileged(new PriviAction<String>("line.separator")); //$NON-NLS-1$
 
 	/**
 	 * Constructs a new PrintWriter on the OutputStream <code>out</code>. All
@@ -198,14 +197,15 @@
     /**
 	 * Answers a boolean indicating whether or not this PrintWriter has
 	 * encountered an error. If so, the receiver should probably be closed since
-	 * futher writes will not actually take place. A side effect of calling
+	 * further writes will not actually take place. A side effect of calling
 	 * checkError is that the target Writer is flushed.
 	 * 
 	 * @return boolean has an error occurred in this PrintWriter.
 	 */
 	public boolean checkError() {
-		if (out != null)
-			flush();
+		if (out != null) {
+            flush();
+        }
 		return ioError;
 	}
 
@@ -362,8 +362,9 @@
 
 	private void newline() {
 		print(lineSeparator);
-		if (autoflush)
-			flush();
+		if (autoflush) {
+            flush();
+        }
 	}
 
 	/**
@@ -693,7 +694,7 @@
 	 * Append a CharSequence <code>csq</code> to the PrintWriter. The
 	 * PrintWriter.append(<code>csq</code>) works the same way as
 	 * PrintWriter.write(<code>csq</code>.toString()). If <code>csq</code>
-	 * is null, then "null" will be subsituted for <code>csq</code>
+	 * is null, then "null" will be substituted for <code>csq</code>
 	 * 
 	 * @override Writer.append
 	 * @param csq
@@ -711,7 +712,7 @@
 
 	/**
 	 * Append a subsequence of a CharSequence <code>csq</code> to the
-	 * PrintWriter. The first char and the last char of the subsequnce is
+	 * PrintWriter. The first char and the last char of the subsequence is
 	 * specified by the parameter <code>start</code> and <code>end</code>.
 	 * The PrintWriter.append(<code>csq</code>) works the same way as
 	 * PrintWriter.write(<code>csq</code>.subSequence(<code>start</code>,<code>end</code>).toString).If

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SequenceInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SequenceInputStream.java?rev=414992&r1=414991&r2=414992&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SequenceInputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SequenceInputStream.java Fri Jun 16 20:33:51 2006
@@ -16,6 +16,7 @@
 package java.io;
 
 import java.util.Enumeration;
+import java.util.Vector;
 
 
 /**
@@ -28,7 +29,7 @@
 	/**
 	 * An enumeration which will return types of InputStream.
 	 */
-	java.util.Enumeration e;
+	Enumeration<? extends InputStream> e;
 
 	/**
 	 * The current input stream.
@@ -47,12 +48,13 @@
 	 */
 	public SequenceInputStream(InputStream s1, InputStream s2) {
 		if (s1 != null && s2 != null) {
-			java.util.Vector inVector = new java.util.Vector(1);
+			Vector<InputStream> inVector = new Vector<InputStream>(1);
 			inVector.addElement(s2);
 			e = inVector.elements();
 			in = s1;
-		} else
-			throw new NullPointerException();
+		} else {
+            throw new NullPointerException();
+        }
 	}
 
 	/**
@@ -66,9 +68,10 @@
 	public SequenceInputStream(Enumeration<? extends InputStream> e) {
 		this.e = e;
 		if (e.hasMoreElements()) {
-			in = (InputStream) e.nextElement();
-			if (in == null)
-				throw new NullPointerException();
+			in = e.nextElement();
+			if (in == null) {
+                throw new NullPointerException();
+            }
 		}
 	}
 
@@ -82,8 +85,9 @@
 	 *             If an error occurs in this InputStream.
 	 */
 	public int available() throws IOException {
-		if (e != null && in != null)
-			return in.available();
+		if (e != null && in != null) {
+            return in.available();
+        }
 		return 0;
 	}
 
@@ -97,11 +101,13 @@
 	 */
 	public void close() throws IOException {
 		if (e != null) {
-			while (in != null)
-				nextStream();
+			while (in != null) {
+                nextStream();
+            }
 			e = null;
-		} else
-			throw new IOException(org.apache.harmony.luni.util.Msg.getString("K00b7")); //$NON-NLS-1$
+		} else {
+            throw new IOException(org.apache.harmony.luni.util.Msg.getString("K00b7")); //$NON-NLS-1$
+        }
 	}
 
 	/**
@@ -109,12 +115,14 @@
 	 * @throws IOException 
 	 */
 	private void nextStream() throws IOException {
-		if (in != null)
-			in.close();
+		if (in != null) {
+            in.close();
+        }
 		if (e.hasMoreElements()) {
-			in = (InputStream) e.nextElement();
-			if (in == null)
-				throw new NullPointerException();
+			in = e.nextElement();
+			if (in == null) {
+                throw new NullPointerException();
+            }
 		} else {
 			in = null;
 		}
@@ -134,8 +142,9 @@
 	public int read() throws IOException {
 		while (in != null) {
 			int result = in.read();
-			if (result >= 0)
-				return result;
+			if (result >= 0) {
+                return result;
+            }
 			nextStream();
 		}
 		return -1;
@@ -165,24 +174,28 @@
 			if (offset >= 0 && count >= 0) {
 				while (in != null) {
 					long result = in.skip(count);
-					if (result >= 0)
-						return (int) result;
+					if (result >= 0) {
+                        return (int) result;
+                    }
 					nextStream();
 				}
-			} else
-				throw new ArrayIndexOutOfBoundsException();
+			} else {
+                throw new ArrayIndexOutOfBoundsException();
+            }
 		} else {
 			// avoid int overflow
 			if (0 <= offset && offset <= buffer.length && 0 <= count
 					&& count <= buffer.length - offset) {
 				while (in != null) {
 					int result = in.read(buffer, offset, count);
-					if (result >= 0)
-						return result;
+					if (result >= 0) {
+                        return result;
+                    }
 					nextStream();
 				}
-			} else
-				throw new ArrayIndexOutOfBoundsException();
+			} else {
+                throw new ArrayIndexOutOfBoundsException();
+            }
 		}
 		return -1;
 	}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SerializablePermission.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SerializablePermission.java?rev=414992&r1=414991&r2=414992&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SerializablePermission.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SerializablePermission.java Fri Jun 16 20:33:51 2006
@@ -15,6 +15,8 @@
 
 package java.io;
 
+import java.security.BasicPermission;
+
 
 /**
  * SerializablePermission objects represent permission to access unsafe
@@ -28,9 +30,10 @@
  * 
  * @see ObjectStreamConstants
  */
-public final class SerializablePermission extends java.security.BasicPermission {
+public final class SerializablePermission extends BasicPermission {
 	private static final long serialVersionUID = 8537212141160296410L;
 
+    //Serializable field
 	private String actions;
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ClassCastException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ClassCastException.java?rev=414992&r1=414991&r2=414992&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ClassCastException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ClassCastException.java Fri Jun 16 20:33:51 2006
@@ -15,10 +15,11 @@
 
 package java.lang;
 
+import org.apache.harmony.luni.util.Msg;
 
 /**
  * This runtime exception is thrown when a program attempts to cast a an object
- * to a type which it is not compatable with.
+ * to a type which it is not compatible with.
  * 
  */
 public class ClassCastException extends RuntimeException {
@@ -53,8 +54,8 @@
 	 * @param castClass
 	 *            Class The class being cast to.
 	 */
-	ClassCastException(Class instanceClass, Class castClass) {
-		super(org.apache.harmony.luni.util.Msg.getString("K0340", instanceClass.getName(),
-				castClass.getName()));
-	}
+	ClassCastException(Class<?> instanceClass, Class<?> castClass) {
+        super(Msg.getString("K0340", instanceClass.getName(), castClass
+                .getName()));
+    }
 }



Mime
View raw message