You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by to...@apache.org on 2009/12/10 04:22:42 UTC

svn commit: r889068 [1/2] - in /harmony/enhanced/classlib/branches/java6: ./ make/ modules/archive/src/main/java/java/util/jar/ modules/archive/src/main/java/java/util/zip/ modules/concurrent/src/main/java/java/util/concurrent/atomic/ modules/concurren...

Author: tonywu
Date: Thu Dec 10 03:22:37 2009
New Revision: 889068

URL: http://svn.apache.org/viewvc?rev=889068&view=rev
Log:
Merge updates from classlib trunk@889062 since r885602


Added:
    harmony/enhanced/classlib/branches/java6/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/HelloWorldTest.java
      - copied unchanged from r889062, harmony/enhanced/classlib/trunk/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/HelloWorldTest.java
    harmony/enhanced/classlib/branches/java6/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/InstrumentTestHelper.java
      - copied unchanged from r889062, harmony/enhanced/classlib/trunk/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/InstrumentTestHelper.java
    harmony/enhanced/classlib/branches/java6/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/agents/
      - copied from r889062, harmony/enhanced/classlib/trunk/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/agents/
    harmony/enhanced/classlib/branches/java6/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/agents/HelloWorldAgent.java
      - copied unchanged from r889062, harmony/enhanced/classlib/trunk/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/agents/HelloWorldAgent.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/InputStreamHelper.java
      - copied unchanged from r889062, harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/InputStreamHelper.java
Removed:
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/ExposedByteArrayInputStream.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/InputStreamExposer.java
Modified:
    harmony/enhanced/classlib/branches/java6/   (props changed)
    harmony/enhanced/classlib/branches/java6/make/build-test.xml
    harmony/enhanced/classlib/branches/java6/make/depends-common.xml   (props changed)
    harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/jar/JarFile.java
    harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/jar/Manifest.java
    harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipFile.java
    harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/   (props changed)
    harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/locks/   (props changed)
    harmony/enhanced/classlib/branches/java6/modules/instrument/src/main/native/instrument/shared/inst_agt.c
    harmony/enhanced/classlib/branches/java6/modules/jmx/META-INF/   (props changed)
    harmony/enhanced/classlib/branches/java6/modules/lang-management/src/test/api/java/org/apache/harmony/lang/management/tests/java/util/logging/   (props changed)
    harmony/enhanced/classlib/branches/java6/modules/luni/META-INF/MANIFEST.MF
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/AbstractMap.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/AbstractSet.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Collections.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/EnumSet.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/HugeEnumSet.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/MiniEnumSet.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/TreeMap.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/TreeSet.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/fdlibm.h   (props changed)
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/gp.h   (props changed)
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/hymagic.h   (props changed)
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/hysocket.h   (props changed)
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/hyvmls.h   (props changed)
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/jni.h   (props changed)
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/jni_types.h   (props changed)
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/jvmpi.h   (props changed)
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/jvmri.h   (props changed)
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/jvmti.h   (props changed)
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/jvmti_types.h   (props changed)
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/vmi.h   (props changed)
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/vmizip.h   (props changed)
    harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/AbstractMapTest.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/EnumSetTest.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/unix/org/apache/harmony/luni/tests/java/io/UnixFileTest.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/test/resources/net.resources/   (props changed)
    harmony/enhanced/classlib/branches/java6/modules/pack200/depends/manifests/asm-3.1/   (props changed)
    harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200Adapter.java   (props changed)
    harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200PackerAdapter.java   (props changed)
    harmony/enhanced/classlib/branches/java6/modules/rmi/META-INF/MANIFEST.MF
    harmony/enhanced/classlib/branches/java6/modules/rmi/src/main/java/java/rmi/server/RMIClassLoader.java
    harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/utils/JarUtils.java
    harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureClassLoader2Test.java
    harmony/enhanced/classlib/branches/java6/modules/sound/src/main/java/org/apache/harmony/sound/utils/ProviderService.java
    harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLExceptionTest.java
    harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLWarningTest.java
    harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/transaction/TransactionRequiredExceptionTest.java
    harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/transaction/TransactionRolledbackExceptionTest.java
    harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/BasicSwingTestCase.java   (props changed)
    harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/SwingTestCase.java   (props changed)
    harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/text/parser/   (props changed)

Propchange: harmony/enhanced/classlib/branches/java6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 03:22:37 2009
@@ -1,2 +1,2 @@
-/harmony/enhanced/classlib/trunk:713674-735919,765923-885602
+/harmony/enhanced/classlib/trunk:713674-735919,765923-889062
 /harmony/enhanced/classlib/trunk/working_classlib:884014-884286

Modified: harmony/enhanced/classlib/branches/java6/make/build-test.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/make/build-test.xml?rev=889068&r1=889067&r2=889068&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/make/build-test.xml (original)
+++ harmony/enhanced/classlib/branches/java6/make/build-test.xml Thu Dec 10 03:22:37 2009
@@ -27,6 +27,20 @@
     <property name="tests.output" location="build/test_report" />
     <import file="${basedir}/make/properties.xml" />
 
+    <property name="gen.report" value="true" />
+    <condition property="do.full.report" value="true">
+        <and>
+            <equals arg1="${gen.report}" arg2="true" />
+            <not><equals arg1="${short.report}" arg2="true" /></not>
+        </and>
+    </condition>
+    <condition property="do.short.report" value="true">
+        <and>
+            <equals arg1="${gen.report}" arg2="true" />
+            <equals arg1="${short.report}" arg2="true" />
+        </and>
+    </condition>
+
     <property name="tests.support.output" location="build/test_support" />
     <property name="support.dir" location="support"/>
     <property name="tests.depends.jars" location="deploy/jdk/jre/lib/boot" />
@@ -71,7 +85,7 @@
 
     <property name="report.dir" value="${tests.output}/html"/>
 
-    <target name="full-report" unless="short.report" >
+    <target name="full-report" if="do.full.report" >
         <delete dir="${report.dir}" />
         <junitreport todir="${tests.output}">
             <fileset dir="${tests.output}">
@@ -85,7 +99,7 @@
         <echo message="The test report is in ${display-location}"/>
     </target>
 
-    <target name="short-report" if="short.report" >
+    <target name="short-report" if="do.short.report">
         <delete dir="${report.dir}" />
         <junitreport todir="${tests.output}">
             <fileset dir="${tests.output}" includes="TEST*-*.xml">

Propchange: harmony/enhanced/classlib/branches/java6/make/depends-common.xml
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 03:22:37 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/make/depends-common.xml:768152-885602
+/harmony/enhanced/classlib/trunk/make/depends-common.xml:768152-889062

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/jar/JarFile.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/jar/JarFile.java?rev=889068&r1=889067&r2=889068&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/jar/JarFile.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/jar/JarFile.java Thu Dec 10 03:22:37 2009
@@ -17,19 +17,19 @@
 
 package java.util.jar;
 
-import java.io.ByteArrayOutputStream;
-import java.util.List;
-import java.util.ArrayList;
 import java.io.File;
 import java.io.FilterInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.ArrayList;
 import java.util.Enumeration;
+import java.util.List;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
 import org.apache.harmony.archive.internal.nls.Messages;
 import org.apache.harmony.archive.util.Util;
+import org.apache.harmony.luni.util.InputStreamHelper;
 
 /**
  * {@code JarFile} is used to read jar entries and their associated data from
@@ -282,42 +282,6 @@
         return (JarEntry) getEntry(name);
     }
 
-    /*
-     * Drains the entire content from the given input stream and returns it as a
-     * byte[]. The stream is closed after being drained, or if an IOException
-     * occurs.
-     */
-    private byte[] getAllBytesFromStreamAndClose(InputStream is)
-            throws IOException {
-        try {
-            // Initial read
-            byte[] buffer = new byte[1024];
-            int count = is.read(buffer);
-            int nextByte = is.read();
-
-            // Did we get it all in one read?
-            if (nextByte == -1) {
-                byte[] dest = new byte[count];
-                System.arraycopy(buffer, 0, dest, 0, count);
-                return dest;
-            }
-
-            // Requires additional reads
-            ByteArrayOutputStream baos = new ByteArrayOutputStream(count * 2);
-            baos.write(buffer, 0, count);
-            baos.write(nextByte);
-            while (true) {
-                count = is.read(buffer);
-                if (count == -1) {
-                    return baos.toByteArray();
-                }
-                baos.write(buffer, 0, count);
-            }
-        } finally {
-            is.close();
-        }
-    }
-
     /**
      * Returns the {@code Manifest} object associated with this {@code JarFile}
      * or {@code null} if no MANIFEST entry exists.
@@ -340,7 +304,8 @@
         try {
             InputStream is = super.getInputStream(manifestEntry);
             if (verifier != null) {
-                verifier.addMetaEntry(manifestEntry.getName(), getAllBytesFromStreamAndClose(is));
+                verifier.addMetaEntry(manifestEntry.getName(),
+                        InputStreamHelper.readFullyAndClose(is));
                 is = super.getInputStream(manifestEntry);
             }
             try {
@@ -392,7 +357,7 @@
                                 || Util.asciiEndsWithIgnoreCase(entryName, ".RSA"))) {
                     signed = true;
                     InputStream is = super.getInputStream(entry);
-                    byte[] buf = getAllBytesFromStreamAndClose(is);
+                    byte[] buf = InputStreamHelper.readFullyAndClose(is);
                     verifier.addMetaEntry(entryName, buf);
                 }
             }

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/jar/Manifest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/jar/Manifest.java?rev=889068&r1=889067&r2=889068&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/jar/Manifest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/jar/Manifest.java Thu Dec 10 03:22:37 2009
@@ -30,7 +30,7 @@
 import java.util.Map;
 
 import org.apache.harmony.archive.internal.nls.Messages;
-import org.apache.harmony.luni.util.InputStreamExposer;
+import org.apache.harmony.luni.util.InputStreamHelper;
 import org.apache.harmony.luni.util.ThreadLocalCache;
 
 /**
@@ -209,7 +209,7 @@
         byte[] buf;
         // Try to read get a reference to the bytes directly
         try {
-            buf = InputStreamExposer.expose(is);
+            buf = InputStreamHelper.expose(is);
         } catch (UnsupportedOperationException uoe) {
             buf = readFully(is);
         }

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipFile.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipFile.java?rev=889068&r1=889067&r2=889068&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipFile.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipFile.java Thu Dec 10 03:22:37 2009
@@ -368,7 +368,6 @@
         RandomAccessFile mSharedRaf;
         long mOffset;
         long mLength;
-        private byte[] singleByteBuf = new byte[1];
 
         public RAFStream(RandomAccessFile raf, long pos) throws IOException {
             mSharedRaf = raf;
@@ -383,6 +382,7 @@
 
         @Override
         public int read() throws IOException {
+            byte[] singleByteBuf = new byte[1];
             if (read(singleByteBuf, 0, 1) == 1) {
                 return singleByteBuf[0] & 0XFF;
             } else {

Propchange: harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/atomic/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 03:22:37 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/concurrent/src/main/java/java/util/concurrent/atomic:765923-885602
+/harmony/enhanced/classlib/trunk/modules/concurrent/src/main/java/java/util/concurrent/atomic:765923-889062

Propchange: harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java/java/util/concurrent/locks/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 03:22:37 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/concurrent/src/main/java/java/util/concurrent/locks:765923-885602
+/harmony/enhanced/classlib/trunk/modules/concurrent/src/main/java/java/util/concurrent/locks:765923-889062

Modified: harmony/enhanced/classlib/branches/java6/modules/instrument/src/main/native/instrument/shared/inst_agt.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/instrument/src/main/native/instrument/shared/inst_agt.c?rev=889068&r1=889067&r2=889068&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/instrument/src/main/native/instrument/shared/inst_agt.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/instrument/src/main/native/instrument/shared/inst_agt.c Thu Dec 10 03:22:37 2009
@@ -206,7 +206,7 @@
 
     /* read bytes */
     size = zipEntry.uncompressedSize;
-    result = (char *)hymem_allocate_memory(size*sizeof(char));
+    result = (char *)hymem_allocate_memory(size*sizeof(char) + 1);
 #ifndef HY_ZIP_API
     retval = zip_getZipEntryData(privatePortLibrary, &zipFile, &zipEntry, (unsigned char*)result, size);
 #else /* HY_ZIP_API */
@@ -223,6 +223,7 @@
         return NULL;
     }
 
+    result[size] = '\0';
     /* free resource */
 #ifndef HY_ZIP_API
     zip_freeZipEntry(privatePortLibrary, &zipEntry);
@@ -243,6 +244,7 @@
     char *pos;
     char *end;
     char *value;
+    char *tmp;
     int length;
     PORT_ACCESS_FROM_JAVAVM(vm);
 
@@ -253,18 +255,46 @@
     pos = manifest+ (strstr(lwrmanifest,target) - lwrmanifest);
     pos += strlen(target)+2;//": "
     end = strchr(pos, '\n');
+
+    while (end != NULL && *(end + 1) == ' ') {
+        end = strchr(end + 1, '\n');
+    }
+
     if(NULL == end){
         end = manifest + strlen(manifest);
     }
-    /* in windows, has '\r\n' in the end of line, omit '\r' */
-    if (*(end - 1) == '\r'){
-        end--;
-    }
+
     length = end - pos;
 
     value = (char *)hymem_allocate_memory(sizeof(char)*(length+1));
-    strncpy(value, pos, length);
-    *(value+length) = '\0';
+    tmp = value;
+
+    end = strchr(pos, '\n');
+    while (end != NULL && *(end + 1) == ' ') {
+        /* in windows, has '\r\n' in the end of line, omit '\r' */
+        if (*(end - 1) == '\r') {
+            strncpy(tmp, pos, end - 1 - pos);
+            tmp += end - 1 - pos;
+            pos = end + 2;
+        } else {
+            strncpy(tmp, pos, end - pos);
+            tmp += end - pos;
+            pos = end + 2;
+        }
+        end = strchr(end + 1, '\n');
+    }
+
+    if (NULL == end) {
+        strcpy(tmp, pos);
+    } else {
+        /* in windows, has '\r\n' in the end of line, omit '\r' */
+        if (*(end - 1) == '\r') {
+            end--;
+        }
+        strncpy(tmp, pos, end - pos);
+        *(tmp + (end - pos)) = '\0';
+    }
+
     return value;
 }
 
@@ -316,7 +346,11 @@
     check_jvmti_error(env, (*jvmti)->GetSystemProperty(jvmti,"java.class.path",&classpath),"Failed to get classpath.");
     classpath_cpy = (char *)hymem_allocate_memory((sizeof(char)*(strlen(classpath)+strlen(jar_name)+2)));
     strcpy(classpath_cpy,classpath);
+#if defined(WIN32) || defined(WIN64)
     strcat(classpath_cpy,";");
+#else
+    strcat(classpath_cpy,":");
+#endif
     strcat(classpath_cpy,jar_name);
     check_jvmti_error(env, (*jvmti)->SetSystemProperty(jvmti, "java.class.path",classpath_cpy),"Failed to set classpath.");
     hymem_free_memory(classpath_cpy);
@@ -339,9 +373,9 @@
     str_support_redefine = read_attribute(vm, manifest, lwrmanifest,"can-redefine-classes");
     if(NULL != str_support_redefine){
         support_redefine = str2bol(str_support_redefine);
-        gsupport_redefine |= support_redefine;
         hymem_free_memory(str_support_redefine);
     }
+    gsupport_redefine &= support_redefine;
 
     //add bootclasspath
 
@@ -362,6 +396,10 @@
 JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *options, void *reserved){
     PORT_ACCESS_FROM_JAVAVM(vm);
     VMI_ACCESS_FROM_JAVAVM(vm);
+    jvmtiError jvmti_err;
+    JNIEnv *env = NULL;
+    static jvmtiEnv *jvmti;
+    jvmtiCapabilities updatecapabilities;
     jint err = (*vm)->GetEnv(vm, (void **)&jnienv, JNI_VERSION_1_2);
     if(JNI_OK != err){
         return err;
@@ -371,8 +409,6 @@
         jvmtiCapabilities capabilities;
         jvmtiError jvmti_err;
         jvmtiEventCallbacks callbacks;
-        JNIEnv *env = NULL;
-        static jvmtiEnv *jvmti;
 
         gdata = hymem_allocate_memory(sizeof(AgentData));
 
@@ -383,15 +419,10 @@
         }
         gdata->jvmti = jvmti;
 
-        //set prerequisite capabilities for classfileloadhook, redefine, and VMInit event
-        memset(&capabilities, 0, sizeof(capabilities));
-        capabilities.can_generate_all_class_hook_events=1;
-        capabilities.can_redefine_classes = 1;
-        //FIXME VM doesnot support the capbility right now.
-        //capabilities.can_redefine_any_class = 1;
-        jvmti_err = (*jvmti)->AddCapabilities(jvmti, &capabilities);
-        check_jvmti_error(env, jvmti_err,
-                          "Cannot add JVMTI capabilities.");
+        //get JVMTI potential capabilities
+        jvmti_err = (*jvmti)->GetPotentialCapabilities(jvmti, &capabilities);
+        check_jvmti_error(env, jvmti_err, "Cannot get JVMTI potential capabilities.");
+        gsupport_redefine = (capabilities.can_redefine_classes == 1);
 
         //set events callback function
         (void)memset(&callbacks, 0, sizeof(callbacks));
@@ -405,7 +436,18 @@
         check_jvmti_error(env, jvmti_err, "Cannot set JVMTI VMInit event notification mode.");
     }
 
-    return Parse_Options(vm,jnienv, gdata->jvmti,options);
+    err = Parse_Options(vm,jnienv, gdata->jvmti,options);
+
+    //update capabilities JVMTI
+    memset(&updatecapabilities, 0, sizeof(updatecapabilities));
+    updatecapabilities.can_generate_all_class_hook_events = 1;
+    updatecapabilities.can_redefine_classes = gsupport_redefine;
+    //FIXME VM doesnot support the capbility right now.
+    //capabilities.can_redefine_any_class = 1;
+    jvmti_err = (*jvmti)->AddCapabilities(jvmti, &updatecapabilities);
+    check_jvmti_error(env, jvmti_err, "Cannot add JVMTI capabilities.");
+
+    return err;
 }
 
 JNIEXPORT void JNICALL Agent_OnUnload(JavaVM *vm){

Propchange: harmony/enhanced/classlib/branches/java6/modules/jmx/META-INF/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 03:22:37 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/jmx/META-INF:768152-885602
+/harmony/enhanced/classlib/trunk/modules/jmx/META-INF:768152-889062

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 Thu Dec 10 03:22:37 2009
@@ -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-889062

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=889068&r1=889067&r2=889068&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 Thu Dec 10 03:22:37 2009
@@ -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/util/AbstractMap.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/AbstractMap.java?rev=889068&r1=889067&r2=889068&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 Thu Dec 10 03:22:37 2009
@@ -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=889068&r1=889067&r2=889068&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 Thu Dec 10 03:22:37 2009
@@ -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/Collections.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Collections.java?rev=889068&r1=889067&r2=889068&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 Thu Dec 10 03:22:37 2009
@@ -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=889068&r1=889067&r2=889068&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 Thu Dec 10 03:22:37 2009
@@ -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=889068&r1=889067&r2=889068&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 Thu Dec 10 03:22:37 2009
@@ -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=889068&r1=889067&r2=889068&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 Thu Dec 10 03:22:37 2009
@@ -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/TreeMap.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/TreeMap.java?rev=889068&r1=889067&r2=889068&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/TreeMap.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/TreeMap.java Thu Dec 10 03:22:37 2009
@@ -5465,6 +5465,9 @@
 
     @SuppressWarnings("unchecked")
     private static <T> Comparable<T> toComparable(T obj) {
+        if (obj == null) {
+            throw new NullPointerException();
+        }
         return (Comparable<T>) obj;
     }
 

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=889068&r1=889067&r2=889068&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 Thu Dec 10 03:22:37 2009
@@ -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;

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/fdlibm.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 03:22:37 2009
@@ -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-889062

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/gp.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 03:22:37 2009
@@ -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-889062

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/hymagic.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 03:22:37 2009
@@ -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-889062

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/hysocket.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 03:22:37 2009
@@ -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-889062

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/hyvmls.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 03:22:37 2009
@@ -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-889062

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/jni.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 03:22:37 2009
@@ -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-889062

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/jni_types.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 03:22:37 2009
@@ -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-889062

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/jvmpi.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 03:22:37 2009
@@ -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-889062

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/jvmri.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 03:22:37 2009
@@ -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-889062

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/jvmti.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 03:22:37 2009
@@ -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-889062

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/jvmti_types.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 03:22:37 2009
@@ -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-889062

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/vmi.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 03:22:37 2009
@@ -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-889062

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/vmizip.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 03:22:37 2009
@@ -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-889062

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=889068&r1=889067&r2=889068&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 Thu Dec 10 03:22:37 2009
@@ -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/util/AbstractMapTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/AbstractMapTest.java?rev=889068&r1=889067&r2=889068&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/AbstractMapTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/AbstractMapTest.java Thu Dec 10 03:22:37 2009
@@ -19,6 +19,7 @@
 
 import java.util.AbstractMap;
 import java.util.AbstractSet;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
@@ -355,6 +356,57 @@
         assertEquals("Should be equal", amt, ht);
     }
 
+    public void testEqualsWithNullValues() {
+        Map<String, String> a = new HashMap<String, String>();
+        a.put("a", null);
+        a.put("b", null);
+
+        Map<String, String> b = new HashMap<String, String>();
+        a.put("c", "cat");
+        a.put("d", "dog");
+
+        assertFalse(a.equals(b));
+        assertFalse(b.equals(a));
+    }
+
+    public void testNullsOnViews() {
+        Map<String, String> nullHostile = new Hashtable<String, String>();
+
+        nullHostile.put("a", "apple");
+        testNullsOnView(nullHostile.entrySet());
+
+        nullHostile.put("a", "apple");
+        testNullsOnView(nullHostile.keySet());
+
+        nullHostile.put("a", "apple");
+        testNullsOnView(nullHostile.values());
+    }
+
+    private void testNullsOnView(Collection<?> view) {
+        try {
+            assertFalse(view.contains(null));
+        } catch (NullPointerException optional) {
+        }
+
+        try {
+            assertFalse(view.remove(null));
+        } catch (NullPointerException optional) {
+        }
+
+        Set<Object> setOfNull = Collections.singleton(null);
+        assertFalse(view.equals(setOfNull));
+
+        try {
+            assertFalse(view.removeAll(setOfNull));
+        } catch (NullPointerException optional) {
+        }
+
+        try {
+            assertTrue(view.retainAll(setOfNull)); // destructive
+        } catch (NullPointerException optional) {
+        }
+    }
+
     protected void setUp() {
     }
 

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/EnumSetTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/EnumSetTest.java?rev=889068&r1=889067&r2=889068&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/EnumSetTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/EnumSetTest.java Thu Dec 10 03:22:37 2009
@@ -137,6 +137,25 @@
         }
     }
 
+    public void testRemoveIteratorRemoveFromHugeEnumSet() {
+        EnumSet<HugeEnumCount> set = EnumSet.noneOf(HugeEnumCount.class);
+        set.add(HugeEnumCount.NO64);
+        set.add(HugeEnumCount.NO65);
+        set.add(HugeEnumCount.NO128);
+        Iterator<HugeEnumCount> iterator = set.iterator();
+        assertTrue(iterator.hasNext());
+        assertEquals(HugeEnumCount.NO64, iterator.next());
+        assertTrue(iterator.hasNext());
+        iterator.remove();
+        assertEquals(HugeEnumCount.NO65, iterator.next());
+        assertTrue(iterator.hasNext());
+        assertEquals(HugeEnumCount.NO128, iterator.next());
+        assertFalse(iterator.hasNext());
+        assertEquals(EnumSet.of(HugeEnumCount.NO65, HugeEnumCount.NO128), set);
+        iterator.remove();
+        assertEquals(EnumSet.of(HugeEnumCount.NO65), set);
+    }
+
     /**
      * @tests java.util.EnumSet#allOf(java.lang.Class)
      */
@@ -1220,21 +1239,21 @@
         Set<EnumWithInnerClass> setWithInnerClass = EnumSet
                 .allOf(EnumWithInnerClass.class);
         result = set.retainAll(setWithInnerClass);
-        assertTrue("Should return true", result); //$NON-NLS-1$
+        assertFalse("Should return false", result); //$NON-NLS-1$
         assertEquals("Size of set should be 0", 0, set.size()); //$NON-NLS-1$
 
         setWithInnerClass = EnumSet.noneOf(EnumWithInnerClass.class);
         result = set.retainAll(setWithInnerClass);
-        assertTrue("Should return true", result); //$NON-NLS-1$
+        assertFalse("Should return false", result); //$NON-NLS-1$
 
         Set<EmptyEnum> emptySet = EnumSet.allOf(EmptyEnum.class);
         result = set.retainAll(emptySet);
-        assertTrue("Should return true", result); //$NON-NLS-1$
+        assertFalse("Should return false", result); //$NON-NLS-1$
 
         Set<EnumWithAllInnerClass> setWithAllInnerClass = EnumSet
                 .allOf(EnumWithAllInnerClass.class);
         result = set.retainAll(setWithAllInnerClass);
-        assertTrue("Should return true", result); //$NON-NLS-1$
+        assertFalse("Should return false", result); //$NON-NLS-1$
 
         set.add(EnumFoo.a);
         result = set.retainAll(setWithInnerClass);
@@ -1314,17 +1333,17 @@
         Set<HugeEnumWithInnerClass> hugeSetWithInnerClass = EnumSet
                 .allOf(HugeEnumWithInnerClass.class);
         result = hugeSet.retainAll(hugeSetWithInnerClass);
-        assertTrue(result);
+        assertFalse(result);
         assertEquals(0, hugeSet.size());
 
         hugeSetWithInnerClass = EnumSet.noneOf(HugeEnumWithInnerClass.class);
         result = hugeSet.retainAll(hugeSetWithInnerClass);
-        assertTrue(result);
+        assertFalse(result);
 
         Set<HugeEnumWithInnerClass> hugeSetWithAllInnerClass = EnumSet
                 .allOf(HugeEnumWithInnerClass.class);
         result = hugeSet.retainAll(hugeSetWithAllInnerClass);
-        assertTrue(result);
+        assertFalse(result);
 
         hugeSet.add(HugeEnum.a);
         result = hugeSet.retainAll(hugeSetWithInnerClass);

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/unix/org/apache/harmony/luni/tests/java/io/UnixFileTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/unix/org/apache/harmony/luni/tests/java/io/UnixFileTest.java?rev=889068&r1=889067&r2=889068&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/unix/org/apache/harmony/luni/tests/java/io/UnixFileTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/unix/org/apache/harmony/luni/tests/java/io/UnixFileTest.java Thu Dec 10 03:22:37 2009
@@ -368,7 +368,8 @@
 		super.tearDown();
 	}
 
-    public void test_getCanonicalPath() throws IOException {
+    public void test_getCanonicalPath() throws IOException,
+                                               InterruptedException {
         File tmpFolder1 = new File("folder1");
         tmpFolder1.mkdirs();
         tmpFolder1.deleteOnExit();
@@ -386,7 +387,8 @@
         tmpFolder4.deleteOnExit();
 
         // make a link to folder1/folder2
-        Runtime.getRuntime().exec("ln -s folder1/folder2 folder2");
+        Process ln = Runtime.getRuntime().exec("ln -s folder1/folder2 folder2");
+        ln.waitFor();
         File linkFile = new File("folder2");
         linkFile.deleteOnExit();
 

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/resources/net.resources/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 03:22:37 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/net.resources:790472-885602
+/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/net.resources:790472-889062

Propchange: harmony/enhanced/classlib/branches/java6/modules/pack200/depends/manifests/asm-3.1/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 03:22:37 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/pack200/depends/manifests/asm-3.1:785554-885602
+/harmony/enhanced/classlib/trunk/modules/pack200/depends/manifests/asm-3.1:785554-889062

Propchange: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200Adapter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 03:22:37 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200Adapter.java:782694-885602
+/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200Adapter.java:782694-889062

Propchange: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200PackerAdapter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 03:22:37 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200PackerAdapter.java:782694-885602
+/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200PackerAdapter.java:782694-889062

Modified: harmony/enhanced/classlib/branches/java6/modules/rmi/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/rmi/META-INF/MANIFEST.MF?rev=889068&r1=889067&r2=889068&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/rmi/META-INF/MANIFEST.MF (original)
+++ harmony/enhanced/classlib/branches/java6/modules/rmi/META-INF/MANIFEST.MF Thu Dec 10 03:22:37 2009
@@ -23,6 +23,7 @@
  javax.net,
  javax.net.ssl,
  org.apache.harmony.kernel.vm,
+ org.apache.harmony.luni.util,
  org.apache.harmony.testframework.serialization;hy_usage=test;resolution:=optional
 Export-Package: java.rmi,
  java.rmi.activation,



Re: svn commit: r889068 [1/2] - in /harmony/enhanced/classlib/branches/java6: ./ make/ modules/archive/src/main/java/java/util/jar/ modules/archive/src/main/java/java/util/zip/ modules/concurrent/src/main/java/java/util/concurrent/atomic/ modules/concurren...

Posted by Mark Hindess <ma...@googlemail.com>.
Please revert this.  The java6 branch is frozen for the 6.0M1 release.
I have already merge all approved commits from trunk so this commit was
not approved by two committers.

If you want it unfrozen, then perhaps you should test and report issues
so that we can finalize the 6.0M1 release?

-Mark

In message <20...@eris.apache.org>, tonywu@apache.org
writes:
>
> Author: tonywu
> Date: Thu Dec 10 03:22:37 2009
> New Revision: 889068
> 
> URL: http://svn.apache.org/viewvc?rev=889068&view=rev
> Log:
> Merge updates from classlib trunk@889062 since r885602
> 
> 
> Added:
>     harmony/enhanced/classlib/branches/java6/modules/instrument/src/test/java
> /org/apache/harmony/tests/java/lang/instrument/HelloWorldTest.java
>       - copied unchanged from r889062, harmony/enhanced/classlib/trunk/module
> s/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/Hell
> oWorldTest.java
>     harmony/enhanced/classlib/branches/java6/modules/instrument/src/test/java
> /org/apache/harmony/tests/java/lang/instrument/InstrumentTestHelper.java
>       - copied unchanged from r889062, harmony/enhanced/classlib/trunk/module
> s/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/Inst
> rumentTestHelper.java
>     harmony/enhanced/classlib/branches/java6/modules/instrument/src/test/java
> /org/apache/harmony/tests/java/lang/instrument/agents/
>       - copied from r889062, harmony/enhanced/classlib/trunk/modules/instrume
> nt/src/test/java/org/apache/harmony/tests/java/lang/instrument/agents/
>     harmony/enhanced/classlib/branches/java6/modules/instrument/src/test/java
> /org/apache/harmony/tests/java/lang/instrument/agents/HelloWorldAgent.java
>       - copied unchanged from r889062, harmony/enhanced/classlib/trunk/module
> s/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/agen
> ts/HelloWorldAgent.java
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/a
> pache/harmony/luni/util/InputStreamHelper.java
>       - copied unchanged from r889062, harmony/enhanced/classlib/trunk/module
> s/luni/src/main/java/org/apache/harmony/luni/util/InputStreamHelper.java
> Removed:
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/a
> pache/harmony/luni/util/ExposedByteArrayInputStream.java
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/a
> pache/harmony/luni/util/InputStreamExposer.java
> Modified:
>     harmony/enhanced/classlib/branches/java6/   (props changed)
>     harmony/enhanced/classlib/branches/java6/make/build-test.xml
>     harmony/enhanced/classlib/branches/java6/make/depends-common.xml   (props
>  changed)
>     harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/ja
> va/util/jar/JarFile.java
>     harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/ja
> va/util/jar/Manifest.java
>     harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/ja
> va/util/zip/ZipFile.java
>     harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java
> /java/util/concurrent/atomic/   (props changed)
>     harmony/enhanced/classlib/branches/java6/modules/concurrent/src/main/java
> /java/util/concurrent/locks/   (props changed)
>     harmony/enhanced/classlib/branches/java6/modules/instrument/src/main/nati
> ve/instrument/shared/inst_agt.c
>     harmony/enhanced/classlib/branches/java6/modules/jmx/META-INF/   (props c
> hanged)
>     harmony/enhanced/classlib/branches/java6/modules/lang-management/src/test
> /api/java/org/apache/harmony/lang/management/tests/java/util/logging/   (prop
> s changed)
>     harmony/enhanced/classlib/branches/java6/modules/luni/META-INF/MANIFEST.M
> F
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/
> util/AbstractMap.java
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/
> util/AbstractSet.java
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/
> util/Collections.java
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/
> util/EnumSet.java
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/
> util/HugeEnumSet.java
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/
> util/MiniEnumSet.java
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/
> util/TreeMap.java
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/
> util/TreeSet.java
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/inc
> lude/fdlibm.h   (props changed)
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/inc
> lude/gp.h   (props changed)
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/inc
> lude/hymagic.h   (props changed)
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/inc
> lude/hysocket.h   (props changed)
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/inc
> lude/hyvmls.h   (props changed)
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/inc
> lude/jni.h   (props changed)
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/inc
> lude/jni_types.h   (props changed)
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/inc
> lude/jvmpi.h   (props changed)
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/inc
> lude/jvmri.h   (props changed)
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/inc
> lude/jvmti.h   (props changed)
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/inc
> lude/jvmti_types.h   (props changed)
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/inc
> lude/vmi.h   (props changed)
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/inc
> lude/vmizip.h   (props changed)
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common
> /org/apache/harmony/luni/tests/java/io/SerializationStressTest.java
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common
> /org/apache/harmony/luni/tests/java/util/AbstractMapTest.java
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common
> /org/apache/harmony/luni/tests/java/util/EnumSetTest.java
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/unix/o
> rg/apache/harmony/luni/tests/java/io/UnixFileTest.java
>     harmony/enhanced/classlib/branches/java6/modules/luni/src/test/resources/
> net.resources/   (props changed)
>     harmony/enhanced/classlib/branches/java6/modules/pack200/depends/manifest
> s/asm-3.1/   (props changed)
>     harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/o
> rg/apache/harmony/pack200/Pack200Adapter.java   (props changed)
>     harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/o
> rg/apache/harmony/pack200/Pack200PackerAdapter.java   (props changed)
>     harmony/enhanced/classlib/branches/java6/modules/rmi/META-INF/MANIFEST.MF
>     harmony/enhanced/classlib/branches/java6/modules/rmi/src/main/java/java/r
> mi/server/RMIClassLoader.java
>     harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/c
> ommon/org/apache/harmony/security/utils/JarUtils.java
>     harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/ja
> va/org/apache/harmony/security/tests/java/security/SecureClassLoader2Test.jav
> a
>     harmony/enhanced/classlib/branches/java6/modules/sound/src/main/java/org/
> apache/harmony/sound/utils/ProviderService.java
>     harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/ap
> ache/harmony/sql/tests/java/sql/SQLExceptionTest.java
>     harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/ap
> ache/harmony/sql/tests/java/sql/SQLWarningTest.java
>     harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/ap
> ache/harmony/sql/tests/javax/transaction/TransactionRequiredExceptionTest.jav
> a
>     harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/ap
> ache/harmony/sql/tests/javax/transaction/TransactionRolledbackExceptionTest.j
> ava
>     harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.
> injected/javax/swing/BasicSwingTestCase.java   (props changed)
>     harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.
> injected/javax/swing/SwingTestCase.java   (props changed)
>     harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.
> injected/javax/swing/text/parser/   (props changed)
> 
> Propchange: harmony/enhanced/classlib/branches/java6/
> -----------------------------------------------------------------------------
> -
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Thu Dec 10 03:22:37 2009
> @@ -1,2 +1,2 @@
> -/harmony/enhanced/classlib/trunk:713674-735919,765923-885602
> +/harmony/enhanced/classlib/trunk:713674-735919,765923-889062
>  /harmony/enhanced/classlib/trunk/working_classlib:884014-884286
> 
> Modified: harmony/enhanced/classlib/branches/java6/make/build-test.xml
> URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/ma
> ke/build-test.xml?rev=889068&r1=889067&r2=889068&view=diff
> =============================================================================
> =
> --- harmony/enhanced/classlib/branches/java6/make/build-test.xml (original)
> +++ harmony/enhanced/classlib/branches/java6/make/build-test.xml Thu Dec 10 0
> 3:22:37 2009
> @@ -27,6 +27,20 @@
>      <property name="tests.output" location="build/test_report" />
>      <import file="${basedir}/make/properties.xml" />
>  
> +    <property name="gen.report" value="true" />
> +    <condition property="do.full.report" value="true">
> +        <and>
> +            <equals arg1="${gen.report}" arg2="true" />
> +            <not><equals arg1="${short.report}" arg2="true" /></not>
> +        </and>
> +    </condition>
> +    <condition property="do.short.report" value="true">
> +        <and>
> +            <equals arg1="${gen.report}" arg2="true" />
> +            <equals arg1="${short.report}" arg2="true" />
> +        </and>
> +    </condition>
> +
>      <property name="tests.support.output" location="build/test_support" />
>      <property name="support.dir" location="support"/>
>      <property name="tests.depends.jars" location="deploy/jdk/jre/lib/boot" /
> >
> @@ -71,7 +85,7 @@
>  
>      <property name="report.dir" value="${tests.output}/html"/>
>  
> -    <target name="full-report" unless="short.report" >
> +    <target name="full-report" if="do.full.report" >
>          <delete dir="${report.dir}" />
>          <junitreport todir="${tests.output}">
>              <fileset dir="${tests.output}">
> @@ -85,7 +99,7 @@
>          <echo message="The test report is in ${display-location}"/>
>      </target>
>  
> -    <target name="short-report" if="short.report" >
> +    <target name="short-report" if="do.short.report">
>          <delete dir="${report.dir}" />
>          <junitreport todir="${tests.output}">
>              <fileset dir="${tests.output}" includes="TEST*-*.xml">
> 
> Propchange: harmony/enhanced/classlib/branches/java6/make/depends-common.xml
> -----------------------------------------------------------------------------
> -
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Thu Dec 10 03:22:37 2009
> @@ -1 +1 @@
> -/harmony/enhanced/classlib/trunk/make/depends-common.xml:768152-885602
> +/harmony/enhanced/classlib/trunk/make/depends-common.xml:768152-889062
> 
> Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/j
> ava/java/util/jar/JarFile.java
> URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/mo
> dules/archive/src/main/java/java/util/jar/JarFile.java?rev=889068&r1=889067&r
> 2=889068&view=diff
> =============================================================================
> =
> --- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/ja
> va/util/jar/JarFile.java (original)
> +++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/ja
> va/util/jar/JarFile.java Thu Dec 10 03:22:37 2009
> @@ -17,19 +17,19 @@
>  
>  package java.util.jar;
>  
> -import java.io.ByteArrayOutputStream;
> -import java.util.List;
> -import java.util.ArrayList;
>  import java.io.File;
>  import java.io.FilterInputStream;
>  import java.io.IOException;
>  import java.io.InputStream;
> +import java.util.ArrayList;
>  import java.util.Enumeration;
> +import java.util.List;
>  import java.util.zip.ZipEntry;
>  import java.util.zip.ZipFile;
>  
>  import org.apache.harmony.archive.internal.nls.Messages;
>  import org.apache.harmony.archive.util.Util;
> +import org.apache.harmony.luni.util.InputStreamHelper;
>  
>  /**
>   * {@code JarFile} is used to read jar entries and their associated data fro
> m
> @@ -282,42 +282,6 @@
>          return (JarEntry) getEntry(name);
>      }
>  
> -    /*
> -     * Drains the entire content from the given input stream and returns it 
> as a
> -     * byte[]. The stream is closed after being drained, or if an IOExceptio
> n
> -     * occurs.
> -     */
> -    private byte[] getAllBytesFromStreamAndClose(InputStream is)
> -            throws IOException {
> -        try {
> -            // Initial read
> -            byte[] buffer = new byte[1024];
> -            int count = is.read(buffer);
> -            int nextByte = is.read();
> -
> -            // Did we get it all in one read?
> -            if (nextByte == -1) {
> -                byte[] dest = new byte[count];
> -                System.arraycopy(buffer, 0, dest, 0, count);
> -                return dest;
> -            }
> -
> -            // Requires additional reads
> -            ByteArrayOutputStream baos = new ByteArrayOutputStream(count * 2
> );
> -            baos.write(buffer, 0, count);
> -            baos.write(nextByte);
> -            while (true) {
> -                count = is.read(buffer);
> -                if (count == -1) {
> -                    return baos.toByteArray();
> -                }
> -                baos.write(buffer, 0, count);
> -            }
> -        } finally {
> -            is.close();
> -        }
> -    }
> -
>      /**
>       * Returns the {@code Manifest} object associated with this {@code JarFi
> le}
>       * or {@code null} if no MANIFEST entry exists.
> @@ -340,7 +304,8 @@
>          try {
>              InputStream is = super.getInputStream(manifestEntry);
>              if (verifier != null) {
> -                verifier.addMetaEntry(manifestEntry.getName(), getAllBytesFr
> omStreamAndClose(is));
> +                verifier.addMetaEntry(manifestEntry.getName(),
> +                        InputStreamHelper.readFullyAndClose(is));
>                  is = super.getInputStream(manifestEntry);
>              }
>              try {
> @@ -392,7 +357,7 @@
>                                  || Util.asciiEndsWithIgnoreCase(entryName, "
> .RSA"))) {
>                      signed = true;
>                      InputStream is = super.getInputStream(entry);
> -                    byte[] buf = getAllBytesFromStreamAndClose(is);
> +                    byte[] buf = InputStreamHelper.readFullyAndClose(is);
>                      verifier.addMetaEntry(entryName, buf);
>                  }
>              }
> 
> Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/j
> ava/java/util/jar/Manifest.java
> URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/mo
> dules/archive/src/main/java/java/util/jar/Manifest.java?rev=889068&r1=889067&
> r2=889068&view=diff
> =============================================================================
> =
> --- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/ja
> va/util/jar/Manifest.java (original)
> +++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/ja
> va/util/jar/Manifest.java Thu Dec 10 03:22:37 2009
> @@ -30,7 +30,7 @@
>  import java.util.Map;
>  
>  import org.apache.harmony.archive.internal.nls.Messages;
> -import org.apache.harmony.luni.util.InputStreamExposer;
> +import org.apache.harmony.luni.util.InputStreamHelper;
>  import org.apache.harmony.luni.util.ThreadLocalCache;
>  
>  /**
> @@ -209,7 +209,7 @@
>          byte[] buf;
>          // Try to read get a reference to the bytes directly
>          try {
> -            buf = InputStreamExposer.expose(is);
> +            buf = InputStreamHelper.expose(is);
>          } catch (UnsupportedOperationException uoe) {
>              buf = readFully(is);
>          }
> 
> Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/j
> ava/java/util/zip/ZipFile.java
> URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/mo
> dules/archive/src/main/java/java/util/zip/ZipFile.java?rev=889068&r1=889067&r
> 2=889068&view=diff
> =============================================================================
> =
> --- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/ja
> va/util/zip/ZipFile.java (original)
> +++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/ja
> va/util/zip/ZipFile.java Thu Dec 10 03:22:37 2009
> @@ -368,7 +368,6 @@
>          RandomAccessFile mSharedRaf;
>          long mOffset;
>          long mLength;
> -        private byte[] singleByteBuf = new byte[1];
>  
>          public RAFStream(RandomAccessFile raf, long pos) throws IOException 
> {
>              mSharedRaf = raf;
> @@ -383,6 +382,7 @@
>  
>          @Override
>          public int read() throws IOException {
> +            byte[] singleByteBuf = new byte[1];
>              if (read(singleByteBuf, 0, 1) == 1) {
>                  return singleByteBuf[0] & 0XFF;
>              } else {
> 
> Propchange: harmony/enhanced/classlib/branches/java6/modules/concurrent/src/m
> ain/java/java/util/concurrent/atomic/
> -----------------------------------------------------------------------------
> -
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Thu Dec 10 03:22:37 2009
> @@ -1 +1 @@
> -/harmony/enhanced/classlib/trunk/modules/concurrent/src/main/java/java/util/
> concurrent/atomic:765923-885602
> +/harmony/enhanced/classlib/trunk/modules/concurrent/src/main/java/java/util/
> concurrent/atomic:765923-889062
> 
> Propchange: harmony/enhanced/classlib/branches/java6/modules/concurrent/src/m
> ain/java/java/util/concurrent/locks/
> -----------------------------------------------------------------------------
> -
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Thu Dec 10 03:22:37 2009
> @@ -1 +1 @@
> -/harmony/enhanced/classlib/trunk/modules/concurrent/src/main/java/java/util/
> concurrent/locks:765923-885602
> +/harmony/enhanced/classlib/trunk/modules/concurrent/src/main/java/java/util/
> concurrent/locks:765923-889062
> 
> Modified: harmony/enhanced/classlib/branches/java6/modules/instrument/src/mai
> n/native/instrument/shared/inst_agt.c
> URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/mo
> dules/instrument/src/main/native/instrument/shared/inst_agt.c?rev=889068&r1=8
> 89067&r2=889068&view=diff
> =============================================================================
> =
> --- harmony/enhanced/classlib/branches/java6/modules/instrument/src/main/nati
> ve/instrument/shared/inst_agt.c (original)
> +++ harmony/enhanced/classlib/branches/java6/modules/instrument/src/main/nati
> ve/instrument/shared/inst_agt.c Thu Dec 10 03:22:37 2009
> @@ -206,7 +206,7 @@
>  
>      /* read bytes */
>      size = zipEntry.uncompressedSize;
> -    result = (char *)hymem_allocate_memory(size*sizeof(char));
> +    result = (char *)hymem_allocate_memory(size*sizeof(char) + 1);
>  #ifndef HY_ZIP_API
>      retval = zip_getZipEntryData(privatePortLibrary, &zipFile, &zipEntry, (u
> nsigned char*)result, size);
>  #else /* HY_ZIP_API */
> @@ -223,6 +223,7 @@
>          return NULL;
>      }
>  
> +    result[size] = '\0';
>      /* free resource */
>  #ifndef HY_ZIP_API
>      zip_freeZipEntry(privatePortLibrary, &zipEntry);
> @@ -243,6 +244,7 @@
>      char *pos;
>      char *end;
>      char *value;
> +    char *tmp;
>      int length;
>      PORT_ACCESS_FROM_JAVAVM(vm);
>  
> @@ -253,18 +255,46 @@
>      pos = manifest+ (strstr(lwrmanifest,target) - lwrmanifest);
>      pos += strlen(target)+2;//": "
>      end = strchr(pos, '\n');
> +
> +    while (end != NULL && *(end + 1) == ' ') {
> +        end = strchr(end + 1, '\n');
> +    }
> +
>      if(NULL == end){
>          end = manifest + strlen(manifest);
>      }
> -    /* in windows, has '\r\n' in the end of line, omit '\r' */
> -    if (*(end - 1) == '\r'){
> -        end--;
> -    }
> +
>      length = end - pos;
>  
>      value = (char *)hymem_allocate_memory(sizeof(char)*(length+1));
> -    strncpy(value, pos, length);
> -    *(value+length) = '\0';
> +    tmp = value;
> +
> +    end = strchr(pos, '\n');
> +    while (end != NULL && *(end + 1) == ' ') {
> +        /* in windows, has '\r\n' in the end of line, omit '\r' */
> +        if (*(end - 1) == '\r') {
> +            strncpy(tmp, pos, end - 1 - pos);
> +            tmp += end - 1 - pos;
> +            pos = end + 2;
> +        } else {
> +            strncpy(tmp, pos, end - pos);
> +            tmp += end - pos;
> +            pos = end + 2;
> +        }
> +        end = strchr(end + 1, '\n');
> +    }
> +
> +    if (NULL == end) {
> +        strcpy(tmp, pos);
> +    } else {
> +        /* in windows, has '\r\n' in the end of line, omit '\r' */
> +        if (*(end - 1) == '\r') {
> +            end--;
> +        }
> +        strncpy(tmp, pos, end - pos);
> +        *(tmp + (end - pos)) = '\0';
> +    }
> +
>      return value;
>  }
>  
> @@ -316,7 +346,11 @@
>      check_jvmti_error(env, (*jvmti)->GetSystemProperty(jvmti,"java.class.pat
> h",&classpath),"Failed to get classpath.");
>      classpath_cpy = (char *)hymem_allocate_memory((sizeof(char)*(strlen(clas
> spath)+strlen(jar_name)+2)));
>      strcpy(classpath_cpy,classpath);
> +#if defined(WIN32) || defined(WIN64)
>      strcat(classpath_cpy,";");
> +#else
> +    strcat(classpath_cpy,":");
> +#endif
>      strcat(classpath_cpy,jar_name);
>      check_jvmti_error(env, (*jvmti)->SetSystemProperty(jvmti, "java.class.pa
> th",classpath_cpy),"Failed to set classpath.");
>      hymem_free_memory(classpath_cpy);
> @@ -339,9 +373,9 @@
>      str_support_redefine = read_attribute(vm, manifest, lwrmanifest,"can-red
> efine-classes");
>      if(NULL != str_support_redefine){
>          support_redefine = str2bol(str_support_redefine);
> -        gsupport_redefine |= support_redefine;
>          hymem_free_memory(str_support_redefine);
>      }
> +    gsupport_redefine &= support_redefine;
>  
>      //add bootclasspath
>  
> @@ -362,6 +396,10 @@
>  JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *options, void *reserve
> d){
>      PORT_ACCESS_FROM_JAVAVM(vm);
>      VMI_ACCESS_FROM_JAVAVM(vm);
> +    jvmtiError jvmti_err;
> +    JNIEnv *env = NULL;
> +    static jvmtiEnv *jvmti;
> +    jvmtiCapabilities updatecapabilities;
>      jint err = (*vm)->GetEnv(vm, (void **)&jnienv, JNI_VERSION_1_2);
>      if(JNI_OK != err){
>          return err;
> @@ -371,8 +409,6 @@
>          jvmtiCapabilities capabilities;
>          jvmtiError jvmti_err;
>          jvmtiEventCallbacks callbacks;
> -        JNIEnv *env = NULL;
> -        static jvmtiEnv *jvmti;
>  
>          gdata = hymem_allocate_memory(sizeof(AgentData));
>  
> @@ -383,15 +419,10 @@
>          }
>          gdata->jvmti = jvmti;
>  
> -        //set prerequisite capabilities for classfileloadhook, redefine, and
>  VMInit event
> -        memset(&capabilities, 0, sizeof(capabilities));
> -        capabilities.can_generate_all_class_hook_events=1;
> -        capabilities.can_redefine_classes = 1;
> -        //FIXME VM doesnot support the capbility right now.
> -        //capabilities.can_redefine_any_class = 1;
> -        jvmti_err = (*jvmti)->AddCapabilities(jvmti, &capabilities);
> -        check_jvmti_error(env, jvmti_err,
> -                          "Cannot add JVMTI capabilities.");
> +        //get JVMTI potential capabilities
> +        jvmti_err = (*jvmti)->GetPotentialCapabilities(jvmti, &capabilities)
> ;
> +        check_jvmti_error(env, jvmti_err, "Cannot get JVMTI potential capabi
> lities.");
> +        gsupport_redefine = (capabilities.can_redefine_classes == 1);
>  
>          //set events callback function
>          (void)memset(&callbacks, 0, sizeof(callbacks));
> @@ -405,7 +436,18 @@
>          check_jvmti_error(env, jvmti_err, "Cannot set JVMTI VMInit event not
> ification mode.");
>      }
>  
> -    return Parse_Options(vm,jnienv, gdata->jvmti,options);
> +    err = Parse_Options(vm,jnienv, gdata->jvmti,options);
> +
> +    //update capabilities JVMTI
> +    memset(&updatecapabilities, 0, sizeof(updatecapabilities));
> +    updatecapabilities.can_generate_all_class_hook_events = 1;
> +    updatecapabilities.can_redefine_classes = gsupport_redefine;
> +    //FIXME VM doesnot support the capbility right now.
> +    //capabilities.can_redefine_any_class = 1;
> +    jvmti_err = (*jvmti)->AddCapabilities(jvmti, &updatecapabilities);
> +    check_jvmti_error(env, jvmti_err, "Cannot add JVMTI capabilities.");
> +
> +    return err;
>  }
>  
>  JNIEXPORT void JNICALL Agent_OnUnload(JavaVM *vm){
> 
> Propchange: harmony/enhanced/classlib/branches/java6/modules/jmx/META-INF/
> -----------------------------------------------------------------------------
> -
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Thu Dec 10 03:22:37 2009
> @@ -1 +1 @@
> -/harmony/enhanced/classlib/trunk/modules/jmx/META-INF:768152-885602
> +/harmony/enhanced/classlib/trunk/modules/jmx/META-INF:768152-889062
> 
> 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 Thu Dec 10 03:22:37 2009
> @@ -1 +1 @@
> -/harmony/enhanced/classlib/trunk/modules/lang-management/src/test/api/java/o
> rg/apache/harmony/lang/management/tests/java/util/logging:768152-885602
> +/harmony/enhanced/classlib/trunk/modules/lang-management/src/test/api/java/o
> rg/apache/harmony/lang/management/tests/java/util/logging:768152-889062
> 
> Modified: harmony/enhanced/classlib/branches/java6/modules/luni/META-INF/MANI
> FEST.MF
> URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/mo
> dules/luni/META-INF/MANIFEST.MF?rev=889068&r1=889067&r2=889068&view=diff
> =============================================================================
> =
> --- harmony/enhanced/classlib/branches/java6/modules/luni/META-INF/MANIFEST.M
> F (original)
> +++ harmony/enhanced/classlib/branches/java6/modules/luni/META-INF/MANIFEST.M
> F Thu Dec 10 03:22:37 2009
> @@ -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/util/AbstractMap.java
> URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/mo
> dules/luni/src/main/java/java/util/AbstractMap.java?rev=889068&r1=889067&r2=8
> 89068&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 Thu Dec 10 03:22:37 2009
> @@ -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/mo
> dules/luni/src/main/java/java/util/AbstractSet.java?rev=889068&r1=889067&r2=8
> 89068&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 Thu Dec 10 03:22:37 2009
> @@ -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/Collections.java
> URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/mo
> dules/luni/src/main/java/java/util/Collections.java?rev=889068&r1=889067&r2=8
> 89068&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 Thu Dec 10 03:22:37 2009
> @@ -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 proper
> ly.
> +     */
>      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> implem
> ents
> @@ -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.hashCod
> e());
> -                                    }
> -
> -                                    public V setValue(V value) {
> -                                        throw new UnsupportedOperationExcept
> ion();
> -                                    }
> -                                };
> +                            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 comparab
> le
> +            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 comparab
> le
> +            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/mo
> dules/luni/src/main/java/java/util/EnumSet.java?rev=889068&r1=889067&r2=88906
> 8&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 Thu Dec 10 03:22:37 2009
> @@ -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/mo
> dules/luni/src/main/java/java/util/HugeEnumSet.java?rev=889068&r1=889067&r2=8
> 89068&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 Thu Dec 10 03:22:37 2009
> @@ -18,90 +18,95 @@
>  
>  
>  /**
> - * This is a concrete subclass of EnumSet designed specifically for enum typ
> e
> - * 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 value
> s 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 curre
> ntBits as necessary.
> +         */
> +        void computeNextElement() {
> +            while (true) {
> +                if (currentBits != 0) {
> +                    mask = currentBits & -currentBits; // the lowest 1 bit i
> n 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 - startElementI
> nBits + 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 mos
> t 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/mo
> dules/luni/src/main/java/java/util/MiniEnumSet.java?rev=889068&r1=889067&r2=8
> 89068&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 Thu Dec 10 03:22:37 2009
> @@ -18,9 +18,7 @@
>  
>  
>  /**
> - * This is a concrete subclass of EnumSet designed specifically for enum typ
> e
> - * 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 curren
> tBits
> +
> +            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) == s
> et.bits);
> +            long setBits = set.bits;
> +            return isValidType(set.elementClass) && ((bits & setBits) == set
> Bits);
>          }
>          return !(collection instanceof EnumSet) && super.containsAll(collect
> ion);  
>      }
>      
>      @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/TreeMap.java
> URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/mo
> dules/luni/src/main/java/java/util/TreeMap.java?rev=889068&r1=889067&r2=88906
> 8&view=diff
> =============================================================================
> =
> --- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/
> util/TreeMap.java (original)
> +++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/
> util/TreeMap.java Thu Dec 10 03:22:37 2009
> @@ -5465,6 +5465,9 @@
>  
>      @SuppressWarnings("unchecked")
>      private static <T> Comparable<T> toComparable(T obj) {
> +        if (obj == null) {
> +            throw new NullPointerException();
> +        }
>          return (Comparable<T>) obj;
>      }
>  
> 
> 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/mo
> dules/luni/src/main/java/java/util/TreeSet.java?rev=889068&r1=889067&r2=88906
> 8&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 Thu Dec 10 03:22:37 2009
> @@ -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>) bac
> kingMap)
> +                clone.backingMap = (NavigableMap<E, Object>) ((TreeMap<E, Ob
> ject>) 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;
> 
> Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/na
> tive/include/fdlibm.h
> -----------------------------------------------------------------------------
> -
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Thu Dec 10 03:22:37 2009
> @@ -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-889062
> 
> Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/na
> tive/include/gp.h
> -----------------------------------------------------------------------------
> -
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Thu Dec 10 03:22:37 2009
> @@ -1 +1 @@
> -/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/gp.h:8
> 03062-885602
> +/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/gp.h:8
> 03062-889062
> 
> Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/na
> tive/include/hymagic.h
> -----------------------------------------------------------------------------
> -
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Thu Dec 10 03:22:37 2009
> @@ -1 +1 @@
> -/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/hymagi
> c.h:803062-885602
> +/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/hymagi
> c.h:803062-889062
> 
> Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/na
> tive/include/hysocket.h
> -----------------------------------------------------------------------------
> -
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Thu Dec 10 03:22:37 2009
> @@ -1 +1 @@
> -/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/hysock
> et.h:803062-885602
> +/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/hysock
> et.h:803062-889062
> 
> Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/na
> tive/include/hyvmls.h
> -----------------------------------------------------------------------------
> -
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Thu Dec 10 03:22:37 2009
> @@ -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-889062
> 
> Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/na
> tive/include/jni.h
> -----------------------------------------------------------------------------
> -
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Thu Dec 10 03:22:37 2009
> @@ -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-889062
> 
> Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/na
> tive/include/jni_types.h
> -----------------------------------------------------------------------------
> -
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Thu Dec 10 03:22:37 2009
> @@ -1 +1 @@
> -/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jni_ty
> pes.h:803062-885602
> +/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jni_ty
> pes.h:803062-889062
> 
> Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/na
> tive/include/jvmpi.h
> -----------------------------------------------------------------------------
> -
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Thu Dec 10 03:22:37 2009
> @@ -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-889062
> 
> Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/na
> tive/include/jvmri.h
> -----------------------------------------------------------------------------
> -
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Thu Dec 10 03:22:37 2009
> @@ -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-889062
> 
> Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/na
> tive/include/jvmti.h
> -----------------------------------------------------------------------------
> -
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Thu Dec 10 03:22:37 2009
> @@ -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-889062
> 
> Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/na
> tive/include/jvmti_types.h
> -----------------------------------------------------------------------------
> -
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Thu Dec 10 03:22:37 2009
> @@ -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-889062
> 
> Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/na
> tive/include/vmi.h
> -----------------------------------------------------------------------------
> -
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Thu Dec 10 03:22:37 2009
> @@ -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-889062
> 
> Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/na
> tive/include/vmizip.h
> -----------------------------------------------------------------------------
> -
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Thu Dec 10 03:22:37 2009
> @@ -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-889062
> 
> 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/mo
> dules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/Serializ
> ationStressTest.java?rev=889068&r1=889067&r2=889068&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 Thu Dec 1
> 0 03:22:37 2009
> @@ -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.cla
> ss);
>  	}
>  
> -	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, (by
> te) 0, (byte) 1,
> -					(byte) 'R', (byte) 0x79, (byte) 0x77, (
> byte) 1, (byte) 24 };
> -			assertTrue("incorrect output", Arrays.equals(input, res
> ult));
> -
> -			ois = new ObjectInputStreamSubclass(loadStream());
> -			assertEquals("Wrong result from readObject()", "R", ois
> .readObject()
> -					);
> -			assertEquals("Wrong result from readByte()", 24, ois.re
> adByte());
> -			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 Excep
> tion {
>  		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/util/AbstractMapTest.java
> URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/mo
> dules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/Abstra
> ctMapTest.java?rev=889068&r1=889067&r2=889068&view=diff
> =============================================================================
> =
> --- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common
> /org/apache/harmony/luni/tests/java/util/AbstractMapTest.java (original)
> +++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common
> /org/apache/harmony/luni/tests/java/util/AbstractMapTest.java Thu Dec 10 03:2
> 2:37 2009
> @@ -19,6 +19,7 @@
>  
>  import java.util.AbstractMap;
>  import java.util.AbstractSet;
> +import java.util.Collection;
>  import java.util.Collections;
>  import java.util.Comparator;
>  import java.util.HashMap;
> @@ -355,6 +356,57 @@
>          assertEquals("Should be equal", amt, ht);
>      }
>  
> +    public void testEqualsWithNullValues() {
> +        Map<String, String> a = new HashMap<String, String>();
> +        a.put("a", null);
> +        a.put("b", null);
> +
> +        Map<String, String> b = new HashMap<String, String>();
> +        a.put("c", "cat");
> +        a.put("d", "dog");
> +
> +        assertFalse(a.equals(b));
> +        assertFalse(b.equals(a));
> +    }
> +
> +    public void testNullsOnViews() {
> +        Map<String, String> nullHostile = new Hashtable<String, String>();
> +
> +        nullHostile.put("a", "apple");
> +        testNullsOnView(nullHostile.entrySet());
> +
> +        nullHostile.put("a", "apple");
> +        testNullsOnView(nullHostile.keySet());
> +
> +        nullHostile.put("a", "apple");
> +        testNullsOnView(nullHostile.values());
> +    }
> +
> +    private void testNullsOnView(Collection<?> view) {
> +        try {
> +            assertFalse(view.contains(null));
> +        } catch (NullPointerException optional) {
> +        }
> +
> +        try {
> +            assertFalse(view.remove(null));
> +        } catch (NullPointerException optional) {
> +        }
> +
> +        Set<Object> setOfNull = Collections.singleton(null);
> +        assertFalse(view.equals(setOfNull));
> +
> +        try {
> +            assertFalse(view.removeAll(setOfNull));
> +        } catch (NullPointerException optional) {
> +        }
> +
> +        try {
> +            assertTrue(view.retainAll(setOfNull)); // destructive
> +        } catch (NullPointerException optional) {
> +        }
> +    }
> +
>      protected void setUp() {
>      }
>  
> 
> Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/
> common/org/apache/harmony/luni/tests/java/util/EnumSetTest.java
> URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/mo
> dules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/EnumSe
> tTest.java?rev=889068&r1=889067&r2=889068&view=diff
> =============================================================================
> =
> --- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common
> /org/apache/harmony/luni/tests/java/util/EnumSetTest.java (original)
> +++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common
> /org/apache/harmony/luni/tests/java/util/EnumSetTest.java Thu Dec 10 03:22:37
>  2009
> @@ -137,6 +137,25 @@
>          }
>      }
>  
> +    public void testRemoveIteratorRemoveFromHugeEnumSet() {
> +        EnumSet<HugeEnumCount> set = EnumSet.noneOf(HugeEnumCount.class);
> +        set.add(HugeEnumCount.NO64);
> +        set.add(HugeEnumCount.NO65);
> +        set.add(HugeEnumCount.NO128);
> +        Iterator<HugeEnumCount> iterator = set.iterator();
> +        assertTrue(iterator.hasNext());
> +        assertEquals(HugeEnumCount.NO64, iterator.next());
> +        assertTrue(iterator.hasNext());
> +        iterator.remove();
> +        assertEquals(HugeEnumCount.NO65, iterator.next());
> +        assertTrue(iterator.hasNext());
> +        assertEquals(HugeEnumCount.NO128, iterator.next());
> +        assertFalse(iterator.hasNext());
> +        assertEquals(EnumSet.of(HugeEnumCount.NO65, HugeEnumCount.NO128), se
> t);
> +        iterator.remove();
> +        assertEquals(EnumSet.of(HugeEnumCount.NO65), set);
> +    }
> +
>      /**
>       * @tests java.util.EnumSet#allOf(java.lang.Class)
>       */
> @@ -1220,21 +1239,21 @@
>          Set<EnumWithInnerClass> setWithInnerClass = EnumSet
>                  .allOf(EnumWithInnerClass.class);
>          result = set.retainAll(setWithInnerClass);
> -        assertTrue("Should return true", result); //$NON-NLS-1$
> +        assertFalse("Should return false", result); //$NON-NLS-1$
>          assertEquals("Size of set should be 0", 0, set.size()); //$NON-NLS-1
> $
>  
>          setWithInnerClass = EnumSet.noneOf(EnumWithInnerClass.class);
>          result = set.retainAll(setWithInnerClass);
> -        assertTrue("Should return true", result); //$NON-NLS-1$
> +        assertFalse("Should return false", result); //$NON-NLS-1$
>  
>          Set<EmptyEnum> emptySet = EnumSet.allOf(EmptyEnum.class);
>          result = set.retainAll(emptySet);
> -        assertTrue("Should return true", result); //$NON-NLS-1$
> +        assertFalse("Should return false", result); //$NON-NLS-1$
>  
>          Set<EnumWithAllInnerClass> setWithAllInnerClass = EnumSet
>                  .allOf(EnumWithAllInnerClass.class);
>          result = set.retainAll(setWithAllInnerClass);
> -        assertTrue("Should return true", result); //$NON-NLS-1$
> +        assertFalse("Should return false", result); //$NON-NLS-1$
>  
>          set.add(EnumFoo.a);
>          result = set.retainAll(setWithInnerClass);
> @@ -1314,17 +1333,17 @@
>          Set<HugeEnumWithInnerClass> hugeSetWithInnerClass = EnumSet
>                  .allOf(HugeEnumWithInnerClass.class);
>          result = hugeSet.retainAll(hugeSetWithInnerClass);
> -        assertTrue(result);
> +        assertFalse(result);
>          assertEquals(0, hugeSet.size());
>  
>          hugeSetWithInnerClass = EnumSet.noneOf(HugeEnumWithInnerClass.class)
> ;
>          result = hugeSet.retainAll(hugeSetWithInnerClass);
> -        assertTrue(result);
> +        assertFalse(result);
>  
>          Set<HugeEnumWithInnerClass> hugeSetWithAllInnerClass = EnumSet
>                  .allOf(HugeEnumWithInnerClass.class);
>          result = hugeSet.retainAll(hugeSetWithAllInnerClass);
> -        assertTrue(result);
> +        assertFalse(result);
>  
>          hugeSet.add(HugeEnum.a);
>          result = hugeSet.retainAll(hugeSetWithInnerClass);
> 
> Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/
> unix/org/apache/harmony/luni/tests/java/io/UnixFileTest.java
> URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/mo
> dules/luni/src/test/api/unix/org/apache/harmony/luni/tests/java/io/UnixFileTe
> st.java?rev=889068&r1=889067&r2=889068&view=diff
> =============================================================================
> =
> --- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/unix/o
> rg/apache/harmony/luni/tests/java/io/UnixFileTest.java (original)
> +++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/unix/o
> rg/apache/harmony/luni/tests/java/io/UnixFileTest.java Thu Dec 10 03:22:37 20
> 09
> @@ -368,7 +368,8 @@
>  		super.tearDown();
>  	}
>  
> -    public void test_getCanonicalPath() throws IOException {
> +    public void test_getCanonicalPath() throws IOException,
> +                                               InterruptedException {
>          File tmpFolder1 = new File("folder1");
>          tmpFolder1.mkdirs();
>          tmpFolder1.deleteOnExit();
> @@ -386,7 +387,8 @@
>          tmpFolder4.deleteOnExit();
>  
>          // make a link to folder1/folder2
> -        Runtime.getRuntime().exec("ln -s folder1/folder2 folder2");
> +        Process ln = Runtime.getRuntime().exec("ln -s folder1/folder2 folder
> 2");
> +        ln.waitFor();
>          File linkFile = new File("folder2");
>          linkFile.deleteOnExit();
>  
> 
> Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/re
> sources/net.resources/
> -----------------------------------------------------------------------------
> -
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Thu Dec 10 03:22:37 2009
> @@ -1 +1 @@
> -/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/net.resourc
> es:790472-885602
> +/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/net.resourc
> es:790472-889062
> 
> Propchange: harmony/enhanced/classlib/branches/java6/modules/pack200/depends/
> manifests/asm-3.1/
> -----------------------------------------------------------------------------
> -
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Thu Dec 10 03:22:37 2009
> @@ -1 +1 @@
> -/harmony/enhanced/classlib/trunk/modules/pack200/depends/manifests/asm-3.1:7
> 85554-885602
> +/harmony/enhanced/classlib/trunk/modules/pack200/depends/manifests/asm-3.1:7
> 85554-889062
> 
> Propchange: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main
> /java5/org/apache/harmony/pack200/Pack200Adapter.java
> -----------------------------------------------------------------------------
> -
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Thu Dec 10 03:22:37 2009
> @@ -1 +1 @@
> -/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java5/org/apache/h
> armony/pack200/Pack200Adapter.java:782694-885602
> +/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java5/org/apache/h
> armony/pack200/Pack200Adapter.java:782694-889062
> 
> Propchange: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main
> /java5/org/apache/harmony/pack200/Pack200PackerAdapter.java
> -----------------------------------------------------------------------------
> -
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Thu Dec 10 03:22:37 2009
> @@ -1 +1 @@
> -/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java5/org/apache/h
> armony/pack200/Pack200PackerAdapter.java:782694-885602
> +/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java5/org/apache/h
> armony/pack200/Pack200PackerAdapter.java:782694-889062
> 
> Modified: harmony/enhanced/classlib/branches/java6/modules/rmi/META-INF/MANIF
> EST.MF
> URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/mo
> dules/rmi/META-INF/MANIFEST.MF?rev=889068&r1=889067&r2=889068&view=diff
> =============================================================================
> =
> --- harmony/enhanced/classlib/branches/java6/modules/rmi/META-INF/MANIFEST.MF
>  (original)
> +++ harmony/enhanced/classlib/branches/java6/modules/rmi/META-INF/MANIFEST.MF
>  Thu Dec 10 03:22:37 2009
> @@ -23,6 +23,7 @@
>   javax.net,
>   javax.net.ssl,
>   org.apache.harmony.kernel.vm,
> + org.apache.harmony.luni.util,
>   org.apache.harmony.testframework.serialization;hy_usage=test;resolution:=op
> tional
>  Export-Package: java.rmi,
>   java.rmi.activation,
>