Merge change Iccd6c010

* changes:
  Make the traige process for self-verification found divergence easier.
diff --git a/libcore/archive/src/main/java/java/util/zip/Deflater.java b/libcore/archive/src/main/java/java/util/zip/Deflater.java
index ad17cf2..48ae479 100644
--- a/libcore/archive/src/main/java/java/util/zip/Deflater.java
+++ b/libcore/archive/src/main/java/java/util/zip/Deflater.java
@@ -203,6 +203,10 @@
      * methods will typically throw an {@code IllegalStateException}.
      */
     public synchronized void end() {
+        endImpl();
+    }
+
+    private void endImpl() {
         if (streamHandle != -1) {
             endImpl(streamHandle);
             inputBuffer = null;
@@ -212,7 +216,10 @@
 
     @Override
     protected void finalize() {
-        end();
+        synchronized (this) {
+            end(); // to allow overriding classes to clean up
+            endImpl(); // in case those classes don't call super.end()
+        }
     }
 
     /**
diff --git a/libcore/icu/src/main/java/com/ibm/icu4jni/util/Resources.java b/libcore/icu/src/main/java/com/ibm/icu4jni/util/Resources.java
index 0460fde..086f8d4 100644
--- a/libcore/icu/src/main/java/com/ibm/icu4jni/util/Resources.java
+++ b/libcore/icu/src/main/java/com/ibm/icu4jni/util/Resources.java
@@ -114,7 +114,7 @@
             isoLanguages = getISOLanguagesNative();
         }
 
-        return isoLanguages;
+        return isoLanguages.clone();
     }
 
     /**
@@ -128,7 +128,7 @@
             isoCountries = getISOCountriesNative();
         }
 
-        return isoCountries;
+        return isoCountries.clone();
     }
 
     /**
@@ -142,7 +142,7 @@
             availableLocales = getAvailableLocalesNative();
         }
 
-        return availableLocales;
+        return availableLocales.clone();
     }
 
     /**
@@ -157,7 +157,7 @@
             availableTimezones = TimeZone.getAvailableIDs();
         }
 
-        return availableTimezones;
+        return availableTimezones.clone();
     }
 
     /**
@@ -264,17 +264,25 @@
         if (locale == null) {
             locale = defaultLocale;
         }
-
+        
         // If locale == default and the default locale hasn't changed since
         // DefaultTimeZones loaded, return the cached names.
         // TODO: We should force a reboot if the default locale changes.
         if (defaultLocale.equals(locale) && DefaultTimeZones.locale.equals(defaultLocale)) {
-            return DefaultTimeZones.names;
+            return clone2dStringArray(DefaultTimeZones.names);
         }
         
         return createTimeZoneNamesFor(locale);
     }
 
+    private static String[][] clone2dStringArray(String[][] array) {
+        String[][] result = new String[array.length][];
+        for (int i = 0; i < array.length; ++i) {
+            result[i] = array[i].clone();
+        }
+        return result;
+    }
+
     // --- Specialized ResourceBundle subclasses ------------------------------
 
     /**
diff --git a/libcore/icu/src/test/java/com/ibm/icu4jni/util/AllTests.java b/libcore/icu/src/test/java/com/ibm/icu4jni/util/AllTests.java
new file mode 100644
index 0000000..1b95075
--- /dev/null
+++ b/libcore/icu/src/test/java/com/ibm/icu4jni/util/AllTests.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ibm.icu4jni.util;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+    public static final Test suite() {
+        TestSuite suite = tests.TestSuiteFactory.createTestSuite();
+        suite.addTestSuite(com.ibm.icu4jni.util.ResourcesTest.class);
+        return suite;
+    }
+}
diff --git a/libcore/icu/src/test/java/com/ibm/icu4jni/util/ResourcesTest.java b/libcore/icu/src/test/java/com/ibm/icu4jni/util/ResourcesTest.java
new file mode 100644
index 0000000..4112d0b
--- /dev/null
+++ b/libcore/icu/src/test/java/com/ibm/icu4jni/util/ResourcesTest.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ibm.icu4jni.util;
+
+public class ResourcesTest extends junit.framework.TestCase {
+    public void test_getISOLanguages() throws Exception {
+        // Check that corrupting our array doesn't affect other callers.
+        assertNotNull(Resources.getISOLanguages()[0]);
+        Resources.getISOLanguages()[0] = null;
+        assertNotNull(Resources.getISOLanguages()[0]);
+    }
+
+    public void test_getISOCountries() throws Exception {
+        // Check that corrupting our array doesn't affect other callers.
+        assertNotNull(Resources.getISOCountries()[0]);
+        Resources.getISOCountries()[0] = null;
+        assertNotNull(Resources.getISOCountries()[0]);
+    }
+
+    public void test_getAvailableLocales() throws Exception {
+        // Check that corrupting our array doesn't affect other callers.
+        assertNotNull(Resources.getAvailableLocales()[0]);
+        Resources.getAvailableLocales()[0] = null;
+        assertNotNull(Resources.getAvailableLocales()[0]);
+    }
+
+    public void test_getKnownTimezones() throws Exception {
+        // Check that corrupting our array doesn't affect other callers.
+        assertNotNull(Resources.getKnownTimezones()[0]);
+        Resources.getKnownTimezones()[0] = null;
+        assertNotNull(Resources.getKnownTimezones()[0]);
+    }
+
+    public void test_getDisplayTimeZones() throws Exception {
+        // Check that corrupting our array doesn't affect other callers.
+        assertNotNull(Resources.getDisplayTimeZones(null)[0]);
+        Resources.getDisplayTimeZones(null)[0] = null;
+        assertNotNull(Resources.getDisplayTimeZones(null)[0]);
+        // getDisplayTimezones actually returns a String[][] rather than a String[].
+        assertNotNull(Resources.getDisplayTimeZones(null)[0][0]);
+        Resources.getDisplayTimeZones(null)[0][0] = null;
+        assertNotNull(Resources.getDisplayTimeZones(null)[0][0]);
+    }
+}
diff --git a/libcore/luni/src/test/java/tests/AllTests.java b/libcore/luni/src/test/java/tests/AllTests.java
index 3a38c5f..7533eea 100644
--- a/libcore/luni/src/test/java/tests/AllTests.java
+++ b/libcore/luni/src/test/java/tests/AllTests.java
@@ -32,6 +32,7 @@
     public static final Test suite() {
         TestSuite suite = tests.TestSuiteFactory.createTestSuite();
         
+        // Harmony-written test suites (often with Android tests added in).
         suite.addTest(tests.annotation.AllTests.suite());
         suite.addTest(tests.archive.AllTests.suite());
         suite.addTest(tests.concurrent.AllTests.suite());
@@ -53,10 +54,12 @@
         suite.addTest(tests.text.AllTests.suite());
         suite.addTest(tests.xml.AllTests.suite());
         suite.addTest(tests.xnet.AllTests.suite());
-
-        suite.addTest(tests.api.org.apache.harmony.kernel.dalvik.AllTests.suite());
+        
+        // Android-written test suites.
+        suite.addTest(com.ibm.icu4jni.util.AllTests.suite());
         suite.addTest(java.lang.reflect.AllTests.suite());
         suite.addTest(org.apache.harmony.luni.platform.AllTests.suite());
+        suite.addTest(tests.api.org.apache.harmony.kernel.dalvik.AllTests.suite());
         
         return suite;
     }
diff --git a/vm/Sync.c b/vm/Sync.c
index 1f81349..8528c0f 100644
--- a/vm/Sync.c
+++ b/vm/Sync.c
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 /*
  * Fundamental synchronization mechanisms.
  *
@@ -985,8 +986,10 @@
         LOG_THIN("(%d) lock 0x%08x fattened by wait() to count %d\n",
                  self->threadId, (uint)&obj->lock, mon->lockCount);
 
+
         /* Make the monitor public now that it's in the right state.
          */
+        MEM_BARRIER();
         obj->lock.mon = mon;
     }