Merge "Fix a test that assumes Locale.getDefault() == Locale.US"
diff --git a/expectations/brokentests.txt b/expectations/brokentests.txt
index 3b966f5..9f900a3 100644
--- a/expectations/brokentests.txt
+++ b/expectations/brokentests.txt
@@ -522,190 +522,6 @@
   substring: "got java.lang.StringIndexOutOfBoundsException: null - FAILED"
 },
 {
-  description: "ICU doesn't like 3-letter names like CST because they're ambiguous.
-                Harmony prefers them because they're more human readable. We'll be
-                consistent with ICU, since that seems least fragile.
-                See https://issues.apache.org/jira/browse/HARMONY-5468
-                and http://bugs.icu-project.org/trac/ticket/6174",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.DateTest#test_toString",
-  substring: "GMT-07:00"
-},
-{
-  description: "These Harmony tests are enforcing a buggy behavior in TreeMap, presumably to be bug-compatible
-                with the RI. Our implementation is more conservative and throws on the bogus inputs.",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.TreeMapExtendTest#test_AscendingSubMapKeySet_headSet",
-  substring: "java.lang.IllegalArgumentException: 100 not in range (100..109]"
-},
-{
-  description: "These Harmony tests are enforcing a buggy behavior in TreeMap, presumably to be bug-compatible
-                with the RI. Our implementation is more conservative and throws on the bogus inputs.",
-  result: EXEC_FAILED,
-  names: [
-    "org.apache.harmony.luni.tests.java.util.TreeMapExtendTest#test_AscendingSubMapKeySet_tailSet",
-    "org.apache.harmony.luni.tests.java.util.TreeMapExtendTest#test_DescendingSubMapKeySet_headSet"
-  ],
-  substring: "java.lang.IllegalArgumentException: null not in range [100..109)"
-},
-{
-  description: "These Harmony tests are enforcing a buggy behavior in TreeMap, presumably to be bug-compatible
-                with the RI. Our implementation is more conservative and throws on the bogus inputs.",
-  result: EXEC_FAILED,
-  names: [
-    "org.apache.harmony.luni.tests.java.util.TreeMapExtendTest#test_DescendingSubMap_tailMap",
-    "org.apache.harmony.luni.tests.java.util.TreeMapExtendTest#test_DescendingSubMapKeySet_tailSet",
-    "org.apache.harmony.luni.tests.java.util.TreeMapExtendTest#test_SubMap_headMap"
-  ],
-  substring: "java.lang.IllegalArgumentException: 100 not in range (100..109]"
-},
-{
-  description: "why are they using reflection to test implementation details?",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.ArraysTest#test_swap_I_I_$Ljava_lang_Object",
-  substring: "java.lang.NoSuchMethodException"
-},
-{
-  description: "all these tests rely on a Harmony bug where TreeMaps may have a singleton null, which we choose
-                to disallow.",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.SimpleImmutableEntryTest#test_SimpleImmutableEntry_Constructor_LEntry",
-  pattern: ".*java.lang.NullPointerException.*at java.util.TreeMap.find.*"
-},
-{
-  description: "all these tests rely on a Harmony bug where TreeMaps may have a singleton null, which we choose
-                to disallow.",
-  result: EXEC_FAILED,
-  names: [
-    "org.apache.harmony.luni.tests.java.util.TreeMapTest#test_ceilingEntry",
-    "org.apache.harmony.luni.tests.java.util.TreeMapTest#test_ceilingKey",
-    "org.apache.harmony.luni.tests.java.util.TreeMapTest#test_floorEntry",
-    "org.apache.harmony.luni.tests.java.util.TreeMapTest#test_floorKey",
-    "org.apache.harmony.luni.tests.java.util.TreeMapTest#test_higherEntry",
-    "org.apache.harmony.luni.tests.java.util.TreeMapTest#test_higherKey",
-    "org.apache.harmony.luni.tests.java.util.TreeMapTest#test_lowerEntry",
-    "org.apache.harmony.luni.tests.java.util.TreeMapTest#test_lowerKey"
-  ],
-  substring: "java.lang.NullPointerException"
-},
-{
-  description: "all these tests rely on a Harmony bug where TreeMaps may have a singleton null, which we choose
-                to disallow.",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.TreeMapTest#test_illegalFirstNullKey",
-  pattern: ".*java.lang.NullPointerException.*at java.util.TreeMap.find.*"
-},
-{
-  description: "this is testing exception priorities",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.TreeMapTest#test_subMapLjava_lang_ObjectLjava_lang_Object",
-  substring: "java.lang.ClassCastException: java.lang.Object"
-},
-{
-  description: "the null-friendly comparator isn't symmetric",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.TreeMapTest#test_subMapLjava_lang_ObjectZLjava_lang_ObjectZ",
-  substring: "java.lang.NullPointerException"
-},
-{
-  description: "we fail fast on not-comparable objects",
-  result: EXEC_FAILED,
-  names: [
-    "org.apache.harmony.luni.tests.java.util.TreeMapTest#test_equals",
-    "org.apache.harmony.luni.tests.java.util.TreeMapTest#test_putLjava_lang_ObjectLjava_lang_Object"
-  ],
-  substring: "java.lang.ClassCastException: java.lang.Object"
-},
-{
-  description: "tests that depend on the iteration order of a hash",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.CollectionsTest#test_unmodifiable_toString_methods",
-  substring: "expected:<...one=1, two=2...> but was:<...two=2, one=1...>"
-},
-{
-  description: "tests that depend on the iteration order of a hash",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.HashtableTest#test_keySet_subtest1",
-  pattern: ".*java.lang.IllegalStateException.*at java.util.Hashtable.*"
-},
-{
-  description: "tests that depend on the iteration order of a hash",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.HashtableTest#test_elements_subtest0",
-  substring: "junit.framework.AssertionFailedError: unexpected: b"
-},
-{
-  description: "tests that depend on the iteration order of a hash",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.HashMapTest#test_rehash",
-  substring: "junit.framework.AssertionFailedError: expected same"
-},
-{
-  description: "tests that depend on the iteration order of a hash",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.PropertiesTest#test_SequentialpropertyNames",
-  substring: "expected:<current.b.key> but was:<current.a.key>"
-},
-{
-  description: "tests that depend on the iteration order of a hash",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.PropertiesTest#test_SequentialstringPropertyNames",
-  substring: "junit.framework.ComparisonFailure"
-},
-{
-  description: "tests that depend on the iteration order of a hash",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.PropertiesTest#test_propertyNames_sequence",
-  substring: "junit.framework.AssertionFailedError: expected:<current.b.key> but was:<current.a.key>"
-},
-{
-  description: "tests that use secret type information to reason about behavior",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.HashtableTest#test_keySet",
-  substring: "junit.framework.ComparisonFailure: Not synchronized expected:<...Collections$Synchronized...> but was:<...Hashtable$Key...>"
-},
-{
-  description: "tests that use secret type information to reason about behavior",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.HashtableTest#test_entrySet",
-  substring: "junit.framework.ComparisonFailure: Not synchronized expected:<...Collections$Synchronized...> but was:<...Hashtable$Entry...>"
-},
-{
-  description: "tests that use secret type information to reason about behavior",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.HashtableTest#test_values",
-  substring: "junit.framework.ComparisonFailure: Not synchronized expected:<...Collections$SynchronizedCollection> but was:<...Hashtable$Values>"
-},
-{
-  description: "this test is invalid, proxy.equals isn't symmetric",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.HashMapTest#test_proxies"
-},
-{
-  description: "this test is invalid, the mock map's entry set isn't to spec",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.HashMapTest#test_putAllLjava_util_Map",
-  substring: "java.lang.NullPointerException"
-},
-{
-  description: "this test assumes remove acts on equals() equality, not comparator equality",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.PriorityQueueTest#test_remove_Ljava_lang_Object_using_comparator",
-  substring: "junit.framework.AssertionFailedError"
-},
-{
-  description: "tests that violate the API and then guess about the outcomes",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.HashtableTest#test_getLjava_lang_Object",
-  substring: "junit.framework.AssertionFailedError"
-},
-{
-  description: "this test assumes Integer.toString() always returns a new instance",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.IdentityHashMap2Test#test_containsKeyLjava_lang_Object",
-  substring: "junit.framework.AssertionFailedError: Returned true for copy of valid key"
-},
-{
   description: "tests that cast to Harmony-specific types",
   result: EXEC_FAILED,
   failure: "bogus cast to harmony Hashtable$KeyEnumeration",
@@ -718,27 +534,6 @@
   substring: "java.util.Hashtable$ValueEnumeration"
 },
 {
-  description: "test doesn't expect it, but the spec permits the exception. RI also throws here.",
-  result: EXEC_FAILED,
-  names: [
-    "org.apache.harmony.luni.tests.java.util.PriorityQueueTest#test_remove_Ljava_lang_Object_not_Compatible",
-    "org.apache.harmony.luni.tests.java.util.PriorityQueueTest#test_remove_Ljava_lang_Object_not_exists"
-  ],
-  substring: "java.lang.ClassCastException"
-},
-{
-  description: "localization tests where our data disagree",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.LocaleTest#test_getAvailableLocales",
-  substring: "Wrong number of locales"
-},
-{
-  description: "test that enforce redundant implements clauses",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.LinkedHashMapTest#test_getInterfaces",
-  substring: "junit.framework.AssertionFailedError: expected:<3> but was:<2>"
-},
-{
   description: "we don't support the CharsetProvider spi, so we don't have \"mockCharset00\".",
   result: EXEC_FAILED,
   name: "org.apache.harmony.tests.java.nio.charset.CharsetTest#test_availableCharsets",
@@ -776,47 +571,11 @@
   ]
 },
 {
-  description: "The RI is still on Unicode 4.0, we're on 5.2, and Harmony is inconsistent
-                between its test for isJavaIdentifierPart(char) and isJavaIdentifierPart(int).",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.lang.CharacterTest#test_isJavaIdentifierPartC"
-},
-{
   description: "We removed this: we don't support Pack200.",
   result: UNSUPPORTED,
   name: "org.apache.harmony.archive.tests.java.util.jar.Pack200Test"
 },
 {
-  description: "We removed this: we don't cache canonical paths.",
-  result: UNSUPPORTED,
-  name: "org.apache.harmony.luni.tests.java.io.FileCanonPathCacheTest"
-},
-{
-  description: "We removed this: we don't throw NotYetImplementedException.",
-  result: UNSUPPORTED,
-  name: "org.apache.harmony.luni.tests.util.NYITest"
-},
-{
-  description: "We removed this: we don't support localized exceptions.",
-  result: UNSUPPORTED,
-  name: "org.apache.harmony.luni.tests.internal.nls.MessagesTest"
-},
-{
-  description: "These format specifiers are documented to not take flags, but the RI accepts and ignores them.",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.FormatterTest#test_formatLjava_lang_String$Ljava_lang_Object_LineSeparator",
-  substring: "java.util.IllegalFormatFlagsException: %n doesn't take an argument"
-},
-{
-  description: "These format specifiers are documented to not take flags, but the RI accepts and ignores them.",
-  result: EXEC_FAILED,
-  names: [
-    "org.apache.harmony.luni.tests.java.util.FormatterTest#test_formatLjava_lang_String$Ljava_lang_Object_Percent",
-    "org.apache.harmony.luni.tests.java.util.FormatterTest#test_formatLjava_lang_String$Ljava_lang_Object_Width"
-  ],
-  substring: "java.util.IllegalFormatFlagsException: %% doesn't take an argument"
-},
-{
   description: "Some tests (ExcludedProxyTest) connect to a public webserver to check that the HTTP client works",
   result: EXEC_FAILED,
   failure: "connect to the Internet",
diff --git a/expectations/icebox.txt b/expectations/icebox.txt
index daf9af4..34ffb2b 100644
--- a/expectations/icebox.txt
+++ b/expectations/icebox.txt
@@ -189,26 +189,9 @@
   name: "tests.api.javax.xml.parsers.SAXParserTest#test_parseLjava_io_InputStreamLorg_xml_sax_helpers_DefaultHandlerLjava_lang_String"
 },
 {
-  description: "these enforce a bug where an exception is incorrectly unthrown, but should maybe be fixed for
-                compatibility.",
-  result: EXEC_FAILED,
-  name: "org.apache.harmony.luni.tests.java.util.TreeMapTest#test_headMapLjava_lang_ObjectZL",
-  substring: "java.lang.IllegalArgumentException: null not in range ...5)"
-},
-{
-  description: "these enforce a bug where an exception is incorrectly unthrown, but should maybe be fixed for
-                compatibility.",
-  result: EXEC_FAILED,
-  names: [
-    "org.apache.harmony.luni.tests.java.util.TreeMapTest#test_tailMapLjava_lang_ObjectZL",
-    "org.apache.harmony.luni.tests.java.util.TreeMapTest#test_descendingMap_subMap"
-  ],
-  substring: "java.lang.IllegalArgumentException: 5 not in range (5..."
-},
-{
   description: "BouncyCastle allows unrecognized algorithms, but RI does not, not clear if this is a bug",
   result: EXEC_FAILED,
   name: "org.apache.harmony.crypto.tests.javax.crypto.KeyAgreementTest#test_generateSecretLjava_lang_String",
   substring: "junit.framework.AssertionFailedError: NoSuchAlgorithmException expected"
 }
-]
\ No newline at end of file
+]
diff --git a/expectations/knownfailures.txt b/expectations/knownfailures.txt
index 8bf1306..df33aee 100644
--- a/expectations/knownfailures.txt
+++ b/expectations/knownfailures.txt
@@ -18,11 +18,6 @@
   bug: 40103
 },
 {
-  description: "our regex implementation calls toString on CharSequences",
-  name: "org.apache.harmony.luni.tests.java.util.ScannerParseLargeFileBenchmarkTest#testParseLargeFile",
-  bug: 10133206
-},
-{
   description: "Method.getExceptionTypes() broken on proxy-generated classes",
   name: "libcore.java.lang.reflect.AnnotationsTest#testProxyMethodGetExceptions",
   bug: 5392273
@@ -191,12 +186,7 @@
   description: "Math failures when running on the host",
   names: [
     "libcore.java.lang.OldAndroidStrictMathTest#testLog1pD",
-    "libcore.java.lang.OldAndroidStrictMathTest#testRintD",
-    "org.apache.harmony.luni.tests.java.lang.MathTest#test_cbrt_D",
-    "org.apache.harmony.luni.tests.java.lang.MathTest#test_powDD",
-    "org.apache.harmony.luni.tests.java.lang.MathTest#test_sinh_D",
-    "org.apache.harmony.luni.tests.java.lang.StrictMathTest#test_log1p_D",
-    "org.apache.harmony.luni.tests.java.lang.StrictMathTest#test_rintD"
+    "libcore.java.lang.OldAndroidStrictMathTest#testRintD"
   ],
   bug: 2931959,
   modes: [ "host" ]
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/ref/ReferenceQueueTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/ref/ReferenceQueueTest.java
index ba28541..75a5218 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/ref/ReferenceQueueTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/ref/ReferenceQueueTest.java
@@ -76,7 +76,8 @@
         pr.enqueue();
 
         try {
-            assertNull("Remove failed.", rq.poll().get());
+            assertTrue("Remove failed.", ((Boolean) rq.poll().get())
+                    .booleanValue());
         } catch (Exception e) {
             fail("Exception during the test : " + e.getMessage());
         }
@@ -88,11 +89,11 @@
         }
 
         try {
-            assertTrue("Remove failed.", ((Boolean) rq.poll().get())
-                    .booleanValue());
+            assertNull("Remove failed.", rq.poll().get());
         } catch (Exception e) {
             fail("Exception during the test : " + e.getMessage());
         }
+
         assertNull(rq.poll());
 
         sr.enqueue();
@@ -182,11 +183,11 @@
 
         try {
             Reference result = rq.remove(1L);
-            assertTrue((Boolean)result.get());
+            assertNull(result.get());
             result = rq.remove(1L);
             assertEquals(obj, result.get());
             result = rq.remove(1L);
-            assertNull(result.get());
+            assertTrue((Boolean)result.get());
         } catch (IllegalArgumentException e1) {
             fail("IllegalArgumentException was thrown.");
         } catch (InterruptedException e1) {
diff --git a/libart/src/main/java/java/lang/reflect/ArtMethod.java b/libart/src/main/java/java/lang/reflect/ArtMethod.java
index 6ef06ee..8ce158a 100644
--- a/libart/src/main/java/java/lang/reflect/ArtMethod.java
+++ b/libart/src/main/java/java/lang/reflect/ArtMethod.java
@@ -105,19 +105,6 @@
      */
     private int methodIndex;
 
-    /* Quick compiler meta-data. TODO: merge and place in native heap. */
-
-    /** Bit map of spilled machine registers. */
-    private int quickCoreSpillMask;
-
-    /** Bit map of spilled floating point machine registers. */
-    private int quickFpSpillMask;
-
-    /** Fixed frame size for this method when executed. */
-    private int quickFrameSizeInBytes;
-
-    /* End of quick compiler meta-data. */
-
     /** Only created by ART directly. */
     private ArtMethod() {}
 
diff --git a/luni/src/main/java/java/io/ObjectInputStream.java b/luni/src/main/java/java/io/ObjectInputStream.java
index 35f6fc1..d07075f 100644
--- a/luni/src/main/java/java/io/ObjectInputStream.java
+++ b/luni/src/main/java/java/io/ObjectInputStream.java
@@ -1736,9 +1736,7 @@
      */
     protected Class<?> resolveProxyClass(String[] interfaceNames)
             throws IOException, ClassNotFoundException {
-        // TODO: This method is opportunity for performance enhancement
-        //       We can cache the classloader and recently used interfaces.
-        ClassLoader loader = ClassLoader.getSystemClassLoader();
+        ClassLoader loader = callerClassLoader;
         Class<?>[] interfaces = new Class<?>[interfaceNames.length];
         for (int i = 0; i < interfaceNames.length; i++) {
             interfaces[i] = Class.forName(interfaceNames[i], false, loader);
diff --git a/luni/src/main/java/java/text/DateFormat.java b/luni/src/main/java/java/text/DateFormat.java
index 049ddf98..64784b7 100644
--- a/luni/src/main/java/java/text/DateFormat.java
+++ b/luni/src/main/java/java/text/DateFormat.java
@@ -766,7 +766,7 @@
         /**
          * Marks the time zone part of a date.
          */
-        public static final Field TIME_ZONE = new Field("time zone", Calendar.ZONE_OFFSET);
+        public static final Field TIME_ZONE = new Field("time zone", -1);
 
         /**
          * The calendar field that this field represents.
diff --git a/luni/src/main/java/libcore/icu/NativeDecimalFormat.java b/luni/src/main/java/libcore/icu/NativeDecimalFormat.java
index 451dd91..f512002 100644
--- a/luni/src/main/java/libcore/icu/NativeDecimalFormat.java
+++ b/luni/src/main/java/libcore/icu/NativeDecimalFormat.java
@@ -415,6 +415,10 @@
     }
 
     public int getGroupingSize() {
+        // Work around http://bugs.icu-project.org/trac/ticket/10864 in icu4c 53.
+        if (!isGroupingUsed()) {
+            return 0;
+        }
         return getAttribute(this.address, UNUM_GROUPING_SIZE);
     }
 
diff --git a/support/src/test/java/libcore/java/security/StandardNames.java b/support/src/test/java/libcore/java/security/StandardNames.java
index da6fcd6..e37a788 100644
--- a/support/src/test/java/libcore/java/security/StandardNames.java
+++ b/support/src/test/java/libcore/java/security/StandardNames.java
@@ -897,7 +897,7 @@
         MINIMUM_KEY_SIZE = new HashMap<String, Integer>();
         PRIVATE_KEY_SPEC_CLASSES.put("RSA", RSAPrivateCrtKeySpec.class);
         PUBLIC_KEY_SPEC_CLASSES.put("RSA", RSAPublicKeySpec.class);
-        MINIMUM_KEY_SIZE.put("RSA", 256);
+        MINIMUM_KEY_SIZE.put("RSA", 512);
         PRIVATE_KEY_SPEC_CLASSES.put("DSA", DSAPrivateKeySpec.class);
         PUBLIC_KEY_SPEC_CLASSES.put("DSA", DSAPublicKeySpec.class);
         MINIMUM_KEY_SIZE.put("DSA", 512);