harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r903199 [3/4] - in /harmony/enhanced/classlib/branches/java6: ./ depends/libs/ make/ modules/accessibility/src/test/api/java/common/javax/accessibility/ modules/archive/src/main/java/java/util/jar/ modules/archive/src/main/java/java/util/zi...
Date Tue, 26 Jan 2010 12:40:40 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/IllegalClassFormatExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/IllegalClassFormatExceptionTest.java?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/IllegalClassFormatExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/IllegalClassFormatExceptionTest.java Tue Jan 26 12:40:37 2010
@@ -40,4 +40,15 @@
         IllegalClassFormatException object = new IllegalClassFormatException();
         SerializationTest.verifyGolden(this, object);        
     }
+    
+    /**
+     * @tests java.lang.instrument.IllegalClassFormatException#
+     *        IllegalClassFormatException(java.lang.String)}
+     */
+    public void test_IllegalClassFormatException_LString() {
+        IllegalClassFormatException object = new IllegalClassFormatException(
+                "Some Error Message");
+        assertEquals("Wrong message from constructor(String)",
+                "Some Error Message", object.getMessage());
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/UnmodifiableClassExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/UnmodifiableClassExceptionTest.java?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/UnmodifiableClassExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/UnmodifiableClassExceptionTest.java Tue Jan 26 12:40:37 2010
@@ -40,4 +40,15 @@
         UnmodifiableClassException object = new UnmodifiableClassException();
         SerializationTest.verifyGolden(this, object);
     }
+    
+    /**
+     * @tests java.lang.instrument.UnmodifiableClassException#
+     *        UnmodifiableClassException(java.lang.String)}.
+     */
+    public void test_UnmodifiableClassException_LString() {
+        UnmodifiableClassException object = new UnmodifiableClassException(
+                "Some Error Message");
+        assertEquals("Wrong message from constructor(String)",
+                "Some Error Message", object.getMessage());
+    }
 }

Propchange: harmony/enhanced/classlib/branches/java6/modules/jmx/META-INF/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 26 12:40:37 2010
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/jmx/META-INF:768152-885602
+/harmony/enhanced/classlib/trunk/modules/jmx/META-INF:768152-901560

Propchange: harmony/enhanced/classlib/branches/java6/modules/lang-management/src/test/api/java/org/apache/harmony/lang/management/tests/java/util/logging/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 26 12:40:37 2010
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/lang-management/src/test/api/java/org/apache/harmony/lang/management/tests/java/util/logging:768152-885602
+/harmony/enhanced/classlib/trunk/modules/lang-management/src/test/api/java/org/apache/harmony/lang/management/tests/java/util/logging:768152-901560

Modified: harmony/enhanced/classlib/branches/java6/modules/logging/src/main/java/java/util/logging/LogManager.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/logging/src/main/java/java/util/logging/LogManager.java?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/logging/src/main/java/java/util/logging/LogManager.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/logging/src/main/java/java/util/logging/LogManager.java Tue Jan 26 12:40:37 2010
@@ -205,7 +205,7 @@
                 try {
                     manager.readConfiguration();
                 } catch (Exception e) {
-                    e.printStackTrace();
+                    // e.printStackTrace();
                 }
 
                 // if global logger has been initialized, set root as its parent

Modified: harmony/enhanced/classlib/branches/java6/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LogManagerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LogManagerTest.java?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LogManagerTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LogManagerTest.java Tue Jan 26 12:40:37 2010
@@ -19,6 +19,7 @@
 
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintStream;
@@ -811,23 +812,46 @@
         }
 
     }
-    
-    public void testValidConfigClass() throws Exception{
-        String oldProperty = System.getProperty("java.util.logging.config.class");
-        try{
-//            System.setProperty("java.util.logging.config.class", "org.apache.harmony.logging.tests.java.util.logging.LogManagerTest$ConfigClass");
-            System.setProperty("java.util.logging.config.class", this.getClass().getName()+"$ConfigClass");            
+
+    public void testValidConfigClass() throws Exception {
+        String oldPropertyValue = System
+                .getProperty("java.util.logging.config.class");
+        try {
+            System.setProperty("java.util.logging.config.class", this
+                    .getClass().getName()
+                    + "$ConfigClass");
             assertNull(manager.getLogger("testConfigClass.foo"));
-            
+
             manager.readConfiguration();
             assertNull(manager.getLogger("testConfigClass.foo"));
             Logger l = Logger.getLogger("testConfigClass.foo.child");
             assertSame(Level.FINEST, manager.getLogger("").getLevel());
-            assertEquals(0, manager.getLogger("").getHandlers().length);            
+            assertEquals(0, manager.getLogger("").getHandlers().length);
             assertEquals("testConfigClass.foo", l.getParent().getName());
-        }finally{
-            if(oldProperty != null){
-                System.setProperty("java.util.logging.config.class", oldProperty);
+        } finally {
+            Properties systemProperties = System.getProperties();
+            if (oldPropertyValue != null) {
+                systemProperties.setProperty(CONFIG_CLASS, oldPropertyValue);
+            } else {
+                systemProperties.remove(CONFIG_CLASS);
+            }
+        }
+    }
+
+    public void testNotExistConfigFile() throws Exception {
+        String oldPropertyValue = System.getProperty(CONFIG_FILE);
+        System.setProperty(CONFIG_FILE, "not.exist.config.file");
+        try {
+            LogManager.getLogManager().readConfiguration();
+            fail("should throw FileNotFoundException");
+        } catch (FileNotFoundException e) {
+            // Expected
+        } finally {
+            Properties systemProperties = System.getProperties();
+            if (oldPropertyValue != null) {
+                systemProperties.setProperty(CONFIG_FILE, oldPropertyValue);
+            } else {
+                systemProperties.remove(CONFIG_FILE);
             }
         }
     }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni-kernel/src/main/java/org/apache/harmony/kernel/vm/VM.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni-kernel/src/main/java/org/apache/harmony/kernel/vm/VM.java?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni-kernel/src/main/java/org/apache/harmony/kernel/vm/VM.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni-kernel/src/main/java/org/apache/harmony/kernel/vm/VM.java Tue Jan 26 12:40:37 2010
@@ -70,7 +70,8 @@
      * </ul>
      *
      * @param depth the stack depth of the requested Class
-     * @return the Class at the specified depth
+     * @return the Class at the specified depth or null if depth is outside the
+     *         bounds of the stack
      * @see Class#getStackClasses
      */
     public static Class<?> getStackClass(int depth) {

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/META-INF/MANIFEST.MF?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/META-INF/MANIFEST.MF (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/META-INF/MANIFEST.MF Tue Jan 26 12:40:37 2010
@@ -21,6 +21,7 @@
  java.security,
  java.security.cert,
  java.text,
+ java.util.concurrent;resolution:=optional,
  java.util.jar,
  java.util.regex,
  java.util.zip,

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/String.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/String.java?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/String.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/String.java Tue Jan 26 12:40:37 2010
@@ -857,8 +857,9 @@
         }
         if (object instanceof String) {
             String s = (String) object;
-            if (count != s.count
-                    || (hashCode != s.hashCode && hashCode != 0 && s.hashCode != 0)) {
+            int hash = hashCode;  // Single read on hashCodes as they may change
+            int shash = s.hashCode;
+            if (count != s.count || (hash != shash && hash != 0 && shash != 0)) {
                 return false;
             }
             for (int i = 0; i < count; ++i) {

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/AbstractList.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/AbstractList.java?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/AbstractList.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/AbstractList.java Tue Jan 26 12:40:37 2010
@@ -36,53 +36,48 @@
     protected transient int modCount;
 
     private class SimpleListIterator implements Iterator<E> {
-        int pos = -1;
-
-        int expectedModCount;
-
+        int numLeft = size();
+        int expectedModCount = modCount;
         int lastPosition = -1;
 
-        SimpleListIterator() {
-            super();
-            expectedModCount = modCount;
-        }
-
         public boolean hasNext() {
-            return pos + 1 < size();
+            return numLeft > 0;
         }
 
         public E next() {
-            if (expectedModCount == modCount) {
-                try {
-                    E result = get(pos + 1);
-                    lastPosition = ++pos;
-                    return result;
-                } catch (IndexOutOfBoundsException e) {
-                    throw new NoSuchElementException();
-                }
+            if (expectedModCount != modCount) {
+                throw new ConcurrentModificationException();
+            }
+
+            try {
+                int index = size() - numLeft;
+                E result = get(index);
+                lastPosition = index;
+                numLeft--;
+                return result;
+            } catch (IndexOutOfBoundsException e) {
+                throw new NoSuchElementException();
             }
-            throw new ConcurrentModificationException();
         }
 
         public void remove() {
-            if (this.lastPosition == -1) {
+            if (lastPosition == -1) {
                 throw new IllegalStateException();
             }
-
             if (expectedModCount != modCount) {
                 throw new ConcurrentModificationException();
             }
 
             try {
+                if (lastPosition == size() - numLeft) {
+                    numLeft--; // we're removing after a call to previous()
+                }
                 AbstractList.this.remove(lastPosition);
             } catch (IndexOutOfBoundsException e) {
                 throw new ConcurrentModificationException();
             }
             
             expectedModCount = modCount;
-            if (pos == lastPosition) {
-                pos--;
-            }
             lastPosition = -1;
         }
     }
@@ -90,67 +85,64 @@
     private final class FullListIterator extends SimpleListIterator implements
             ListIterator<E> {
         FullListIterator(int start) {
-            super();
-            if (0 <= start && start <= size()) {
-                pos = start - 1;
-            } else {
+            if (start < 0 || start > numLeft) {
                 throw new IndexOutOfBoundsException();
             }
+            numLeft -= start;
         }
 
         public void add(E object) {
-            if (expectedModCount == modCount) {
-                try {
-                    AbstractList.this.add(pos + 1, object);
-                } catch (IndexOutOfBoundsException e) {
-                    throw new NoSuchElementException();
-                }
-                pos++;
-                lastPosition = -1;
-                if (modCount != expectedModCount) {
-                    expectedModCount = modCount;
-                }
-            } else {
+            if (expectedModCount != modCount) {
                 throw new ConcurrentModificationException();
             }
+
+            try {
+                AbstractList.this.add(size() - numLeft, object);
+                expectedModCount = modCount;
+                lastPosition = -1;
+            } catch (IndexOutOfBoundsException e) {
+                throw new NoSuchElementException();
+            }
         }
 
         public boolean hasPrevious() {
-            return pos >= 0;
+            return numLeft < size();
         }
 
         public int nextIndex() {
-            return pos + 1;
+            return size() - numLeft;
         }
 
         public E previous() {
-            if (expectedModCount == modCount) {
-                try {
-                    E result = get(pos);
-                    lastPosition = pos;
-                    pos--;
-                    return result;
-                } catch (IndexOutOfBoundsException e) {
-                    throw new NoSuchElementException();
-                }
+            if (expectedModCount != modCount) {
+                throw new ConcurrentModificationException();
+            }
+
+            try {
+                int index = size() - numLeft - 1;
+                E result = get(index);
+                numLeft++;
+                lastPosition = index;
+                return result;
+            } catch (IndexOutOfBoundsException e) {
+                throw new NoSuchElementException();
             }
-            throw new ConcurrentModificationException();
         }
 
         public int previousIndex() {
-            return pos;
+            return size() - numLeft - 1;
         }
 
         public void set(E object) {
-            if (expectedModCount == modCount) {
-                try {
-                    AbstractList.this.set(lastPosition, object);
-                } catch (IndexOutOfBoundsException e) {
-                    throw new IllegalStateException();
-                }
-            } else {
+            if (expectedModCount != modCount) {
                 throw new ConcurrentModificationException();
             }
+
+            try {
+                AbstractList.this.set(lastPosition, object);
+            } catch (IndexOutOfBoundsException e) {
+                throw new IllegalStateException();
+            }
         }
     }
 

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/AbstractMap.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/AbstractMap.java?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/AbstractMap.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/AbstractMap.java Tue Jan 26 12:40:37 2010
@@ -370,19 +370,22 @@
                 return false;
             }
 
-            Iterator<Map.Entry<K, V>> it = entrySet().iterator();
-
             try {
-                while (it.hasNext()) {
-                    Entry<K, V> entry = it.next();
+                for (Entry<K, V> entry : entrySet()) {
                     K key = entry.getKey();
-                    V value = entry.getValue();
-                    Object obj = map.get(key);
-                    if( null != obj && (!obj.equals(value)) || null == obj && obj != value) {
+                    V mine = entry.getValue();
+                    Object theirs = map.get(key);
+                    if (mine == null) {
+                        if (theirs != null || !map.containsKey(key)) {
+                            return false;
+                        }
+                    } else if (!mine.equals(theirs)) {
                         return false;
                     }
                 }
-            } catch (ClassCastException cce) {
+            } catch (NullPointerException ignored) {
+                return false;
+            } catch (ClassCastException ignored) {
                 return false;
             }
             return true;

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/AbstractSet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/AbstractSet.java?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/AbstractSet.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/AbstractSet.java Tue Jan 26 12:40:37 2010
@@ -55,7 +55,9 @@
 
             try {
                 return size() == s.size() && containsAll(s);
-            } catch (ClassCastException cce) {
+            } catch (NullPointerException ignored) {
+                return false;
+            } catch (ClassCastException ignored) {
                 return false;
             }
         }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Arrays.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Arrays.java?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Arrays.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Arrays.java Tue Jan 26 12:40:37 2010
@@ -1756,6 +1756,26 @@
         return equals((short[]) e1, (short[]) e2);
     }
 
+    private static boolean isSame(double double1, double double2) {
+        // Simple case
+        if (double1 == double2 && 0.0d != double1) {
+            return true;
+        }
+
+        // Deal with NaNs
+        if (Double.isNaN(double1)) {
+            return Double.isNaN(double2);
+        }
+        if (Double.isNaN(double2)) {
+            return false;
+        }
+
+        // Deal with +0.0 and -0.0
+        long d1 = Double.doubleToRawLongBits(double1);
+        long d2 = Double.doubleToRawLongBits(double2);
+        return d1 == d2;
+    }
+
     private static boolean lessThan(double double1, double double2) {
         // A slightly specialized version of
         // Double.compare(double1, double2) < 0.
@@ -1784,6 +1804,26 @@
         return d1 < d2;
     }
 
+    private static boolean isSame(float float1, float float2) {
+        // Simple case
+        if (float1 == float2 && 0.0d != float1) {
+            return true;
+        }
+
+        // Deal with NaNs
+        if (Float.isNaN(float1)) {
+            return Float.isNaN(float2);
+        }
+        if (Float.isNaN(float2)) {
+            return false;
+        }
+
+        // Deal with +0.0 and -0.0
+        int f1 = Float.floatToRawIntBits(float1);
+        int f2 = Float.floatToRawIntBits(float2);
+        return f1 == f2;
+    }
+    
     private static boolean lessThan(float float1, float float2) {
         // A slightly specialized version of Float.compare(float1, float2) < 0.
 
@@ -2156,7 +2196,7 @@
         c = d = end - 1;
         while (true) {
             while (b <= c && !lessThan(partionValue, array[b])) {
-                if (array[b] == partionValue) {
+                if (isSame(array[b], partionValue)) {
                     temp = array[a];
                     array[a++] = array[b];
                     array[b] = temp;
@@ -2164,7 +2204,7 @@
                 b++;
             }
             while (c >= b && !lessThan(array[c], partionValue)) {
-                if (array[c] == partionValue) {
+                if (isSame(array[c], partionValue)) {
                     temp = array[c];
                     array[c] = array[d];
                     array[d--] = temp;
@@ -2269,7 +2309,7 @@
         c = d = end - 1;
         while (true) {
             while (b <= c && !lessThan(partionValue, array[b])) {
-                if (array[b] == partionValue) {
+                if (isSame(array[b], partionValue)) {
                     temp = array[a];
                     array[a++] = array[b];
                     array[b] = temp;
@@ -2277,7 +2317,7 @@
                 b++;
             }
             while (c >= b && !lessThan(array[c], partionValue)) {
-                if (array[c] == partionValue) {
+                if (isSame(array[c], partionValue)) {
                     temp = array[c];
                     array[c] = array[d];
                     array[d--] = temp;

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Collections.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Collections.java?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Collections.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Collections.java Tue Jan 26 12:40:37 2010
@@ -20,6 +20,7 @@
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
+import java.io.ObjectStreamException;
 import java.io.Serializable;
 import java.lang.reflect.Array;
 
@@ -189,8 +190,15 @@
     @SuppressWarnings("unchecked")
     public static final Map EMPTY_MAP = new EmptyMap();
 
+    /**
+     * This class is a singleton so that equals() and hashCode() work properly.
+     */
     private static final class ReverseComparator<T> implements Comparator<T>,
             Serializable {
+
+        private static final ReverseComparator<Object> INSTANCE
+                = new ReverseComparator<Object>();
+
         private static final long serialVersionUID = 7207038068494060240L;
 
         @SuppressWarnings("unchecked")
@@ -198,6 +206,10 @@
             Comparable<T> c2 = (Comparable<T>) o2;
             return c2.compareTo(o1);
         }
+
+        private Object readResolve() throws ObjectStreamException {
+            return INSTANCE;
+        }
     }
 
     private static final class ReverseComparatorWithComparator<T> implements
@@ -214,6 +226,18 @@
         public int compare(T o1, T o2) {
             return comparator.compare(o2, o1);
         }
+
+        @Override
+        public boolean equals(Object o) {
+            return o instanceof ReverseComparatorWithComparator
+                    && ((ReverseComparatorWithComparator) o).comparator
+                            .equals(comparator);
+        }
+
+        @Override
+        public int hashCode() {
+            return ~comparator.hashCode();
+        }
     }
 
     private static final class SingletonSet<E> extends AbstractSet<E> implements
@@ -353,34 +377,17 @@
                         }
 
                         public Map.Entry<K, V> next() {
-                            if (hasNext) {
-                                hasNext = false;
-                                return new Map.Entry<K, V>() {
-                                    @Override
-                                    public boolean equals(Object object) {
-                                        return contains(object);
-                                    }
-
-                                    public K getKey() {
-                                        return k;
-                                    }
-
-                                    public V getValue() {
-                                        return v;
-                                    }
-
-                                    @Override
-                                    public int hashCode() {
-                                        return (k == null ? 0 : k.hashCode())
-                                                ^ (v == null ? 0 : v.hashCode());
-                                    }
-
-                                    public V setValue(V value) {
-                                        throw new UnsupportedOperationException();
-                                    }
-                                };
+                            if (!hasNext) {
+                                throw new NoSuchElementException();
                             }
-                            throw new NoSuchElementException();
+
+                            hasNext = false;
+                            return new MapEntry<K, V>(k, v) {
+                                @Override
+                                public V setValue(V value) {
+                                    throw new UnsupportedOperationException();
+                                }
+                            };
                         }
 
                         public void remove() {
@@ -1685,6 +1692,12 @@
      */
     public static <T> T max(Collection<? extends T> collection,
             Comparator<? super T> comparator) {
+        if (comparator == null) {
+            @SuppressWarnings("unchecked") // null comparator? T is comparable
+            T result = (T) max((Collection<Comparable>) collection);
+            return result;
+        }
+
         Iterator<? extends T> it = collection.iterator();
         T max = it.next();
         while (it.hasNext()) {
@@ -1735,6 +1748,12 @@
      */
     public static <T> T min(Collection<? extends T> collection,
             Comparator<? super T> comparator) {
+        if (comparator == null) {
+            @SuppressWarnings("unchecked") // null comparator? T is comparable
+            T result = (T) min((Collection<Comparable>) collection);
+            return result;
+        }
+
         Iterator<? extends T> it = collection.iterator();
         T min = it.next();
         while (it.hasNext()) {
@@ -1794,8 +1813,9 @@
      * @see Comparable
      * @see Serializable
      */
+    @SuppressWarnings("unchecked")
     public static <T> Comparator<T> reverseOrder() {
-        return new ReverseComparator<T>();
+        return (Comparator) ReverseComparator.INSTANCE;
     }
 
     /**
@@ -1816,6 +1836,9 @@
         if (c == null) {
             return reverseOrder();
         }
+        if (c instanceof ReverseComparatorWithComparator) {
+            return ((ReverseComparatorWithComparator<T>) c).comparator;
+        }
         return new ReverseComparatorWithComparator<T>(c);
     }
 
@@ -2661,8 +2684,8 @@
      *            class of object that should be
      * @return specified object
      */
-    static <E> E checkType(E obj, Class<E> type) {
-        if (!type.isInstance(obj)) {
+    static <E> E checkType(E obj, Class<? extends E> type) {
+        if (obj != null && !type.isInstance(obj)) {
             // luni.05=Attempt to insert {0} element into collection with
             // element type {1}
             throw new ClassCastException(Messages.getString(
@@ -2999,20 +3022,11 @@
          */
         @SuppressWarnings("unchecked")
         public boolean addAll(Collection<? extends E> c1) {
-            int size = c1.size();
-            if (size == 0) {
-                return false;
+            Object[] array = c1.toArray();
+            for (Object o : array) {
+                checkType(o, type);
             }
-            E[] arr = (E[]) new Object[size];
-            Iterator<? extends E> it = c1.iterator();
-            for (int i = 0; i < size; i++) {
-                arr[i] = checkType(it.next(), type);
-            }
-            boolean added = false;
-            for (int i = 0; i < size; i++) {
-                added |= c.add(arr[i]);
-            }
-            return added;
+            return c.addAll((List<E>) Arrays.asList(array));
         }
 
         /**
@@ -3158,16 +3172,11 @@
          */
         @SuppressWarnings("unchecked")
         public boolean addAll(int index, Collection<? extends E> c1) {
-            int size = c1.size();
-            if (size == 0) {
-                return false;
-            }
-            E[] arr = (E[]) new Object[size];
-            Iterator<? extends E> it = c1.iterator();
-            for (int i = 0; i < size; i++) {
-                arr[i] = checkType(it.next(), type);
+            Object[] array = c1.toArray();
+            for (Object o : array) {
+                checkType(o, type);
             }
-            return l.addAll(index, Arrays.asList(arr));
+            return l.addAll(index, (List<E>) Arrays.asList(array));
         }
 
         /**

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/EnumSet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/EnumSet.java?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/EnumSet.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/EnumSet.java Tue Jan 26 12:40:37 2010
@@ -103,7 +103,7 @@
         if (c instanceof EnumSet) {
             return copyOf((EnumSet<E>) c);
         }
-        if (0 == c.size()) {
+        if (c.isEmpty()) {
             throw new IllegalArgumentException();
         }
         Iterator<E> iterator = c.iterator();
@@ -304,15 +304,13 @@
     @Override
     public EnumSet<E> clone() {
         try {
-            Object set = super.clone();
-            return (EnumSet<E>) set;
+            return (EnumSet<E>) super.clone();
         } catch (CloneNotSupportedException e) {
-            return null;
+            throw new AssertionError(e);
         }
     }
 
-    @SuppressWarnings("unchecked")
-    boolean isValidType(Class cls) {
+    boolean isValidType(Class<?> cls) {
         return cls == elementClass || cls.getSuperclass() == elementClass;
     }
 

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/HugeEnumSet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/HugeEnumSet.java?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/HugeEnumSet.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/HugeEnumSet.java Tue Jan 26 12:40:37 2010
@@ -18,90 +18,95 @@
 
 
 /**
- * This is a concrete subclass of EnumSet designed specifically for enum type
- * with more than 64 elements.
- * 
+ * A concrete EnumSet for enums with more than 64 elements.
  */
 @SuppressWarnings("serial")
 final class HugeEnumSet<E extends Enum<E>> extends EnumSet<E> {
     
+    private static final int BIT_IN_LONG = 64;
+
     final private E[] enums;
     
     private long[] bits;
     
     private int size;
     
-    private static final int BIT_IN_LONG = 64;
-    
     HugeEnumSet(Class<E> elementType) {
         super(elementType);
         enums = elementType.getEnumConstants();
         bits = new long[(enums.length + BIT_IN_LONG - 1) / BIT_IN_LONG];
-        Arrays.fill(bits, 0);
     }
     
     private class HugeEnumSetIterator implements Iterator<E> {
 
-        private long[] unProcessedBits;
+        /**
+         * The bits yet to be returned for the long in bits[index]. As values from the current index
+         * are returned, their bits are zeroed out. When this reaches zero, the index must be
+         * incremented.
+         */
+        private long currentBits = bits[0];
 
-        private int bitsPosition = 0;
+        /**
+         * The index into HugeEnumSet.bits of the next value to return.
+         */
+        private int index;
 
-        /*
-         * Mask for current element.
+        /**
+         * The single bit of the next value to return.
          */
-        private long currentElementMask = 0;
+        private long mask;
 
-        boolean canProcess = true;
+        /**
+         * The candidate for removal. If null, no value may be removed.
+         */
+        private E last;
 
         private HugeEnumSetIterator() {
-            unProcessedBits = new long[bits.length];
-            System.arraycopy(bits, 0, unProcessedBits, 0, bits.length);
-            bitsPosition = unProcessedBits.length;
-            findNextNoneZeroPosition(0);
-            if (bitsPosition == unProcessedBits.length) {
-                canProcess = false;
-            }
+            computeNextElement();
         }
 
-        private void findNextNoneZeroPosition(int start) {
-            for (int i = start; i < unProcessedBits.length; i++) {
-                if (0 != bits[i]) {
-                    bitsPosition = i;
-                    break;
+        /**
+         * Assigns mask and index to the next available value, cycling currentBits as necessary.
+         */
+        void computeNextElement() {
+            while (true) {
+                if (currentBits != 0) {
+                    mask = currentBits & -currentBits; // the lowest 1 bit in currentBits
+                    return;
+                } else if (++index < bits.length) {
+                    currentBits = bits[index];
+                } else {
+                    mask = 0;
+                    return;
                 }
             }
         }
 
         public boolean hasNext() {
-            return canProcess;
+            return mask != 0;
         }
 
         public E next() {
-            if (!canProcess) {
+            if (mask == 0) {
                 throw new NoSuchElementException();
             }
-            currentElementMask = unProcessedBits[bitsPosition]
-                    & (-unProcessedBits[bitsPosition]);
-            unProcessedBits[bitsPosition] -= currentElementMask;
-            int index = Long.numberOfTrailingZeros(currentElementMask)
-                    + bitsPosition * BIT_IN_LONG;
-            if (0 == unProcessedBits[bitsPosition]) {
-                int oldBitsPosition = bitsPosition;
-                findNextNoneZeroPosition(bitsPosition + 1);
-                if (bitsPosition == oldBitsPosition) {
-                    canProcess = false;
-                }
-            }
-            return enums[index];
+
+            int ordinal = Long.numberOfTrailingZeros(mask) + index * BIT_IN_LONG;
+            last = enums[ordinal];
+
+            currentBits &= ~mask;
+            computeNextElement();
+
+            return last;
         }
 
         public void remove() {
-            if (currentElementMask == 0) {
+            if (last == null) {
                 throw new IllegalStateException();
             }
-            bits[bitsPosition] &= ~currentElementMask;
-            size--;
-            currentElementMask = 0;
+
+            HugeEnumSet.this.remove(last);
+            last = null;
         }
     }
     
@@ -110,38 +115,44 @@
         if (!isValidType(element.getDeclaringClass())) {
             throw new ClassCastException();
         }
-        calculateElementIndex(element);
 
-        bits[bitsIndex] |= (1l << elementInBits);
-        if (oldBits == bits[bitsIndex]) {
-            return false;
+        int ordinal = element.ordinal();
+        int index = ordinal / BIT_IN_LONG;
+        int inBits = ordinal % BIT_IN_LONG;
+        long oldBits = bits[index];
+        long newBits = oldBits | (1L << inBits);
+        if (oldBits != newBits) {
+            bits[index] = newBits;
+            size++;
+            return true;
         }
-        size++;
-        return true;
+        return false;
     }
     
     @Override
     public boolean addAll(Collection<? extends E> collection) {
-        if (0 == collection.size() || this == collection) {
+        if (collection.isEmpty() || collection == this) {
             return false;
         }
+
         if (collection instanceof EnumSet) {
-            EnumSet set = (EnumSet) collection;
+            EnumSet<?> set = (EnumSet<?>) collection;
             if (!isValidType(set.elementClass)) {
                 throw new ClassCastException();
             }
-            HugeEnumSet hugeSet = (HugeEnumSet) set;
-            boolean addSuccessful = false;
+
+            HugeEnumSet<E> hugeSet = (HugeEnumSet<E>) set;
+            boolean changed = false;
             for (int i = 0; i < bits.length; i++) {
-                oldBits = bits[i];
-                bits[i] |= hugeSet.bits[i];
-                if (oldBits != bits[i]) {
-                    addSuccessful = true;
-                    size = size - Long.bitCount(oldBits)
-                            + Long.bitCount(bits[i]);
+                long oldBits = bits[i];
+                long newBits = oldBits | hugeSet.bits[i];
+                if (oldBits != newBits) {
+                    bits[i] = newBits;
+                    size += Long.bitCount(newBits) - Long.bitCount(oldBits);
+                    changed = true;
                 }
             }
-            return addSuccessful;
+            return changed;
         }
         return super.addAll(collection);
     }
@@ -159,61 +170,53 @@
     
     @Override
     protected void complement() {
-        if (0 != enums.length) {
-            bitsIndex = enums.length / BIT_IN_LONG;
+        size = 0;
+        for (int i = 0, length = bits.length; i < length; i++) {
+            long b = ~bits[i];
 
-            size = 0;
-            int bitCount = 0;
-            for (int i = 0; i <= bitsIndex; i++) {
-                bits[i] = ~bits[i];
-                bitCount = Long.bitCount(bits[i]);
-                size += bitCount;
+            // zero out unused bits on the last element
+            if (i == length - 1) {
+                b &= -1L >>> (BIT_IN_LONG - (enums.length % BIT_IN_LONG));
             }
-            bits[bitsIndex] &= (-1l >>> (BIT_IN_LONG - enums.length
-                    % BIT_IN_LONG));
-            size -= bitCount;
-            bitCount = Long.bitCount(bits[bitsIndex]);
-            size += bitCount;
+
+            size += Long.bitCount(b);
+            bits[i] = b;
         }
     }
     
-    @SuppressWarnings("unchecked")
     @Override
     public boolean contains(Object object) {
-        if (null == object) {
-            return false;
-        }
-        if (!isValidType(object.getClass())) {
+        if (object == null || !isValidType(object.getClass())) {
             return false;
         }
-        calculateElementIndex((E)object);
-        return (bits[bitsIndex] & (1l << elementInBits)) != 0;
+
+        @SuppressWarnings("unchecked") // guarded by isValidType()
+        int ordinal = ((E) object).ordinal();
+        int index = ordinal / BIT_IN_LONG;
+        int inBits = ordinal % BIT_IN_LONG;
+        return (bits[index] & (1L << inBits)) != 0;
     }
     
     @Override
-    @SuppressWarnings("unchecked")
     public HugeEnumSet<E> clone() {
-        Object set = super.clone();
-        if (null != set) {
-            ((HugeEnumSet<E>) set).bits = bits.clone();
-            return (HugeEnumSet<E>) set;
-        }
-        return null;
+        HugeEnumSet<E> set = (HugeEnumSet<E>) super.clone();
+        set.bits = bits.clone();
+        return set;
     }
     
     @Override
     public boolean containsAll(Collection<?> collection) {
-        if (collection.size() == 0) {
+        if (collection.isEmpty()) {
             return true;
         }
         if (collection instanceof HugeEnumSet) {
-            HugeEnumSet set = (HugeEnumSet) collection;
-            if(isValidType(set.elementClass )) {
-                for(int i = 0; i < bits.length; i++) {
-                    if((bits[i] & set.bits[i]) != set.bits[i]){
+            HugeEnumSet<?> set = (HugeEnumSet<?>) collection;
+            if (isValidType(set.elementClass)) {
+                for (int i = 0; i < bits.length; i++) {
+                    long setBits = set.bits[i];
+                    if ((bits[i] & setBits) != setBits) {
                         return false;
                     }
-                    
                 }
                 return true;
             }
@@ -223,13 +226,13 @@
     
     @Override
     public boolean equals(Object object) {
-        if (null == object) {
+        if (object == null) {
             return false;
         }
         if (!isValidType(object.getClass())) {
             return super.equals(object);
         }
-        return Arrays.equals(bits, ((HugeEnumSet) object).bits);
+        return Arrays.equals(bits, ((HugeEnumSet<?>) object).bits);
     }
     
     @Override
@@ -239,38 +242,48 @@
     
     @Override
     public boolean remove(Object object) {
-        if (!contains(object)) {
+        if (object == null || !isValidType(object.getClass())) {
             return false;
         }
-        bits[bitsIndex] -= (1l << elementInBits);
-        size--;
-        return true;
+
+        @SuppressWarnings("unchecked") // guarded by isValidType()
+        int ordinal = ((E) object).ordinal();
+        int index = ordinal / BIT_IN_LONG;
+        int inBits = ordinal % BIT_IN_LONG;
+        long oldBits = bits[index];
+        long newBits = oldBits & ~(1L << inBits);
+        if (oldBits != newBits) {
+            bits[index] = newBits;
+            size--;
+            return true;
+        }
+        return false;
     }
     
     @Override
     public boolean removeAll(Collection<?> collection) {
-        if (0 == collection.size()) {
+        if (collection.isEmpty()) {
             return false;
         }
         
         if (collection instanceof EnumSet) {
-            EnumSet<E> set = (EnumSet<E>) collection;
+            EnumSet<?> set = (EnumSet<?>) collection;
             if (!isValidType(set.elementClass)) {
                 return false;
             }
-            boolean removeSuccessful = false;
-            long mask = 0;
+
+            HugeEnumSet<E> hugeSet = (HugeEnumSet<E>) set;
+            boolean changed = false;
             for (int i = 0; i < bits.length; i++) {
-                oldBits = bits[i];
-                mask = bits[i] & ((HugeEnumSet<E>) set).bits[i];
-                if (mask != 0) {
-                    bits[i] -= mask;
-                    size = (size - Long.bitCount(oldBits) + Long
-                            .bitCount(bits[i]));
-                    removeSuccessful = true;
+                long oldBits = bits[i];
+                long newBits = oldBits & ~hugeSet.bits[i];
+                if (oldBits != newBits) {
+                    bits[i] = newBits;
+                    size += Long.bitCount(newBits) - Long.bitCount(oldBits);
+                    changed = true;
                 }
             }
-            return removeSuccessful;
+            return changed;
         }
         return super.removeAll(collection);
     }
@@ -278,72 +291,65 @@
     @Override
     public boolean retainAll(Collection<?> collection) {
         if (collection instanceof EnumSet) {
-            EnumSet<E> set = (EnumSet<E>) collection;
+            EnumSet<?> set = (EnumSet<?>) collection;
             if (!isValidType(set.elementClass)) {
-                clear();
-                return true;
+                if (size > 0) {
+                    clear();
+                    return true;
+                } else {
+                    return false;
+                }
             }
 
-            boolean retainSuccessful = false;
-            oldBits = 0;
+            HugeEnumSet<E> hugeSet = (HugeEnumSet<E>) set;
+            boolean changed = false;
             for (int i = 0; i < bits.length; i++) {
-                oldBits = bits[i];
-                bits[i] &= ((HugeEnumSet<E>) set).bits[i];
-                if (oldBits != bits[i]) {
-                    size = size - Long.bitCount(oldBits)
-                            + Long.bitCount(bits[i]);
-                    retainSuccessful = true;
+                long oldBits = bits[i];
+                long newBits = oldBits & hugeSet.bits[i];
+                if (oldBits != newBits) {
+                    bits[i] = newBits;
+                    size += Long.bitCount(newBits) - Long.bitCount(oldBits);
+                    changed = true;
                 }
             }
-            return retainSuccessful;
+            return changed;
         }
         return super.retainAll(collection);
     }
     
     @Override
     void setRange(E start, E end) {
-        calculateElementIndex(start);
-        int startBitsIndex = bitsIndex;
-        int startElementInBits = elementInBits;
-        calculateElementIndex(end);
-        int endBitsIndex = bitsIndex;
-        int endElementInBits = elementInBits;
-        long range = 0;
-        if (startBitsIndex == endBitsIndex) {
-            range = (-1l >>> (BIT_IN_LONG -(endElementInBits - startElementInBits + 1))) << startElementInBits;
-            size -= Long.bitCount(bits[bitsIndex]);
-            bits[bitsIndex] |= range;
-            size += Long.bitCount(bits[bitsIndex]);
+        int startOrdinal = start.ordinal();
+        int startIndex = startOrdinal / BIT_IN_LONG;
+        int startInBits = startOrdinal % BIT_IN_LONG;
+
+        int endOrdinal = end.ordinal();
+        int endIndex = endOrdinal / BIT_IN_LONG;
+        int endInBits = endOrdinal % BIT_IN_LONG;
+
+        if (startIndex == endIndex) {
+            long range = (-1L >>> (BIT_IN_LONG -(endInBits - startInBits + 1))) << startInBits;
+            size -= Long.bitCount(bits[startIndex]);
+            bits[startIndex] |= range;
+            size += Long.bitCount(bits[startIndex]);
+
         } else {
-            range = (-1l >>> startElementInBits) << startElementInBits;
-            size -= Long.bitCount(bits[startBitsIndex]);
-            bits[startBitsIndex] |= range;
-            size += Long.bitCount(bits[startBitsIndex]);
-
-            // endElementInBits + 1 is the number of consecutive ones.
-            // 63 - endElementInBits is the following zeros of the right most one.
-            range = -1l >>> (BIT_IN_LONG - (endElementInBits + 1));
-            size -= Long.bitCount(bits[endBitsIndex]);
-            bits[endBitsIndex] |= range;
-            size += Long.bitCount(bits[endBitsIndex]);
-            for(int i = (startBitsIndex + 1); i <= (endBitsIndex - 1); i++) {
+            long range = (-1L >>> startInBits) << startInBits;
+            size -= Long.bitCount(bits[startIndex]);
+            bits[startIndex] |= range;
+            size += Long.bitCount(bits[startIndex]);
+
+            // endInBits + 1 is the number of consecutive ones.
+            // 63 - endInBits is the following zeros of the right most one.
+            range = -1L >>> (BIT_IN_LONG - (endInBits + 1));
+            size -= Long.bitCount(bits[endIndex]);
+            bits[endIndex] |= range;
+            size += Long.bitCount(bits[endIndex]);
+            for (int i = (startIndex + 1); i <= (endIndex - 1); i++) {
                 size -= Long.bitCount(bits[i]);
-                bits[i] = -1l;
+                bits[i] = -1L;
                 size += Long.bitCount(bits[i]);
             }
         }
     }
-    
-    private void calculateElementIndex(E element) {
-        int elementOrdinal = element.ordinal();
-        bitsIndex = elementOrdinal / BIT_IN_LONG;
-        elementInBits = elementOrdinal % BIT_IN_LONG;
-        oldBits = bits[bitsIndex];
-    }
-    
-    private int bitsIndex;
-
-    private int elementInBits;
-
-    private long oldBits;
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/MiniEnumSet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/MiniEnumSet.java?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/MiniEnumSet.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/MiniEnumSet.java Tue Jan 26 12:40:37 2010
@@ -18,9 +18,7 @@
 
 
 /**
- * This is a concrete subclass of EnumSet designed specifically for enum type
- * with less than or equal to 64 elements.
- * 
+ * A concrete EnumSet for enums with 64 or fewer elements.
  */
 @SuppressWarnings("serial")
 final class MiniEnumSet<E extends Enum<E>> extends EnumSet<E> {
@@ -39,45 +37,47 @@
     
     private class MiniEnumSetIterator implements Iterator<E> {
 
-        private long unProcessedBits;
-
-        /*
-         * Mask for current element.
+        /**
+         * The bits yet to be returned for bits. As values from the current index are returned,
+         * their bits are zeroed out.
          */
-        private long currentElementMask;
+        private long currentBits = bits;
 
-        private boolean canProcess = true;
+        /**
+         * The single bit of the next value to return.
+         */
+        private long mask = currentBits & -currentBits; // the lowest 1 bit in currentBits
 
-        private MiniEnumSetIterator() {
-            unProcessedBits = bits;
-            if (0 == unProcessedBits) {
-                canProcess = false;
-            }
-        }
+        /**
+         * The candidate for removal. If null, no value may be removed.
+         */
+        private E last;
 
         public boolean hasNext() {
-            return canProcess;
+            return mask != 0;
         }
 
         public E next() {
-            if (!canProcess) {
+            if (mask == 0) {
                 throw new NoSuchElementException();
             }
-            currentElementMask = unProcessedBits & (-unProcessedBits);
-            unProcessedBits -= currentElementMask;
-            if (0 == unProcessedBits) {
-                canProcess = false;
-            }
-            return enums[Long.numberOfTrailingZeros(currentElementMask)];
+
+            int ordinal = Long.numberOfTrailingZeros(mask);
+            last = enums[ordinal];
+
+            currentBits &= ~mask;
+            mask = currentBits & -currentBits; // the lowest 1 bit in currentBits
+
+            return last;
         }
 
         public void remove() {
-            if ( currentElementMask == 0 ) {
+            if (last == null) {
                 throw new IllegalStateException();
             }
-            bits &= ~currentElementMask;
-            size = Long.bitCount(bits);
-            currentElementMask = 0;
+
+            MiniEnumSet.this.remove(last);
+            last = null;
         }
     }
 
@@ -102,77 +102,83 @@
         if (!isValidType(element.getDeclaringClass())) {
             throw new ClassCastException();
         }
-        long mask = 1l << element.ordinal();
-        if ((bits & mask) == mask) {
-            return false;
-        }
-        bits |= mask;
 
-        size++;
-        return true;
+        long oldBits = bits;
+        long newBits = oldBits | (1L << element.ordinal());
+        if (oldBits != newBits) {
+            bits = newBits;
+            size++;
+            return true;
+        }
+        return false;
     }
     
     @Override
     public boolean addAll(Collection<? extends E> collection) {
-        if (0 == collection.size()) {
+        if (collection.isEmpty()) {
             return false;
         }
         if (collection instanceof EnumSet) {
-            EnumSet<?> set = (EnumSet)collection;
+            EnumSet<?> set = (EnumSet<?>) collection;
             if (!isValidType(set.elementClass)) {
                 throw new ClassCastException();
             }
+
             MiniEnumSet<?> miniSet = (MiniEnumSet<?>) set;
             long oldBits = bits;
-            bits |= miniSet.bits;
-            size = Long.bitCount(bits);
-            return (oldBits != bits);
+            long newBits = oldBits | miniSet.bits;
+            bits = newBits;
+            size = Long.bitCount(newBits);
+            return (oldBits != newBits);
         }
         return super.addAll(collection);
     }
     
     @Override
     public boolean contains(Object object) {
-        if (null == object) {
-            return false;
-        }
-        if (!isValidType(object.getClass())) {
+        if (object == null || !isValidType(object.getClass())) {
             return false;
         }
-        Enum<?> element = (Enum<?>) object;
+
+        @SuppressWarnings("unchecked") // guarded by isValidType()
+        Enum<E> element = (Enum<E>) object;
         int ordinal = element.ordinal();
-        return (bits & (1l << ordinal)) != 0;
+        return (bits & (1L << ordinal)) != 0;
     }
     
     @Override
     public boolean containsAll(Collection<?> collection) {
-        if (collection.size() == 0) {
+        if (collection.isEmpty()) {
             return true;
         }
         if (collection instanceof MiniEnumSet) {
             MiniEnumSet<?> set = (MiniEnumSet<?>) collection;
-            return isValidType(set.elementClass ) && ((bits & set.bits) == set.bits);
+            long setBits = set.bits;
+            return isValidType(set.elementClass) && ((bits & setBits) == setBits);
         }
         return !(collection instanceof EnumSet) && super.containsAll(collection);  
     }
     
     @Override
     public boolean removeAll(Collection<?> collection) {
-        if (0 == collection.size()) {
+        if (collection.isEmpty()) {
             return false;
         }
         if (collection instanceof EnumSet) {
-            EnumSet<E> set = (EnumSet<E>) collection;
-            boolean removeSuccessful = false;
-            if (isValidType(set.elementClass)) {
-                long mask = bits & ((MiniEnumSet<E>) set).bits;
-                if (mask != 0) {
-                    bits -= mask;
-                    size = Long.bitCount(bits);
-                    removeSuccessful = true;
-                }
+            EnumSet<?> set = (EnumSet<?>) collection;
+            if (!isValidType(set.elementClass)) {
+                return false;
+            }
+
+            MiniEnumSet<E> miniSet = (MiniEnumSet<E>) set;
+            long oldBits = bits;
+            long newBits = oldBits & ~miniSet.bits;
+            if (oldBits != newBits) {
+                bits = newBits;
+                size = Long.bitCount(newBits);
+                return true;
             }
-            return removeSuccessful;
+            return false;
         }
         return super.removeAll(collection);
     }
@@ -180,33 +186,46 @@
     @Override
     public boolean retainAll(Collection<?> collection) {
         if (collection instanceof EnumSet) {
-            EnumSet<E> set = (EnumSet<E>) collection;
+            EnumSet<?> set = (EnumSet<?>) collection;
             if (!isValidType(set.elementClass)) {
-                clear();
-                return true;
+                if (size > 0) {
+                    clear();
+                    return true;
+                } else {
+                    return false;
+                }
             }
-            boolean retainSuccessful = false;
+
+            MiniEnumSet<E> miniSet = (MiniEnumSet<E>) set;
             long oldBits = bits;
-            bits &= ((MiniEnumSet<E>)set).bits;
-            if (oldBits != bits) {
-                size = Long.bitCount(bits);
-                retainSuccessful = true;
+            long newBits = oldBits & miniSet.bits;
+            if (oldBits != newBits) {
+                bits = newBits;
+                size = Long.bitCount(newBits);
+                return true;
             }
-            return retainSuccessful;
+            return false;
         }
         return super.retainAll(collection);
     }
     
     @Override
     public boolean remove(Object object) {
-        if (!contains(object)) {
+        if (object == null || !isValidType(object.getClass())) {
             return false;
         }
-        Enum<?> element = (Enum<?>) object;
+
+        @SuppressWarnings("unchecked") // guarded by isValidType() 
+        Enum<E> element = (Enum<E>) object;
         int ordinal = element.ordinal();
-        bits -= (1l << ordinal);
-        size--;
-        return true;
+        long oldBits = bits;
+        long newBits = oldBits & ~(1L << ordinal);
+        if (oldBits != newBits) {
+            bits = newBits;
+            size--;
+            return true;
+        }
+        return false;
     }
     
     @Override
@@ -214,18 +233,18 @@
         if (!(object instanceof EnumSet)) {
             return super.equals(object);
         }
-        EnumSet<?> set =(EnumSet<?>)object; 
-        if( !isValidType(set.elementClass) ) {
-            return size == 0 && set.size() == 0;
+        EnumSet<?> set =(EnumSet<?>) object;
+        if (!isValidType(set.elementClass)) {
+            return size == 0 && set.isEmpty();
         }
-        return bits == ((MiniEnumSet<?>)set).bits;
+        return bits == ((MiniEnumSet<?>) set).bits;
     }
     
     @Override
     void complement() {
-        if (0 != enums.length) {
+        if (enums.length != 0) {
             bits = ~bits;
-            bits &= (-1l >>> (MAX_ELEMENTS - enums.length));
+            bits &= (-1L >>> (MAX_ELEMENTS - enums.length));
             size = enums.length - size;
         }
     }
@@ -233,7 +252,7 @@
     @Override
     void setRange(E start, E end) {
         int length = end.ordinal() - start.ordinal() + 1;
-        long range = (-1l >>> (MAX_ELEMENTS - length)) << start.ordinal();
+        long range = (-1L >>> (MAX_ELEMENTS - length)) << start.ordinal();
         bits |= range;
         size = Long.bitCount(bits);
     }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Properties.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Properties.java?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Properties.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Properties.java Tue Jan 26 12:40:37 2010
@@ -17,10 +17,10 @@
 
 package java.util;
 
-import java.io.IOException;
-import java.io.InputStream;
 import java.io.BufferedReader;
 import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
@@ -38,19 +38,17 @@
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
+import org.apache.harmony.luni.internal.nls.Messages;
+import org.apache.harmony.luni.util.PriviAction;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
 import org.xml.sax.EntityResolver;
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-import org.apache.harmony.luni.internal.nls.Messages;
-import org.apache.harmony.luni.util.PriviAction;
-
 /**
  * A {@code Properties} object is a {@code Hashtable} where the keys and values
  * must be {@code String}s. Each property can have a default
@@ -494,9 +492,10 @@
      *         that this {@code Properties} object contains.
      */
     public Enumeration<?> propertyNames() {
-        Hashtable<Object, Object> allProperties = getAllProperties();
-        return allProperties.keys();
-	}
+        Hashtable<Object, Object> selected = new Hashtable<Object, Object>();
+        selectProperties(selected);
+        return selected.keys();
+    }
     
     /**
      * Answers a set of keys in this property list whoes key and value are
@@ -507,14 +506,15 @@
      * @since 1.6
      */    
     public Set<String> stringPropertyNames(){
-        Hashtable<Object, Object> allProperties = getAllProperties();       
-        Enumeration<?> keys = allProperties.keys();
+        Hashtable<Object, Object> selected = new Hashtable<Object, Object>();
+        selectProperties(selected);
+        Enumeration<?> keys = selected.keys();
         HashSet<String> set = new HashSet<String>();
         Object key, value;
         while (keys.hasMoreElements()) {
             key = keys.nextElement();
             if (key instanceof String) {
-                value = allProperties.get(key);
+                value = selected.get(key);
                 if (value instanceof String){
                     set.add((String)key);    
                 }
@@ -523,20 +523,11 @@
         return Collections.unmodifiableSet(set);
     }
 
-    /*
-     * Add all of properties into the given allProperties hashtable including
-     * default properties
-     */
-    private Hashtable<Object, Object> getAllProperties() {
-        Hashtable<Object, Object> allProperties = new Hashtable<Object, Object>();
-        Properties properties = this;
-        Properties defaultProperties = null;
-        while (properties != null) {
-            defaultProperties = properties.defaults;
-            allProperties.putAll(properties);
-            properties = defaultProperties;
+    private void selectProperties(Hashtable<Object, Object> selected) {
+        if(defaults != null) {
+            defaults.selectProperties(selected);
         }
-        return allProperties;
+        selected.putAll(this);
     }
 
     /**

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/TreeSet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/TreeSet.java?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/TreeSet.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/TreeSet.java Tue Jan 26 12:40:37 2010
@@ -35,11 +35,12 @@
 
     private static final long serialVersionUID = -2479143000061671589L;
 
-    transient NavigableMap<E, E> backingMap;
+    /** Keys are this set's elements. Values are always Boolean.TRUE */
+    transient NavigableMap<E, Object> backingMap;
 
     transient NavigableSet<E> descendingSet;
 
-    TreeSet(NavigableMap<E, E> map) {
+    TreeSet(NavigableMap<E, Object> map) {
         backingMap = map;
     }
 
@@ -48,7 +49,7 @@
      * ordering.
      */
     public TreeSet() {
-        backingMap = new TreeMap<E, E>();
+        backingMap = new TreeMap<E, Object>();
     }
 
     /**
@@ -75,7 +76,7 @@
      *            the comparator to use.
      */
     public TreeSet(Comparator<? super E> comparator) {
-        backingMap = new TreeMap<E, E>(comparator);
+        backingMap = new TreeMap<E, Object>(comparator);
     }
 
     /**
@@ -109,7 +110,7 @@
      */
     @Override
     public boolean add(E object) {
-        return backingMap.put(object, object) == null;
+        return backingMap.put(object, Boolean.TRUE) == null;
     }
 
     /**
@@ -155,10 +156,10 @@
         try {
             TreeSet<E> clone = (TreeSet<E>) super.clone();
             if (backingMap instanceof TreeMap) {
-                clone.backingMap = (NavigableMap<E, E>) ((TreeMap<E, E>) backingMap)
+                clone.backingMap = (NavigableMap<E, Object>) ((TreeMap<E, Object>) backingMap)
                         .clone();
             } else {
-                clone.backingMap = new TreeMap<E, E>(backingMap);
+                clone.backingMap = new TreeMap<E, Object>(backingMap);
             }
             return clone;
         } catch (CloneNotSupportedException e) {
@@ -286,7 +287,7 @@
      * @since 1.6
      */
     public E pollFirst() {
-        Map.Entry<E, E> entry = backingMap.pollFirstEntry();
+        Map.Entry<E, Object> entry = backingMap.pollFirstEntry();
         return (null == entry) ? null : entry.getKey();
     }
 
@@ -297,7 +298,7 @@
      * @since 1.6
      */
     public E pollLast() {
-        Map.Entry<E, E> entry = backingMap.pollLastEntry();
+        Map.Entry<E, Object> entry = backingMap.pollLastEntry();
         return (null == entry) ? null : entry.getKey();
     }
 
@@ -493,14 +494,14 @@
     private void readObject(ObjectInputStream stream) throws IOException,
             ClassNotFoundException {
         stream.defaultReadObject();
-        TreeMap<E, E> map = new TreeMap<E, E>((Comparator<? super E>) stream
-                .readObject());
+        TreeMap<E, Object> map = new TreeMap<E, Object>(
+                (Comparator<? super E>) stream.readObject());
         int size = stream.readInt();
         if (size > 0) {
-            TreeMap.Node<E,E> lastNode = null;
+            TreeMap.Node<E, Object> lastNode = null;
             for(int i=0; i<size; i++) {
                 E elem = (E)stream.readObject();
-                lastNode = map.addToLast(lastNode,elem,elem);
+                lastNode = map.addToLast(lastNode,elem, Boolean.TRUE);
             }
         }
         backingMap = map;

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/io/FileCanonPathCache.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/io/FileCanonPathCache.java?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/io/FileCanonPathCache.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/io/FileCanonPathCache.java Tue Jan 26 12:40:37 2010
@@ -85,7 +85,7 @@
                     String oldest = null;
                     do {
                         oldest = list.removeFirst();
-                        cache.remove(path);
+                        cache.remove(oldest);
                     } while (!path.equals(oldest));
                 }
             }

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/fdlibm.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 26 12:40:37 2010
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/fdlibm.h:803062-885602
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/fdlibm.h:803062-901560

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/gp.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 26 12:40:37 2010
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/gp.h:803062-885602
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/gp.h:803062-901560

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/hymagic.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 26 12:40:37 2010
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/hymagic.h:803062-885602
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/hymagic.h:803062-901560

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/hysocket.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 26 12:40:37 2010
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/hysocket.h:803062-885602
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/hysocket.h:803062-901560

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/hyvmls.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 26 12:40:37 2010
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/hyvmls.h:803062-885602
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/hyvmls.h:803062-901560

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/jni.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 26 12:40:37 2010
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jni.h:803062-885602
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jni.h:803062-901560

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/jni_types.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 26 12:40:37 2010
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jni_types.h:803062-885602
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jni_types.h:803062-901560

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/jvmpi.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 26 12:40:37 2010
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jvmpi.h:803062-885602
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jvmpi.h:803062-901560

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/jvmri.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 26 12:40:37 2010
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jvmri.h:803062-885602
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jvmri.h:803062-901560

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/jvmti.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 26 12:40:37 2010
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jvmti.h:803062-885602
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jvmti.h:803062-901560

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/jvmti_types.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 26 12:40:37 2010
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jvmti_types.h:803062-885602
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jvmti_types.h:803062-901560

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/vmi.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 26 12:40:37 2010
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/vmi.h:803062-885602
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/vmi.h:803062-901560

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/vmizip.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 26 12:40:37 2010
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/vmizip.h:803062-885602
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/vmizip.h:803062-901560

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/netif.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/netif.c?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/netif.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/netif.c Tue Jan 26 12:40:37 2010
@@ -34,7 +34,7 @@
                                                          jclass clazz)
 {
   /* variables to store network interface data returned by call to port library */
-  struct hyNetworkInterfaceArray_struct networkInterfaceArray;
+  hyNetworkInterfaceArray_struct networkInterfaceArray;
   I_32 result = 0;
 
   /* variables for class and method objects needed to create bridge to java */

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/OSFileSystemLinux32.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/OSFileSystemLinux32.c?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/OSFileSystemLinux32.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/OSFileSystemLinux32.c Tue Jan 26 12:40:37 2010
@@ -32,6 +32,7 @@
 #include "vmi.h"
 #include "iohelp.h"
 #include "nethelp.h"
+#include "hysock.h"
 
 #include "IFileSystem.h"
 #include "OSFileSystem.h"
@@ -42,14 +43,6 @@
 #define FD_BIAS 0
 #endif /* ZOS */
 
-typedef int OSSOCKET;
-typedef struct hysocket_struct
-{
-  OSSOCKET sock;
-  U_16 family;
-} hysocket_struct;
-
-
 /**
  * Lock the file identified by the given handle.
  * The range and lock type are given.

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSFileSystemWin32.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSFileSystemWin32.c?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSFileSystemWin32.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSFileSystemWin32.c Tue Jan 26 12:40:37 2010
@@ -18,9 +18,9 @@
  * Win32 specific natives supporting the file system interface.
  */
 
-#if defined(_WINSOCKAPI_) && !defined(_WINSOCK2API_)
-#undef _WINSOCKAPI_
-#endif
+#include "vmi.h"
+#include "hysock.h"
+#include <mswsock.h>
 
 #include <windows.h>
 #include "nethelp.h"
@@ -28,14 +28,6 @@
 #include "IFileSystem.h"
 #include "OSFileSystem.h"
 
-typedef SOCKET OSSOCKET;
-typedef struct hysocket_struct
-{
-  OSSOCKET ipv4;
-  OSSOCKET ipv6;
-  U_8 flags;
-} hysocket_struct;
-
 /**
  * Lock the file identified by the given handle.
  * The range and lock type are given.

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c Tue Jan 26 12:40:37 2010
@@ -64,8 +64,8 @@
   U_32 time_sec = (U_32)timeout/1000;
   U_32 time_msec = (U_32)(timeout%1000)*1000;
 
-  fdset_read = hymem_allocate_memory(sizeof (struct hyfdset_struct));
-  fdset_write =	hymem_allocate_memory(sizeof (struct hyfdset_struct));
+  fdset_read = hymem_allocate_memory(sizeof (hyfdset_struct));
+  fdset_write = hymem_allocate_memory(sizeof (hyfdset_struct));
 
   FD_ZERO (&fdset_read->handle);
   FD_ZERO (&fdset_write->handle);
@@ -180,7 +180,7 @@
   hyfdset_t fdset_read;
   I_32 result = 0;
 
-  fdset_read = hymem_allocate_memory(sizeof (struct hyfdset_struct));
+  fdset_read = hymem_allocate_memory(sizeof (hyfdset_struct));
   FD_ZERO (&fdset_read->handle);
 
   if (hysocketP->flags & SOCKET_IPV4_OPEN_MASK) {

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest.java?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest.java Tue Jan 26 12:40:37 2010
@@ -58,6 +58,8 @@
 import java.util.TreeSet;
 import java.util.Vector;
 
+import org.apache.harmony.luni.util.InputStreamHelper;
+
 /**
  * Automated Test Suite for class java.io.ObjectOutputStream
  * 
@@ -658,33 +660,25 @@
 		assertTrue("resolved class 3", resolvedClasses[2] == Number.class);
 	}
 
-	public void test_reset() {
-		try {
-			oos.reset();
-			oos.writeObject("R");
-			oos.reset();
-			oos.writeByte(24);
-			oos.close();
-
-			DataInputStream dis = new DataInputStream(loadStream());
-			byte[] input = new byte[dis.available()];
-			dis.readFully(input);
-			byte[] result = new byte[] { (byte) 0xac, (byte) 0xed, (byte) 0,
-					(byte) 5, (byte) 0x79, (byte) 0x74, (byte) 0, (byte) 1,
-					(byte) 'R', (byte) 0x79, (byte) 0x77, (byte) 1, (byte) 24 };
-			assertTrue("incorrect output", Arrays.equals(input, result));
-
-			ois = new ObjectInputStreamSubclass(loadStream());
-			assertEquals("Wrong result from readObject()", "R", ois.readObject()
-					);
-			assertEquals("Wrong result from readByte()", 24, ois.readByte());
-			ois.close();
-		} catch (IOException e1) {
-			fail("IOException : " + e1.getMessage());
-		} catch (ClassNotFoundException e2) {
-			fail("ClassNotFoundException : " + e2.getMessage());
-		}
-	}
+    public void test_reset() throws IOException, ClassNotFoundException {
+        oos.reset();
+        oos.writeObject("R");
+        oos.reset();
+        oos.writeByte(24);
+        oos.close();
+
+        DataInputStream dis = new DataInputStream(loadStream());
+        byte[] input = InputStreamHelper.readFullyAndClose(dis);
+        byte[] result = new byte[] { (byte) 0xac, (byte) 0xed, (byte) 0,
+                (byte) 5, (byte) 0x79, (byte) 0x74, (byte) 0, (byte) 1,
+                (byte) 'R', (byte) 0x79, (byte) 0x77, (byte) 1, (byte) 24 };
+        assertTrue("incorrect output", Arrays.equals(input, result));
+
+        ois = new ObjectInputStreamSubclass(loadStream());
+        assertEquals("Wrong result from readObject()", "R", ois.readObject());
+        assertEquals("Wrong result from readByte()", 24, ois.readByte());
+        ois.close();
+    }
 
 	public void test_serialVersionUID(Class clazz, long svUID) throws Exception {
 		final String idWrong = "serialVersionUID is wrong for: ";

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ClassNotFoundExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ClassNotFoundExceptionTest.java?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ClassNotFoundExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ClassNotFoundExceptionTest.java Tue Jan 26 12:40:37 2010
@@ -17,9 +17,15 @@
 
 package org.apache.harmony.luni.tests.java.lang;
 
+import java.io.IOException;
+
 import junit.framework.TestCase;
 
 public class ClassNotFoundExceptionTest extends TestCase {
+    /**
+     * Thrown when an application tries to load in a class through its string
+     * name using the forName method in class Class.
+     */
 
 	/**
 	 * @tests java.lang.ClassNotFoundException#ClassNotFoundException()
@@ -39,4 +45,16 @@
         assertEquals("fixture", e.getMessage());
         assertNull(e.getCause());
 	}
+	
+    /**
+     * @tests java.lang.ClassNotFoundException#ClassNotFoundException(java.lang.String, java.lang.Throwable)
+     */
+    public void test_ClassNotFoundException_LString_LThrowable() {
+        IOException in = new IOException();
+        ClassNotFoundException e = new ClassNotFoundException("SomeMessage", in);
+        assertEquals("Wrong Exception", in, e.getException());
+        assertEquals("Wrong message", "SomeMessage", e.getMessage());
+        assertEquals("Wrong cause", in, e.getCause());
+    }
+
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/StringTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/StringTest.java?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/StringTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/StringTest.java Tue Jan 26 12:40:37 2010
@@ -295,7 +295,7 @@
     /**
      * @tests java.lang.String.offsetByCodePoints(int, int)'
      */
-    public void test_offsetByCodePointsII() throws Exception {
+    public void test_offsetByCodePoints_II() throws Exception {
         int result = new String("a\uD800\uDC00b").offsetByCodePoints(0, 2);
         assertEquals(3, result);
 

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/InvocationTargetExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/InvocationTargetExceptionTest.java?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/InvocationTargetExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/InvocationTargetExceptionTest.java Tue Jan 26 12:40:37 2010
@@ -17,6 +17,9 @@
 
 package org.apache.harmony.luni.tests.java.lang.reflect;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
 import java.io.ByteArrayOutputStream;
 import java.io.CharArrayWriter;
 import java.io.PrintStream;
@@ -24,6 +27,8 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
+import org.junit.Test;
+
 public class InvocationTargetExceptionTest extends junit.framework.TestCase {
 
 	static class TestMethod {
@@ -240,6 +245,36 @@
                                 && s.length() > 400);
 	}
 
+    /**
+     * Test method for
+     * {@link java.lang.reflect.InvocationTargetException#InvocationTargetException(java.lang.Throwable, java.lang.String)}
+     *
+     */
+    @Test
+    public void testInvocationTargetExceptionThrowableString() {
+        Exception cause = null;
+        InvocationTargetException e = new InvocationTargetException(cause,
+                "SomeMessage");
+        assertNull(e.getCause());
+        assertEquals("Wrong Message", "SomeMessage", e.getMessage());
+    }
+
+    class MyInvocationTargetException extends InvocationTargetException {
+        private static final long serialVersionUID = 1L;
+    }
+
+    /**
+     * Test method for
+     * {@link java.lang.reflect.InvocationTargetException#InvocationTargetException()}
+     *
+     */
+    @Test
+    public void testInvocationTargetException() {
+        InvocationTargetException e = new MyInvocationTargetException();
+        assertNull(e.getCause());
+    }
+
+
 	/**
 	 * Sets up the fixture, for example, open a network connection. This method
 	 * is called before a test is executed.

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ModifierTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ModifierTest.java?rev=903199&r1=903198&r2=903199&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ModifierTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ModifierTest.java Tue Jan 26 12:40:37 2010
@@ -28,7 +28,7 @@
 	 */
 	public void test_Constructor() {
 		// Test for method java.lang.reflect.Modifier()
-		// Does nothing
+		new Modifier();
 	}
 
 	/**
@@ -182,6 +182,12 @@
 						java.lang.reflect.Modifier.PUBLIC
 								+ java.lang.reflect.Modifier.ABSTRACT).equals(
 						"public abstract"));
+
+        int i = 0xFFF;
+        String modification = "public protected private abstract static final transient "
+                + "volatile synchronized native strictfp interface";
+        assertTrue("Returned incorrect string value", Modifier.toString(i)
+                .equals(modification));
 	}
 
     public void test_Constants_Value() {



Mime
View raw message