Merge change Ic4433c3d

* changes:
  Jit: Update monitor lock/unlock to reflect thinlock changes (I34b20f49)
diff --git a/libcore/icu/src/main/native/ResourceInterface.cpp b/libcore/icu/src/main/native/ResourceInterface.cpp
index c0fedbf..abb00a0 100644
--- a/libcore/icu/src/main/native/ResourceInterface.cpp
+++ b/libcore/icu/src/main/native/ResourceInterface.cpp
@@ -122,15 +122,16 @@
         return env->NewStringUTF("None");
     }
 
-    // check if there is a to date. If there is, the currency isn't used anymore.
-    {
-        ScopedResourceBundle currencyTo(ures_getByKey(currencyElem.get(), "to", NULL, &status));
-        if (!U_FAILURE(status)) {
-            // return and let the ResourceBundle throw an exception
-            return NULL;
-        }
-        status = U_ZERO_ERROR;
+    // check if there is a 'to' date. If there is, the currency isn't used anymore.
+    ScopedResourceBundle currencyTo(ures_getByKey(currencyElem.get(), "to", NULL, &status));
+    if (!U_FAILURE(status)) {
+        // return and let the caller throw an exception
+        return NULL;
     }
+    // We need to reset 'status'. It works like errno in that ICU doesn't set it
+    // to U_ZERO_ERROR on success: it only touches it on error, and the test
+    // above means it now holds a failure code.
+    status = U_ZERO_ERROR;
 
     ScopedResourceBundle currencyId(ures_getByKey(currencyElem.get(), "id", NULL, &status));
     if (U_FAILURE(status)) {
@@ -255,54 +256,39 @@
     return result;
 }
 
+static TimeZone* timeZoneFromId(JNIEnv* env, jstring id) {
+    const jchar* chars = env->GetStringChars(id, NULL);
+    const UnicodeString zoneID(reinterpret_cast<const UChar*>(chars), env->GetStringLength(id));
+    env->ReleaseStringChars(id, chars);
+    return TimeZone::createTimeZone(zoneID);
+}
+
 static void getTimeZonesNative(JNIEnv* env, jclass clazz,
         jobjectArray outerArray, jstring locale) {
-    // LOGI("ENTER getTimeZonesNative");
-    
-    UErrorCode status = U_ZERO_ERROR;
-
-    jobjectArray zoneIdArray;
-    jobjectArray longStdTimeArray;
-    jobjectArray shortStdTimeArray;
-    jobjectArray longDlTimeArray;
-    jobjectArray shortDlTimeArray;
-
-    jstring content;
-    jstring strObj;
-    const jchar* res;
-    UnicodeString resU;
-    jint length;
-    const UnicodeString* zoneID;
-    DateFormat* df;
-
-    UnicodeString longPattern("zzzz","");
-    UnicodeString shortPattern("z","");
-      
-    Locale loc = getLocale(env, locale);
-
-    SimpleDateFormat longFormat(longPattern, loc, status);
-    SimpleDateFormat shortFormat(shortPattern, loc, status);
-
-
-    zoneIdArray = (jobjectArray) env->GetObjectArrayElement(outerArray, 0);
-    longStdTimeArray = (jobjectArray) env->GetObjectArrayElement(outerArray, 1);
-    shortStdTimeArray = (jobjectArray) env->GetObjectArrayElement(outerArray, 2);
-    longDlTimeArray = (jobjectArray) env->GetObjectArrayElement(outerArray, 3);
-    shortDlTimeArray = (jobjectArray) env->GetObjectArrayElement(outerArray, 4);
 
     // get all timezone objects
+    jobjectArray zoneIdArray = (jobjectArray) env->GetObjectArrayElement(outerArray, 0);
     int count = env->GetArrayLength(zoneIdArray);
     TimeZone* zones[count];
     for(int i = 0; i < count; i++) {
-        strObj = (jstring) env->GetObjectArrayElement(zoneIdArray, i);
-        length = env->GetStringLength(strObj);
-        res = env->GetStringChars(strObj, NULL);
-        const UnicodeString zoneID((UChar*)res, length);
-        env->ReleaseStringChars(strObj, res);
-        zones[i] = TimeZone::createTimeZone(zoneID);
-        env->DeleteLocalRef(strObj);
+        jstring id = (jstring) env->GetObjectArrayElement(zoneIdArray, i);
+        zones[i] = timeZoneFromId(env, id);
+        env->DeleteLocalRef(id);
     }
 
+    Locale loc = getLocale(env, locale);
+
+    UErrorCode status = U_ZERO_ERROR;
+    UnicodeString longPattern("zzzz","");
+    SimpleDateFormat longFormat(longPattern, loc, status);
+    UnicodeString shortPattern("z","");
+    SimpleDateFormat shortFormat(shortPattern, loc, status);
+
+    jobjectArray longStdTimeArray = (jobjectArray) env->GetObjectArrayElement(outerArray, 1);
+    jobjectArray shortStdTimeArray = (jobjectArray) env->GetObjectArrayElement(outerArray, 2);
+    jobjectArray longDlTimeArray = (jobjectArray) env->GetObjectArrayElement(outerArray, 3);
+    jobjectArray shortDlTimeArray = (jobjectArray) env->GetObjectArrayElement(outerArray, 4);
+
     // 15th January 2008
     UDate date1 = 1203105600000.0;
     // 15th July 2008
@@ -331,7 +317,7 @@
 
         UnicodeString str;
         shortFormat.format(daylightSavingDate, str);
-        content = env->NewString(str.getBuffer(), str.length());
+        jstring content = env->NewString(str.getBuffer(), str.length());
         env->SetObjectArrayElement(shortDlTimeArray, i, content);
         env->DeleteLocalRef(content);
 
@@ -355,16 +341,10 @@
 }
 
 static jstring getDisplayTimeZoneNative(JNIEnv* env, jclass clazz,
-        jstring zoneID, jboolean isDST, jint style, jstring localeID) {
+        jstring zoneId, jboolean isDST, jint style, jstring localeId) {
 
-    // Build TimeZone object
-    const jchar* idChars = env->GetStringChars(zoneID, NULL);
-    jint idLength = env->GetStringLength(zoneID);
-    UnicodeString idString((UChar*)idChars, idLength);
-    TimeZone* zone = TimeZone::createTimeZone(idString);
-    env->ReleaseStringChars(zoneID, idChars);
-
-    Locale locale = getLocale(env, localeID);
+    TimeZone* zone = timeZoneFromId(env, zoneId);
+    Locale locale = getLocale(env, localeId);
 
     // Try to get the display name of the TimeZone according to the Locale
     UnicodeString displayName;
@@ -617,7 +597,6 @@
     jobject minimalDaysInFirstWeek = NULL;
     jobjectArray amPmMarkers = NULL;
     jobjectArray eras = NULL;
-    jstring localPatternChars = NULL;
     jobjectArray weekdays = NULL;
     jobjectArray shortWeekdays = NULL;
     jobjectArray months = NULL;
@@ -695,12 +674,6 @@
     }
 
 
-    // local pattern chars are initially always the same
-    localPatternChars = env->NewStringUTF("GyMdkHmsSEDFwWahKzZ");
-    // adding local pattern chars string to the result
-    counter++;
-
-
     // adding month names string array to the result
     months = getLongMonthNames(env, gregorian);
     if(months != NULL) {
@@ -967,9 +940,6 @@
     if(eras != NULL && index < counter) {
         addObject(env, result, "eras", eras, index++);
     }
-    if(localPatternChars != NULL && index < counter) {
-        addObject(env, result, "LocalPatternChars", localPatternChars, index++);
-    }
     if(weekdays != NULL && index < counter) {
         addObject(env, result, "weekdays", weekdays, index++);
     }
diff --git a/libcore/luni/src/test/java/tests/api/java/io/PrintStreamTest.java b/libcore/luni/src/test/java/tests/api/java/io/PrintStreamTest.java
index a249b38..fed1aed 100644
--- a/libcore/luni/src/test/java/tests/api/java/io/PrintStreamTest.java
+++ b/libcore/luni/src/test/java/tests/api/java/io/PrintStreamTest.java
@@ -29,11 +29,12 @@
 import java.util.IllegalFormatException;
 import java.util.Locale;
 
-import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass;
 import dalvik.annotation.TestTargetNew;
 
+import tests.support.Support_Locale;
+
 @TestTargetClass(PrintStream.class) 
 public class PrintStreamTest extends junit.framework.TestCase {
 
@@ -988,6 +989,11 @@
         args = {java.util.Locale.class, java.lang.String.class, java.lang.Object[].class}
     )
     public void test_formatLjava_util_Locale_Ljava_lang_String_$Ljava_lang_Object() {
+        Locale[] requiredLocales = {Locale.US, Locale.GERMANY};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         PrintStream tobj;
 
         tobj = new PrintStream(baos, false);
@@ -1100,6 +1106,11 @@
         args = {java.util.Locale.class, java.lang.String.class, java.lang.Object[].class}
     )
     public void test_printfLjava_util_Locale_Ljava_lang_String_$Ljava_lang_Object() {
+        Locale[] requiredLocales = {Locale.US, Locale.GERMANY};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         PrintStream tobj;
 
         tobj = new PrintStream(baos, false);
diff --git a/libcore/luni/src/test/java/tests/api/java/io/PrintWriterTest.java b/libcore/luni/src/test/java/tests/api/java/io/PrintWriterTest.java
index 0c17a73..59d83eb 100644
--- a/libcore/luni/src/test/java/tests/api/java/io/PrintWriterTest.java
+++ b/libcore/luni/src/test/java/tests/api/java/io/PrintWriterTest.java
@@ -29,9 +29,9 @@
 import java.util.IllegalFormatException;
 import java.util.Locale;
 
+import tests.support.Support_Locale;
 import tests.support.Support_StringReader;
 import tests.support.Support_StringWriter;
-import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass;
 import dalvik.annotation.TestTargetNew;
@@ -1108,6 +1108,11 @@
         args = {java.util.Locale.class, java.lang.String.class, java.lang.Object[].class}
     )
     public void test_formatLjava_util_Locale_Ljava_lang_String_$Ljava_lang_Object() {
+        Locale[] requiredLocales = {Locale.US, Locale.GERMANY};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         PrintWriter tobj;
 
         tobj = new PrintWriter(baos, false);
@@ -1219,6 +1224,11 @@
         args = {java.util.Locale.class, java.lang.String.class, java.lang.Object[].class}
     )
     public void test_printfLjava_util_Locale_Ljava_lang_String_$Ljava_lang_Object() {
+        Locale[] requiredLocales = {Locale.US, Locale.GERMANY};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         PrintWriter tobj;
 
         tobj = new PrintWriter(baos, false);
diff --git a/libcore/luni/src/test/java/tests/api/java/util/CalendarTest.java b/libcore/luni/src/test/java/tests/api/java/util/CalendarTest.java
index 285fa56..cc0f91a 100644
--- a/libcore/luni/src/test/java/tests/api/java/util/CalendarTest.java
+++ b/libcore/luni/src/test/java/tests/api/java/util/CalendarTest.java
@@ -17,11 +17,11 @@
 
 package tests.api.java.util;
 
-import dalvik.annotation.KnownFailure;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargets;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetClass; 
+import tests.support.Support_Locale;
 
 import java.util.Calendar;
 import java.util.Date;
@@ -901,6 +901,11 @@
         )
     })
     public void test_getFirstDayOfWeek() {
+        Locale[] requiredLocales = {Locale.US, Locale.FRANCE};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         Calendar cal = Calendar.getInstance();
 
         assertEquals(Calendar.SUNDAY, cal.getFirstDayOfWeek());
@@ -917,6 +922,11 @@
         args = {java.util.Locale.class}
     )
     public void test_getInstanceLjava_util_Locale() {
+        Locale[] requiredLocales = {Locale.US, Locale.FRANCE};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         Calendar cal1 = Calendar.getInstance(Locale.FRANCE);
         Locale.setDefault(Locale.FRANCE);
         Calendar cal2 = Calendar.getInstance();
@@ -945,6 +955,11 @@
         args = {java.util.TimeZone.class, java.util.Locale.class}
     )
     public void test_getInstanceLjava_util_TimeZoneLjava_util_Locale() {
+        Locale[] requiredLocales = {Locale.US, Locale.FRANCE};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         Calendar cal1 = Calendar.getInstance(TimeZone.getTimeZone("GMT-6"), Locale.FRANCE);
         Locale.setDefault(Locale.FRANCE);
         Calendar cal2 = Calendar.getInstance(TimeZone.getTimeZone("GMT+1"));
@@ -963,6 +978,11 @@
         args = {}
     )
     public void test_getMinimalDaysInFirstWeek() {
+        Locale[] requiredLocales = {Locale.US, Locale.FRANCE};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         Calendar cal = Calendar.getInstance();
         assertTrue(cal.getMinimalDaysInFirstWeek()==1);
         Locale.setDefault(Locale.FRANCE);
@@ -1008,6 +1028,11 @@
         args = {}
     )
     public void test_hashCode() {
+        Locale[] requiredLocales = {Locale.US, Locale.FRANCE};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         Calendar cal1 = Calendar.getInstance();
         Locale.setDefault(Locale.FRANCE);
         Calendar cal2 = Calendar.getInstance();
diff --git a/libcore/luni/src/test/java/tests/api/java/util/CurrencyTest.java b/libcore/luni/src/test/java/tests/api/java/util/CurrencyTest.java
index 14068a3..1bf1f31 100644
--- a/libcore/luni/src/test/java/tests/api/java/util/CurrencyTest.java
+++ b/libcore/luni/src/test/java/tests/api/java/util/CurrencyTest.java
@@ -17,6 +17,7 @@
 
 package tests.api.java.util;
 
+import tests.support.Support_Locale;
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass; 
@@ -225,6 +226,10 @@
 
                 new Locale("da", ""), new Locale("ja", ""),
                 new Locale("en", "")};
+        if (!Support_Locale.areLocalesAvailable(loc1)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
                 
         String[] euro    = new String[] {"EUR", "\u20ac"};
         // \u00a5 and \uffe5 are actually the same symbol, just different code points.
diff --git a/libcore/luni/src/test/java/tests/api/java/util/FormatterTest.java b/libcore/luni/src/test/java/tests/api/java/util/FormatterTest.java
index 9f1d399..fb03a34 100644
--- a/libcore/luni/src/test/java/tests/api/java/util/FormatterTest.java
+++ b/libcore/luni/src/test/java/tests/api/java/util/FormatterTest.java
@@ -15,6 +15,8 @@
  */
 package tests.api.java.util;
 
+import tests.support.Support_Locale;
+
 import java.io.BufferedOutputStream;
 import java.io.Closeable;
 import java.io.File;
@@ -1803,6 +1805,11 @@
         args = {java.lang.String.class, java.lang.Object[].class}
     )
     public void test_formatLjava_lang_String$Ljava_lang_Object_ByteShortIntegerLongConversionD() {
+        Locale[] requiredLocales = {Locale.GERMAN};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         final Object[][] triple = { 
                 { 0,                "%d",                  "0" }, 
                 { 0,                "%10d",       "         0" }, 
@@ -2067,6 +2074,11 @@
     )
     @AndroidOnly("ICU data is different from RI data")
     public void test_formatLjava_lang_String$Ljava_lang_Object_DateTimeConversion() {
+        Locale[] requiredLocales = {Locale.FRANCE, Locale.CHINA, Locale.GERMAN, Locale.US};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         /*
          * Implementation note: For a millisecond date based on Long.MAX_VALUE,
          * the RI produces different formatted minutes and seconds than we do.
@@ -2844,6 +2856,11 @@
         args = {java.lang.String.class, java.lang.Object[].class}
     )
     public void test_formatLjava_lang_String$LBigInteger() {
+        Locale[] requiredLocales = {Locale.ITALY, Locale.GERMAN, Locale.FRANCE};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         final Object[][] tripleD = {
                 {new BigInteger("123456789012345678901234567890"),          "%d",       "123456789012345678901234567890"}, //$NON-NLS-2$
                 {new BigInteger("123456789012345678901234567890"),          "%10d",     "123456789012345678901234567890"}, //$NON-NLS-2$
@@ -2946,6 +2963,11 @@
         args = {java.lang.String.class, java.lang.Object[].class}
     )
     public void test_formatLjava_lang_String$Ljava_lang_Object_BigIntegerPaddingConversion() {
+        Locale[] requiredLocales = {Locale.GERMAN};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         Formatter f = null;
 
         BigInteger bigInt = new BigInteger("123456789012345678901234567890");
@@ -4650,6 +4672,11 @@
         args = {java.util.Locale.class, java.lang.String.class, java.lang.Object[].class}
     )
     public void test_formatLjava_util_LocaleLjava_lang_StringLjava_lang_Object() {
+        Locale[] requiredLocales = {Locale.GERMAN, Locale.FRANCE, Locale.US, Locale.CANADA};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         Double val = new Double(3.14);
         Calendar cal = Calendar.getInstance();
         Formatter fLoc = null;
diff --git a/libcore/luni/src/test/java/tests/api/java/util/GregorianCalendarTest.java b/libcore/luni/src/test/java/tests/api/java/util/GregorianCalendarTest.java
index 6d2ef74..aba02a5 100644
--- a/libcore/luni/src/test/java/tests/api/java/util/GregorianCalendarTest.java
+++ b/libcore/luni/src/test/java/tests/api/java/util/GregorianCalendarTest.java
@@ -22,6 +22,7 @@
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass; 
 import dalvik.annotation.KnownFailure;
+import tests.support.Support_Locale;
 
 import java.util.BitSet;
 import java.util.Calendar;
@@ -149,6 +150,11 @@
         args = {java.util.Locale.class}
     )
     public void test_ConstructorLjava_util_Locale() {
+        Locale[] requiredLocales = {Locale.US, Locale.FRANCE};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         // Test for method java.util.GregorianCalendar(java.util.Locale)
         Date date = new Date();
         GregorianCalendar gcUS = new GregorianCalendar(Locale.US);
diff --git a/libcore/luni/src/test/java/tests/api/java/util/LocaleTest.java b/libcore/luni/src/test/java/tests/api/java/util/LocaleTest.java
index 0362d4b..fdd3d5e 100644
--- a/libcore/luni/src/test/java/tests/api/java/util/LocaleTest.java
+++ b/libcore/luni/src/test/java/tests/api/java/util/LocaleTest.java
@@ -17,12 +17,12 @@
 
 package tests.api.java.util;
 
-import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass; 
 import dalvik.annotation.AndroidOnly;
+import tests.support.Support_Locale;
 
 import java.security.Permission;
 import java.util.Arrays;
@@ -259,6 +259,11 @@
         args = {java.util.Locale.class}
     )
     public void test_getDisplayCountryLjava_util_Locale() {
+        Locale[] requiredLocales = {Locale.ITALY};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         // Test for method java.lang.String
         // java.util.Locale.getDisplayCountry(java.util.Locale)
         assertEquals("Returned incorrect country", "Italie", Locale.ITALY
@@ -296,6 +301,11 @@
         args = {java.util.Locale.class}
     )
     public void test_getDisplayLanguageLjava_util_Locale() {
+        Locale[] requiredLocales = {testLocale};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         // Test for method java.lang.String
         // java.util.Locale.getDisplayLanguage(java.util.Locale)
         assertTrue("Returned incorrect language: "
@@ -328,6 +338,11 @@
         args = {java.util.Locale.class}
     )
     public void test_getDisplayNameLjava_util_Locale() {
+        Locale[] requiredLocales = {testLocale};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         // Test for method java.lang.String
         // java.util.Locale.getDisplayName(java.util.Locale)
         assertTrue("Returned incorrect name: " + testLocale.getDisplayName(l),
diff --git a/libcore/luni/src/test/java/tests/api/java/util/ScannerTest.java b/libcore/luni/src/test/java/tests/api/java/util/ScannerTest.java
index ce35005..6e7f1d4 100644
--- a/libcore/luni/src/test/java/tests/api/java/util/ScannerTest.java
+++ b/libcore/luni/src/test/java/tests/api/java/util/ScannerTest.java
@@ -51,6 +51,7 @@
 import java.util.regex.MatchResult;
 import java.util.regex.Pattern;
 
+import tests.support.Support_Locale;
 import tests.support.Support_PortManager;
 
 import junit.framework.TestCase;
@@ -1120,8 +1121,12 @@
         method = "nextInt",
         args = {int.class}
     )
-    @KnownFailure("Some locales were removed last minute in cupcake")
     public void test_nextIntI() throws IOException {
+        Locale[] requiredLocales = {Locale.GERMANY, Locale.ENGLISH, Locale.CHINESE};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         s = new Scanner("123 456");
         assertEquals(123, s.nextInt(10));
         assertEquals(456, s.nextInt(10));
@@ -1335,8 +1340,12 @@
         method = "nextInt",
         args = {}
     )
-    @KnownFailure("Some locales were removed last minute in cupcake")
     public void test_nextInt() throws IOException {
+        Locale[] requiredLocales = {Locale.GERMANY, Locale.CHINESE, Locale.ENGLISH};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         s = new Scanner("123 456");
         assertEquals(123, s.nextInt());
         assertEquals(456, s.nextInt());
@@ -1730,8 +1739,12 @@
         method = "nextFloat",
         args = {}
     )
-    @KnownFailure("Some locales were removed last minute in cupcake")
     public void test_nextFloat() throws IOException {
+        Locale[] requiredLocales = {Locale.ENGLISH, Locale.GERMANY};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         s = new Scanner("123 45\u0666. 123.4 .123 ");
         s.useLocale(Locale.ENGLISH);
         assertEquals((float)123.0, s.nextFloat());
@@ -2147,6 +2160,11 @@
         args = {int.class}
     )
     public void test_nextShortI() throws IOException {
+        Locale[] requiredLocales = {Locale.GERMANY, Locale.CHINESE, Locale.ENGLISH};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         s = new Scanner("123 456");
         assertEquals(123, s.nextShort(10));
         assertEquals(456, s.nextShort(10));
@@ -2304,6 +2322,11 @@
         args = {}
     )
     public void test_nextShort() throws IOException {
+        Locale[] requiredLocales = {Locale.GERMANY, Locale.CHINESE, Locale.ENGLISH};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         s = new Scanner("123 456");
         assertEquals(123, s.nextShort());
         assertEquals(456, s.nextShort());
@@ -2464,6 +2487,11 @@
         args = {int.class}
     )
     public void test_nextLongI() throws IOException {
+        Locale[] requiredLocales = {Locale.GERMANY, Locale.CHINESE, Locale.ENGLISH};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         s = new Scanner("123 456");
         assertEquals(123, s.nextLong(10));
         assertEquals(456, s.nextLong(10));
@@ -2621,6 +2649,11 @@
         args = {}
     )
     public void test_nextLong() throws IOException {
+        Locale[] requiredLocales = {Locale.GERMANY, Locale.CHINESE, Locale.ENGLISH};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         s = new Scanner("123 456");
         assertEquals(123, s.nextLong());
         assertEquals(456, s.nextLong());
@@ -3716,8 +3749,16 @@
         method = "hasNextInt",
         args = {int.class}
     )
-    @KnownFailure("Some locales were removed last minute in cupcake")
     public void test_hasNextIntI() throws IOException {
+        Locale mkLocale = new Locale("mk", "MK");
+        Locale arLocale = new Locale("ar", "AE");
+        Locale deLocale = new Locale("de", "CH");
+        Locale[] requiredLocales = {Locale.GERMANY, Locale.ENGLISH, Locale.CHINESE,
+                mkLocale, arLocale, deLocale};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         s = new Scanner("123 456");
         assertEquals(123, s.nextInt(10));
         assertTrue(s.hasNextInt(10));
@@ -3762,7 +3803,7 @@
         s = new Scanner("23'456");
         s.useLocale(Locale.GERMANY);
         assertFalse(s.hasNextInt(10));
-        s.useLocale(new Locale("de", "CH"));
+        s.useLocale(deLocale);
         // If exception is thrown out, input will not be advanced.
         assertTrue(s.hasNextInt(10));
 
@@ -3863,7 +3904,7 @@
          * by scanner with locale mk_MK. But this is not the case on RI.
          */
         s = new Scanner("-123 123- -123-");
-        s.useLocale(new Locale("ar", "AE"));
+        s.useLocale(arLocale);
         assertTrue(s.hasNextInt(10));
         assertEquals(-123, s.nextInt(10));
         // The following test case fails on RI
@@ -3880,7 +3921,7 @@
         }
 
         s = new Scanner("-123 123- (123)");
-        s.useLocale(new Locale("mk", "MK"));
+        s.useLocale(mkLocale);
         assertTrue(s.hasNextInt(10));
         assertEquals(-123, s.nextInt(10));
         assertFalse(s.hasNextInt(10));
@@ -3949,8 +3990,16 @@
         method = "hasNextInt",
         args = {}
     )
-    @KnownFailure("Some locales were removed last minute in cupcake")
     public void test_hasNextInt() throws IOException {
+        Locale mkLocale = new Locale("mk", "MK");
+        Locale arLocale = new Locale("ar", "AE");
+        Locale deLocale = new Locale("de", "CH");
+        Locale[] requiredLocales = {Locale.GERMANY, Locale.ENGLISH, Locale.CHINESE,
+                mkLocale, arLocale, deLocale};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         s = new Scanner("123 456");
         assertTrue(s.hasNextInt());
         assertEquals(123, s.nextInt());
@@ -3996,7 +4045,7 @@
         s = new Scanner("23'456");
         s.useLocale(Locale.GERMANY);
         assertFalse(s.hasNextInt());
-        s.useLocale(new Locale("de", "CH"));
+        s.useLocale(deLocale);
         assertTrue(s.hasNextInt());
 
         /*
@@ -4084,7 +4133,7 @@
          * by scanner with locale mk_MK. But this is not the case on RI.
          */
         s = new Scanner("-123 123- -123-");
-        s.useLocale(new Locale("ar", "AE"));
+        s.useLocale(arLocale);
         assertTrue(s.hasNextInt());
         assertEquals(-123, s.nextInt());
         // The following test case fails on RI
@@ -4101,7 +4150,7 @@
         }
 
         s = new Scanner("-123 123- (123)");
-        s.useLocale(new Locale("mk", "MK"));
+        s.useLocale(mkLocale);
         assertTrue(s.hasNextInt());
         assertEquals(-123, s.nextInt());
         try {
@@ -4137,8 +4186,14 @@
         method = "hasNextFloat",
         args = {}
     )
-    @KnownFailure("Some locales were removed last minute in cupcake")
     public void test_hasNextFloat() throws IOException {
+        Locale mkLocale = new Locale("mk", "MK");
+        Locale arLocale = new Locale("ar", "AE");
+        Locale[] requiredLocales = {Locale.GERMANY, Locale.ENGLISH, mkLocale, arLocale};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         s = new Scanner("123 45\u0666. 123.4 .123 ");
         s.useLocale(Locale.ENGLISH);
         assertTrue(s.hasNextFloat());
@@ -4225,7 +4280,7 @@
         assertEquals((float)23456.7, s.nextFloat());
 
         s = new Scanner("-123.4 123.4- -123.4-");
-        s.useLocale(new Locale("ar", "AE"));
+        s.useLocale(arLocale);
         assertTrue(s.hasNextFloat());
         assertEquals((float)-123.4, s.nextFloat());
         //The following test case fails on RI
@@ -4241,7 +4296,7 @@
         }
 
         s = new Scanner("(123) 123- -123");
-        s.useLocale(new Locale("mk", "MK"));
+        s.useLocale(mkLocale);
         if (!disableRIBugs) {
             assertTrue(s.hasNextFloat());
             assertEquals((float)-123.0, s.nextFloat());
@@ -4284,6 +4339,11 @@
         args = {int.class}
     )
     public void test_hasNextShortI() throws IOException {
+        Locale[] requiredLocales = {Locale.GERMANY, Locale.ENGLISH, Locale.CHINESE};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         s = new Scanner("123 456");
         assertTrue(s.hasNextShort(10));
         assertEquals(123, s.nextShort(10));
@@ -4460,6 +4520,15 @@
         args = {}
     )
     public void test_hasNextShort() throws IOException {
+        Locale deLocale = new Locale("de", "CH");
+        Locale arLocale = new Locale("ar", "AE");
+        Locale mkLocale = new Locale("mk", "MK");
+        Locale[] requiredLocales = {Locale.GERMANY, Locale.ENGLISH, Locale.CHINESE, deLocale,
+                arLocale, mkLocale};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         s = new Scanner("123 456");
         assertTrue(s.hasNextShort());
         assertEquals(123, s.nextShort());
@@ -4528,7 +4597,7 @@
         } catch (InputMismatchException e) {
             // Expected
         }
-        s.useLocale(new Locale("de", "CH"));
+        s.useLocale(deLocale);
         // If exception is thrown out, input will not be advanced.
         assertTrue(s.hasNextShort());
         assertEquals(23456, s.nextShort());
@@ -4617,12 +4686,12 @@
         assertEquals(12300, s.nextShort());
 
         s = new Scanner("-123");
-        s.useLocale(new Locale("ar", "AE"));
+        s.useLocale(arLocale);
         assertTrue(s.hasNextShort());
         assertEquals(-123, s.nextShort());
 
         s = new Scanner("-123");
-        s.useLocale(new Locale("mk", "MK"));
+        s.useLocale(mkLocale);
         assertTrue(s.hasNextShort());
         assertEquals(-123, s.nextShort());
         
@@ -4687,6 +4756,11 @@
         args = {int.class}
     )
     public void test_hasNextLongI() throws IOException {
+        Locale[] requiredLocales = {Locale.GERMANY, Locale.ENGLISH, Locale.CHINESE};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         s = new Scanner("123 456");
         assertTrue(s.hasNextLong(10));
         assertEquals(123, s.nextLong(10));
@@ -4904,6 +4978,15 @@
         args = {}
     )
     public void test_hasNextLong() throws IOException {
+        Locale deLocale = new Locale("de", "CH");
+        Locale arLocale = new Locale("ar", "AE");
+        Locale mkLocale = new Locale("mk", "MK");
+        Locale[] requiredLocales = {Locale.GERMANY, Locale.ENGLISH, Locale.CHINESE, deLocale,
+                arLocale, mkLocale};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         s = new Scanner("123 456");
         assertTrue(s.hasNextLong());
         assertEquals(123, s.nextLong());
@@ -4972,7 +5055,7 @@
         } catch (InputMismatchException e) {
             // Expected
         }
-        s.useLocale(new Locale("de", "CH"));
+        s.useLocale(deLocale);
         // If exception is thrown out, input will not be advanced.
         assertTrue(s.hasNextLong());
         assertEquals(23456, s.nextLong());
@@ -5061,12 +5144,12 @@
         assertEquals(12300, s.nextLong());
 
         s = new Scanner("-123");
-        s.useLocale(new Locale("ar", "AE"));
+        s.useLocale(arLocale);
         assertTrue(s.hasNextLong());
         assertEquals(-123, s.nextLong());
 
         s = new Scanner("-123");
-        s.useLocale(new Locale("mk", "MK"));
+        s.useLocale(mkLocale);
         assertTrue(s.hasNextLong());
         assertEquals(-123, s.nextLong());
         
@@ -5090,6 +5173,11 @@
         args = {}
     )
     public void test_hasNextDouble() throws IOException {
+        Locale[] requiredLocales = {Locale.GERMANY, Locale.ENGLISH};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         s = new Scanner("123 45\u0666. 123.4 .123 ");
         s.useLocale(Locale.ENGLISH);
         assertTrue(s.hasNextDouble());
@@ -5203,6 +5291,11 @@
         args = {}
     )
     public void test_hasNextBigDecimal() throws IOException {
+        Locale[] requiredLocales = {Locale.GERMANY, Locale.ENGLISH};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         s = new Scanner("123 45\u0666. 123.4 .123 ");
         s.useLocale(Locale.ENGLISH);
         assertTrue(s.hasNextBigDecimal());
@@ -6335,6 +6428,11 @@
         args = {}
     )
     public void test_nextDouble() throws IOException {
+        Locale[] requiredLocales = {Locale.GERMANY, Locale.ENGLISH};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         s = new Scanner("123 45\u0666. 123.4 .123 ");
         s.useLocale(Locale.ENGLISH);
         assertEquals(123.0, s.nextDouble());
@@ -6427,6 +6525,11 @@
         args = {}
     )
     public void test_nextBigDecimal() throws IOException {
+        Locale[] requiredLocales = {Locale.ENGLISH, Locale.GERMANY};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         s = new Scanner("123 45\u0666. 123.4 .123 ");
         s.useLocale(Locale.ENGLISH);
         assertEquals(new BigDecimal("123"), s.nextBigDecimal());
diff --git a/libcore/luni/src/test/java/tests/api/java/util/TimeZoneTest.java b/libcore/luni/src/test/java/tests/api/java/util/TimeZoneTest.java
index 86f5b9e..9b1d395 100644
--- a/libcore/luni/src/test/java/tests/api/java/util/TimeZoneTest.java
+++ b/libcore/luni/src/test/java/tests/api/java/util/TimeZoneTest.java
@@ -32,6 +32,7 @@
 import java.util.SimpleTimeZone;
 import java.util.TimeZone;
 
+import tests.support.Support_Locale;
 import tests.support.Support_TimeZone;
 
 @TestTargetClass(TimeZone.class) 
@@ -307,6 +308,11 @@
         args = {java.util.Locale.class}
     )
     public void test_getDisplayNameLjava_util_Locale() {
+        Locale[] requiredLocales = {Locale.US, Locale.FRANCE};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
         assertEquals("Pacific Standard Time", tz.getDisplayName(new Locale("US")));
         assertEquals("Heure normale du Pacifique", tz.getDisplayName(Locale.FRANCE));
@@ -333,6 +339,11 @@
     )
     @AndroidOnly("fail on RI. See comment below")
     public void test_getDisplayNameZILjava_util_Locale() {
+        Locale[] requiredLocales = {Locale.US, Locale.UK, Locale.FRANCE};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
         assertEquals("PST",                   tz.getDisplayName(false, 0, Locale.US));
         assertEquals("Pacific Daylight Time", tz.getDisplayName(true,  1, Locale.US));
diff --git a/libcore/support/src/test/java/tests/support/Support_Locale.java b/libcore/support/src/test/java/tests/support/Support_Locale.java
new file mode 100644
index 0000000..c5776cc
--- /dev/null
+++ b/libcore/support/src/test/java/tests/support/Support_Locale.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 tests.support;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
+
+/**
+ * Helper class for {@link Locale} tests
+ */
+public class Support_Locale {
+
+    /**
+     * Helper method to determine if given locales are available.
+     *
+     * @param requiredLocales - the set of {@link Locale} to check
+     *
+     * @return true if all requiredLocales are available.
+     */
+    public static boolean areLocalesAvailable(Locale[] requiredLocales) {
+        Locale[] availableLocales = Locale.getAvailableLocales();
+        Set<Locale> localeSet = new HashSet<Locale>(Arrays.asList(availableLocales));
+        for (Locale requiredLocale : requiredLocales) {
+            if (!localeSet.contains(requiredLocale)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+}
\ No newline at end of file
diff --git a/libcore/text/src/main/java/java/text/DateFormatSymbols.java b/libcore/text/src/main/java/java/text/DateFormatSymbols.java
index ad25bd8..e8e1f69 100644
--- a/libcore/text/src/main/java/java/text/DateFormatSymbols.java
+++ b/libcore/text/src/main/java/java/text/DateFormatSymbols.java
@@ -122,8 +122,8 @@
      */
     public DateFormatSymbols(Locale locale) {
         // BEGIN android-changed
+        localPatternChars = SimpleDateFormat.patternChars;
         ResourceBundle bundle = Format.getBundle(locale);
-        localPatternChars = bundle.getString("LocalPatternChars"); //$NON-NLS-1$
         ampms = bundle.getStringArray("ampm"); //$NON-NLS-1$
         eras = bundle.getStringArray("eras"); //$NON-NLS-1$
         months = bundle.getStringArray("months"); //$NON-NLS-1$
diff --git a/libcore/text/src/main/java/java/text/SimpleDateFormat.java b/libcore/text/src/main/java/java/text/SimpleDateFormat.java
index 290616c..47ff930 100644
--- a/libcore/text/src/main/java/java/text/SimpleDateFormat.java
+++ b/libcore/text/src/main/java/java/text/SimpleDateFormat.java
@@ -316,8 +316,7 @@
     private static final long serialVersionUID = 4774881970558875024L;
 
     // BEGIN android-changed
-    // private static final String patternChars = "GyMdkHmsSEDFwWahKzYeugAZvcLQqV"; //$NON-NLS-1$
-    private static final String patternChars = "GyMdkHmsSEDFwWahKzZ"; //$NON-NLS-1$
+    static final String patternChars = "GyMdkHmsSEDFwWahKzZ"; //$NON-NLS-1$
     // END android-changed
 
     private String pattern;
diff --git a/libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatTest.java b/libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatTest.java
index e636a07..bf7376a 100644
--- a/libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatTest.java
+++ b/libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatTest.java
@@ -16,7 +16,6 @@
  */
 package org.apache.harmony.text.tests.java.text;
 
-import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetNew;
@@ -196,7 +195,8 @@
             assertTrue("Doesn't work",
                     f1.format(new Date()).getClass() == String.class);
         }
-        assertTrue("Missing locales", english && german);
+        // TODO: currently, it is not mandatory to have both English and German locales bug 1943269
+        // assertTrue("Missing locales", english && german);
     }
 
     /**
diff --git a/libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java b/libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java
index e1debbb..b92e37b 100644
--- a/libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java
+++ b/libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.harmony.text.tests.java.text;
 
+import tests.support.Support_Locale;
 import dalvik.annotation.AndroidOnly;
 import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestLevel;
@@ -147,6 +148,15 @@
         args = {}
     )
     public void test_getCurrency() {
+        Locale csCzLocale = new Locale("cs", "CZ");
+        Locale czLocale = new Locale("", "CZ");
+        Locale csLocale = new Locale("cs", "");
+        Locale deLocale = new Locale("de", "AT");
+        Locale[] requiredLocales = {Locale.US, csCzLocale, czLocale, csLocale, deLocale};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         Currency currency = Currency.getInstance("USD");
         assertEquals("Returned incorrect currency",
                 dfsUS.getCurrency(), currency);
@@ -158,8 +168,8 @@
         Currency currE = Currency.getInstance("EUR");
         // Currency currF = Currency.getInstance("FRF");
 
-        DecimalFormatSymbols dfs1 = new DecimalFormatSymbols(new Locale("cs",
-                "CZ"));
+
+        DecimalFormatSymbols dfs1 = new DecimalFormatSymbols(csCzLocale);
         assertTrue("Test1: Returned incorrect currency",
                 dfs1.getCurrency() == currC);
         assertEquals("Test1: Returned incorrect currencySymbol", "K\u010d", dfs1
@@ -167,7 +177,8 @@
         assertEquals("Test1: Returned incorrect intlCurrencySymbol", "CZK",
                 dfs1.getInternationalCurrencySymbol());
 
-        dfs1 = new DecimalFormatSymbols(new Locale("", "CZ"));
+
+        dfs1 = new DecimalFormatSymbols(czLocale);
         assertTrue("Test2: Returned incorrect currency",
                 dfs1.getCurrency() == currC);
         // BEGIN android-changed
@@ -178,7 +189,7 @@
         assertEquals("Test2: Returned incorrect intlCurrencySymbol", "CZK",
                 dfs1.getInternationalCurrencySymbol());
 
-        dfs1 = new DecimalFormatSymbols(new Locale("cs", ""));
+        dfs1 = new DecimalFormatSymbols(csLocale);
         assertEquals("Test3: Returned incorrect currency",
                 currX, dfs1.getCurrency());
         assertEquals("Test3: Returned incorrect currencySymbol", "\u00a4", dfs1
@@ -186,7 +197,7 @@
         assertEquals("Test3: Returned incorrect intlCurrencySymbol", "XXX",
                 dfs1.getInternationalCurrencySymbol());
 
-        dfs1 = new DecimalFormatSymbols(new Locale("de", "AT"));
+        dfs1 = new DecimalFormatSymbols(deLocale);
         assertTrue("Test4: Returned incorrect currency",
                 dfs1.getCurrency() == currE);
         assertEquals("Test4: Returned incorrect currencySymbol", "\u20ac", dfs1
diff --git a/libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java b/libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java
index edab40b..2bd9260 100644
--- a/libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java
+++ b/libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java
@@ -29,6 +29,7 @@
 
 import tests.support.Support_BitSet;
 import tests.support.Support_DecimalFormat;
+import tests.support.Support_Locale;
 
 import java.io.ObjectInputStream;
 import java.io.IOException;
@@ -1831,6 +1832,11 @@
         args = {java.lang.Object.class}
     )
     public void test_formatToCharacterIteratorLjava_lang_Object() {
+        Locale[] requiredLocales = {Locale.US};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
 
         try {
             // Regression for HARMONY-466
diff --git a/libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatTest.java b/libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatTest.java
index d1246d3..7c4a319 100644
--- a/libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatTest.java
+++ b/libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatTest.java
@@ -1,13 +1,13 @@
-/* 
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You 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.
@@ -16,12 +16,12 @@
  */
 package org.apache.harmony.text.tests.java.text;
 
-import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargetClass;
 import dalvik.annotation.BrokenTest;
+import tests.support.Support_Locale;
 
 import junit.framework.TestCase;
 
@@ -34,7 +34,7 @@
 import java.util.Currency;
 import java.util.Locale;
 
-@TestTargetClass(NumberFormat.class) 
+@TestTargetClass(NumberFormat.class)
 public class NumberFormatTest extends TestCase {
 
     /**
@@ -154,6 +154,12 @@
         Locale chLocale = new Locale("de", "CH");
         // END android-changed
 
+        Locale[] requiredLocales = {usLocale, chLocale};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
+
         DecimalFormat format = (DecimalFormat) NumberFormat
                 .getIntegerInstance(usLocale);
         assertEquals(
@@ -292,20 +298,20 @@
             fail("Expected UnsupportedOperationException");
         } catch (UnsupportedOperationException e) {
         }
-        
+
         try {
             NumberFormat.getInstance().setCurrency(null);
             fail("NullPointerException was thrown.");
         } catch(NullPointerException npe) {
-            //expected   
+            //expected
         }
-        
+
         try {
             NumberFormat.getIntegerInstance().setCurrency(null);
             fail("NullPointerException was thrown.");
         } catch(NullPointerException npe) {
-            //expected   
-        }        
+            //expected
+        }
     }
 
     /**
@@ -319,45 +325,50 @@
         args = {java.lang.String.class, java.text.ParsePosition.class}
     )
     public void test_parseObjectLjava_lang_StringLjava_text_ParsePosition() {
+        Locale[] requiredLocales = {Locale.FRANCE};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         // regression test for HARMONY-1003
         assertNull(NumberFormat.getInstance().parseObject("0",
                 new ParsePosition(-1)));
 
-        parseObjectTest(NumberFormat.getInstance(), "123.123", 
+        parseObjectTest(NumberFormat.getInstance(), "123.123",
                 new ParsePosition(1), new Double(23.123), 7, true);
-        
-        parseObjectTest(NumberFormat.getInstance(), "123.123abc123", 
-                new ParsePosition(3), new Double(0.123), 7, true);        
-        
-        parseObjectTest(NumberFormat.getInstance(Locale.FRANCE), 
-                "asd123,123abc123", 
-                new ParsePosition(3), new Double(123.123), 10, true); 
-        
-        parseObjectTest(NumberFormat.getInstance(Locale.FRANCE), 
-                "test test", 
-                new ParsePosition(0), null, 0, false); 
-        
-        parseObjectTest(NumberFormat.getIntegerInstance(), 
-                "asd123.123abc123", 
+
+        parseObjectTest(NumberFormat.getInstance(), "123.123abc123",
+                new ParsePosition(3), new Double(0.123), 7, true);
+
+        parseObjectTest(NumberFormat.getInstance(Locale.FRANCE),
+                "asd123,123abc123",
+                new ParsePosition(3), new Double(123.123), 10, true);
+
+        parseObjectTest(NumberFormat.getInstance(Locale.FRANCE),
+                "test test",
+                new ParsePosition(0), null, 0, false);
+
+        parseObjectTest(NumberFormat.getIntegerInstance(),
+                "asd123.123abc123",
                 new ParsePosition(3), new Long(123), 6, true);
-        
-        parseObjectTest(NumberFormat.getNumberInstance(), 
-                "$-123,123.123#", 
+
+        parseObjectTest(NumberFormat.getNumberInstance(),
+                "$-123,123.123#",
                 new ParsePosition(1), new Double(-123123.123), 13, true);
-        parseObjectTest(NumberFormat.getNumberInstance(), 
-                "$-123,123.123#", 
-                new ParsePosition(0), null, 0, false);      
-        parseObjectTest(NumberFormat.getNumberInstance(), 
-                "$-123,123.123#", 
-                new ParsePosition(13), null, 13, false); 
-        parseObjectTest(NumberFormat.getPercentInstance(), 
-                "%20.123#", 
-                new ParsePosition(0), new Double(20.123), 0, false);        
-        parseObjectTest(NumberFormat.getPercentInstance(), 
-                "%-200,123.123#", 
-                new ParsePosition(0), null, 0, false);        
-        
-        
+        parseObjectTest(NumberFormat.getNumberInstance(),
+                "$-123,123.123#",
+                new ParsePosition(0), null, 0, false);
+        parseObjectTest(NumberFormat.getNumberInstance(),
+                "$-123,123.123#",
+                new ParsePosition(13), null, 13, false);
+        parseObjectTest(NumberFormat.getPercentInstance(),
+                "%20.123#",
+                new ParsePosition(0), new Double(20.123), 0, false);
+        parseObjectTest(NumberFormat.getPercentInstance(),
+                "%-200,123.123#",
+                new ParsePosition(0), null, 0, false);
+
+
         // Regression for HARMONY-1685
         try {
             NumberFormat.getInstance().parseObject("test", null);
@@ -366,8 +377,8 @@
             // expected
         }
     }
-    
-    void parseObjectTest(NumberFormat nf, String sourseStr, ParsePosition position, 
+
+    void parseObjectTest(NumberFormat nf, String sourseStr, ParsePosition position,
             Object resultObj, int outIndex, boolean isSuccess) {
         int indexBefore = position.getIndex();
         Object result = nf.parseObject(sourseStr, position);
@@ -451,11 +462,17 @@
         args = {double.class}
     )
     public void test_formatLdouble() {
+        Locale deLocale = new Locale("de", "CH");
+        Locale[] requiredLocales = {Locale.US, deLocale};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         // BEGIN android-changed
         NumberFormat nf1 = NumberFormat.getInstance(Locale.US);
         // use de_CH instead
         // NumberFormat nf2 = NumberFormat.getInstance(new Locale("ar", "AR"));
-        NumberFormat nf2 = NumberFormat.getInstance(new Locale("de", "CH"));
+        NumberFormat nf2 = NumberFormat.getInstance(deLocale);
 
         String out = nf1.format(1234567890.0123456789);
         assertEquals("Wrong result for double : " + out, "1,234,567,890.012",
@@ -490,11 +507,17 @@
         args = {long.class}
     )
     public void test_formatLlong() {
+        Locale deLocale = new Locale("de", "CH");
+        Locale[] requiredLocales = {Locale.US, deLocale};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         // BEGIN android-changed
         NumberFormat nf1 = NumberFormat.getInstance(Locale.US);
         // use de_CH instead
         // NumberFormat nf2 = NumberFormat.getInstance(Locale.CANADA_FRENCH);
-        NumberFormat nf2 = NumberFormat.getInstance(new Locale("de", "CH"));
+        NumberFormat nf2 = NumberFormat.getInstance(deLocale);
 
         String out = nf1.format(Long.MAX_VALUE);
         assertEquals("Wrong result for double : " + out,
@@ -594,6 +617,12 @@
         // Locale mkLocale = new Locale("mk", "MK");
         Locale atLocale = new Locale("de", "AT");
 
+        Locale[] requiredLocales = {usLocale, atLocale};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
+
         NumberFormat format = NumberFormat.getCurrencyInstance(usLocale);
 
         assertNotSame("Instance is null", null, format);
@@ -616,7 +645,7 @@
         // use de_AT instead
         // format = NumberFormat.getCurrencyInstance(mkLocale);
         format = NumberFormat.getCurrencyInstance(atLocale);
-        
+
         assertEquals(
                 "Test5: NumberFormat.getCurrencyInstance(new Locale(\"de\", \"AT\")).format(35.76) returned wrong value",
                 "\u20ac 35,76", format.format(35.76));
@@ -689,11 +718,17 @@
         args = {java.util.Locale.class}
     )
     public void test_getInstanceLjava_util_Locale() {
+        Locale testLocale = new Locale("de", "CH");
+        Locale[] requiredLocales = {Locale.US, testLocale};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         // BEGIN android-changed
         Locale.setDefault(Locale.US);
         // use de_CH instead
         // NumberFormat format = NumberFormat.getInstance(new Locale("ar", "AR"));
-        NumberFormat format = NumberFormat.getInstance(new Locale("de", "CH"));
+        NumberFormat format = NumberFormat.getInstance(testLocale);
 
         assertNotSame("Instance is null", null, format);
         assertTrue("Object is not instance of NumberFormat",
@@ -765,11 +800,16 @@
         args = {java.util.Locale.class}
     )
     public void test_getNumberInstanceLjava_util_Locale() {
+        Locale deLocale = new Locale("de", "CH");
+        Locale[] requiredLocales = {Locale.US, deLocale};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         // BEGIN android-changed
         Locale.setDefault(Locale.US);
         // use de_CH instead
-        NumberFormat format = NumberFormat.getNumberInstance(new Locale("de",
-                "CH"));
+        NumberFormat format = NumberFormat.getNumberInstance(deLocale);
         // NumberFormat format = NumberFormat.getNumberInstance(new Locale("ar",
         //         "AR"));
 
@@ -843,9 +883,14 @@
         args = {java.util.Locale.class}
     )
     public void test_getPercentInstanceLjava_util_Locale() {
+        Locale csLocale = new Locale("cs", "CZ");
+        Locale[] requiredLocales = {Locale.US, csLocale};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         Locale.setDefault(Locale.US);
-        NumberFormat format = NumberFormat.getPercentInstance(new Locale("cs",
-                "CZ"));
+        NumberFormat format = NumberFormat.getPercentInstance(csLocale);
 
         assertNotSame("Instance is null", null, format);
         assertTrue("Object is not instance of NumberFormat",
@@ -1054,6 +1099,12 @@
         args = {boolean.class}
     )
     public void test_setGroupingUsed() {
+        Locale csLocale = new Locale("cs", "CZ");
+        Locale[] requiredLocales = {Locale.US, csLocale};
+        if (!Support_Locale.areLocalesAvailable(requiredLocales)) {
+            // locale dependent test, bug 1943269
+            return;
+        }
         NumberFormat nf1 = NumberFormat.getInstance(Locale.US);
         nf1.setGroupingUsed(false);
 
@@ -1079,8 +1130,7 @@
         assertEquals("grouping is not used for -1234567890.1",
                 "-1,234,567,890.1", nf1.format(-1234567890.1));
 
-        NumberFormat nf2 = NumberFormat.getPercentInstance(new Locale("cs",
-                "CZ"));
+        NumberFormat nf2 = NumberFormat.getPercentInstance(csLocale);
         nf2.setGroupingUsed(false);
         assertEquals(
                 "Locale(\"cs\", \"CZ\"): grouping is used for 1234567890.1",
diff --git a/vm/Globals.h b/vm/Globals.h
index 916cb97..d96dbf8 100644
--- a/vm/Globals.h
+++ b/vm/Globals.h
@@ -261,14 +261,8 @@
     int         offJavaLangRefReference_queueNext;
     int         offJavaLangRefReference_vmData;
 
-#if FANCY_REFERENCE_SUBCLASS
-    /* method offsets - java.lang.ref.Reference */
-    int         voffJavaLangRefReference_clear;
-    int         voffJavaLangRefReference_enqueue;
-#else
     /* method pointers - java.lang.ref.Reference */
     Method*     methJavaLangRefReference_enqueueInternal;
-#endif
 
     /* field offsets - java.nio.Buffer and java.nio.DirectByteBufferImpl */
     //int         offJavaNioBuffer_capacity;
diff --git a/vm/alloc/Heap.c b/vm/alloc/Heap.c
index 33efa85..07f0a20 100644
--- a/vm/alloc/Heap.c
+++ b/vm/alloc/Heap.c
@@ -236,9 +236,9 @@
     if (obj != NULL) {
         uintptr_t workBits;
 
-        workBits = (uintptr_t)obj & (WORKER_CLEAR | WORKER_ENQUEUE);
+        workBits = (uintptr_t)obj & WORKER_ENQUEUE;
         assert(workBits != 0);
-        obj = (Object *)((uintptr_t)obj & ~(WORKER_CLEAR | WORKER_ENQUEUE));
+        obj = (Object *)((uintptr_t)obj & ~WORKER_ENQUEUE);
 
         *op = workBits;
     } else {
diff --git a/vm/alloc/HeapWorker.c b/vm/alloc/HeapWorker.c
index e7a4d03..3e0f669 100644
--- a/vm/alloc/HeapWorker.c
+++ b/vm/alloc/HeapWorker.c
@@ -15,10 +15,10 @@
  */
 
 /*
- * An async worker thread to handle certain heap operations that
- * need to be done in a separate thread to avoid synchronization
- * problems.  HeapWorkers and reference clearing/enqueuing are
- * handled by this thread.
+ * An async worker thread to handle certain heap operations that need
+ * to be done in a separate thread to avoid synchronization problems.
+ * HeapWorkers and reference enqueuing are handled by this thread.
+ * The VM does all clearing.
  */
 #include "Dalvik.h"
 #include "HeapInternal.h"
@@ -221,7 +221,7 @@
 }
 
 /* Process all enqueued heap work, including finalizers and reference
- * clearing/enqueueing.
+ * enqueueing. Clearing has already been done by the VM.
  *
  * Caller must hold gDvm.heapWorkerLock.
  */
@@ -230,17 +230,9 @@
     Object *obj;
     HeapWorkerOperation op;
     int numFinalizersCalled, numReferencesEnqueued;
-#if FANCY_REFERENCE_SUBCLASS
-    int numReferencesCleared = 0;
-#endif
 
     assert(gDvm.voffJavaLangObject_finalize >= 0);
-#if FANCY_REFERENCE_SUBCLASS
-    assert(gDvm.voffJavaLangRefReference_clear >= 0);
-    assert(gDvm.voffJavaLangRefReference_enqueue >= 0);
-#else
     assert(gDvm.methJavaLangRefReference_enqueueInternal != NULL);
-#endif
 
     numFinalizersCalled = 0;
     numReferencesEnqueued = 0;
@@ -262,39 +254,11 @@
             assert(method->clazz != gDvm.classJavaLangObject);
             callMethod(self, obj, method);
         } else {
-#if FANCY_REFERENCE_SUBCLASS
-            /* clear() *must* happen before enqueue(), otherwise
-             * a non-clear reference could appear on a reference
-             * queue.
-             */
-            if (op & WORKER_CLEAR) {
-                numReferencesCleared++;
-                method = obj->clazz->vtable[
-                        gDvm.voffJavaLangRefReference_clear];
-                assert(dvmCompareNameDescriptorAndMethod("clear", "()V",
-                                method) == 0);
-                assert(method->clazz != gDvm.classJavaLangRefReference);
-                callMethod(self, obj, method);
-            }
-            if (op & WORKER_ENQUEUE) {
-                numReferencesEnqueued++;
-                method = obj->clazz->vtable[
-                        gDvm.voffJavaLangRefReference_enqueue];
-                assert(dvmCompareNameDescriptorAndMethod("enqueue", "()Z",
-                                method) == 0);
-                /* We call enqueue() even when it isn't overridden,
-                 * so don't assert(!classJavaLangRefReference) here.
-                 */
-                callMethod(self, obj, method);
-            }
-#else
-            assert((op & WORKER_CLEAR) == 0);
             if (op & WORKER_ENQUEUE) {
                 numReferencesEnqueued++;
                 callMethod(self, obj,
                         gDvm.methJavaLangRefReference_enqueueInternal);
             }
-#endif
         }
 
         /* Let the GC collect the object.
@@ -303,9 +267,6 @@
     }
     LOGV("Called %d finalizers\n", numFinalizersCalled);
     LOGV("Enqueued %d references\n", numReferencesEnqueued);
-#if FANCY_REFERENCE_SUBCLASS
-    LOGV("Cleared %d overridden references\n", numReferencesCleared);
-#endif
 }
 
 /*
diff --git a/vm/alloc/HeapWorker.h b/vm/alloc/HeapWorker.h
index c079570..2734aef 100644
--- a/vm/alloc/HeapWorker.h
+++ b/vm/alloc/HeapWorker.h
@@ -77,11 +77,10 @@
 typedef enum HeapWorkerOperation {
     WORKER_FINALIZE = 0,
 
-    /* Required: (WORKER_CLEAR | WORKER_ENQUEUE) <= (4-1)
-     * These values will be stuffed in the low bits of a pointer.
+    /* Required: WORKER_ENQUEUE <= (4-1)
+     * This value will be stuffed in the low bits of a pointer.
      */
-    WORKER_CLEAR = (1<<0),
-    WORKER_ENQUEUE = (1<<1),
+    WORKER_ENQUEUE = (1<<0),
 } HeapWorkerOperation;
 
 /*
diff --git a/vm/alloc/MarkSweep.c b/vm/alloc/MarkSweep.c
index 429665f..84750ff 100644
--- a/vm/alloc/MarkSweep.c
+++ b/vm/alloc/MarkSweep.c
@@ -742,65 +742,36 @@
     LOG_SCAN("done with marked objects\n");
 }
 
-/** @return true if we need to schedule a call to clear().
+/** Clear the referent field.
  */
-static bool clearReference(Object *reference)
+static void clearReference(Object *reference)
 {
     /* This is what the default implementation of Reference.clear()
      * does.  We're required to clear all references to a given
      * referent atomically, so we can't pop in and out of interp
      * code each time.
      *
-     * Also, someone may have subclassed one of the basic Reference
-     * types, overriding clear().  We can't trust the clear()
-     * implementation to call super.clear();  we cannot let clear()
-     * resurrect the referent.  If we clear it here, we can safely
-     * call any overriding implementations.
+     * We don't ever actaully call overriding implementations of
+     * Reference.clear().
      */
     dvmSetFieldObject(reference,
             gDvm.offJavaLangRefReference_referent, NULL);
-
-#if FANCY_REFERENCE_SUBCLASS
-    /* See if clear() has actually been overridden.  If so,
-     * we need to schedule a call to it before calling enqueue().
-     */
-    if (reference->clazz->vtable[gDvm.voffJavaLangRefReference_clear]->clazz !=
-            gDvm.classJavaLangRefReference)
-    {
-        /* clear() has been overridden;  return true to indicate
-         * that we need to schedule a call to the real clear()
-         * implementation.
-         */
-        return true;
-    }
-#endif
-
-    return false;
 }
 
 /** @return true if we need to schedule a call to enqueue().
  */
 static bool enqueueReference(Object *reference)
 {
-#if FANCY_REFERENCE_SUBCLASS
-    /* See if this reference class has overridden enqueue();
-     * if not, we can take a shortcut.
-     */
-    if (reference->clazz->vtable[gDvm.voffJavaLangRefReference_enqueue]->clazz
-            == gDvm.classJavaLangRefReference)
-#endif
-    {
-        Object *queue = dvmGetFieldObject(reference,
-                gDvm.offJavaLangRefReference_queue);
-        Object *queueNext = dvmGetFieldObject(reference,
-                gDvm.offJavaLangRefReference_queueNext);
-        if (queue == NULL || queueNext != NULL) {
-            /* There is no queue, or the reference has already
-             * been enqueued.  The Reference.enqueue() method
-             * will do nothing even if we call it.
-             */
-            return false;
-        }
+    Object *queue = dvmGetFieldObject(reference,
+            gDvm.offJavaLangRefReference_queue);
+    Object *queueNext = dvmGetFieldObject(reference,
+            gDvm.offJavaLangRefReference_queueNext);
+    if (queue == NULL || queueNext != NULL) {
+        /* There is no queue, or the reference has already
+         * been enqueued.  The Reference.enqueue() method
+         * will do nothing even if we call it.
+         */
+        return false;
     }
 
     /* We need to call enqueue(), but if we called it from
@@ -835,7 +806,7 @@
         //      the list, and it would be nice to avoid the extra
         //      work.
         if (referent != NULL && !isMarked(ptr2chunk(referent), markContext)) {
-            bool schedClear, schedEnqueue;
+            bool schedEnqueue;
 
             /* This is the strongest reference that refers to referent.
              * Do the right thing.
@@ -843,7 +814,7 @@
             switch (refType) {
             case REF_SOFT:
             case REF_WEAK:
-                schedClear = clearReference(reference);
+                clearReference(reference);
                 schedEnqueue = enqueueReference(reference);
                 break;
             case REF_PHANTOM:
@@ -867,12 +838,11 @@
                     if (queue == gDvm.jniWeakGlobalRefQueue) {
                         LOGV("+++ WGR: clearing + not queueing %p:%p\n",
                             reference, referent);
-                        schedClear = clearReference(reference);
+                        clearReference(reference);
                         schedEnqueue = false;
                         break;
                     }
                 }
-                schedClear = false;
 
                 /* A PhantomReference is only useful with a
                  * queue, but since it's possible to create one
@@ -882,17 +852,15 @@
                 break;
             default:
                 assert(!"Bad reference type");
-                schedClear = false;
                 schedEnqueue = false;
                 break;
             }
 
-            if (schedClear || schedEnqueue) {
+            if (schedEnqueue) {
                 uintptr_t workBits;
 
-                /* Stuff the clear/enqueue bits in the bottom of
-                 * the pointer.  Assumes that objects are 8-byte
-                 * aligned.
+                /* Stuff the enqueue bit in the bottom of the pointer.
+                 * Assumes that objects are 8-byte aligned.
                  *
                  * Note that we are adding the *Reference* (which
                  * is by definition already marked at this point) to
@@ -900,12 +868,10 @@
                  * has already been cleared).
                  */
                 assert(((intptr_t)reference & 3) == 0);
-                assert(((WORKER_CLEAR | WORKER_ENQUEUE) & ~3) == 0);
-                workBits = (schedClear ? WORKER_CLEAR : 0) |
-                           (schedEnqueue ? WORKER_ENQUEUE : 0);
+                assert((WORKER_ENQUEUE & ~3) == 0);
                 if (!dvmHeapAddRefToLargeTable(
                         &gDvm.gcHeap->referenceOperations,
-                        (Object *)((uintptr_t)reference | workBits)))
+                        (Object *)((uintptr_t)reference | WORKER_ENQUEUE)))
                 {
                     LOGE_HEAP("dvmMalloc(): no room for any more "
                             "reference operations\n");