Merge changes from topic 'standard-cldr-data' am: 95cbac5a98 am: 9f071b62f7
am: 257889879e

Change-Id: Ic21b999d7d08621129e9b6132a6388891da98b2f
diff --git a/JavaLibrary.mk b/JavaLibrary.mk
index d348239..f9ded0a 100644
--- a/JavaLibrary.mk
+++ b/JavaLibrary.mk
@@ -245,7 +245,7 @@
 	tzdata-testing \
         junit-params
 LOCAL_JAVACFLAGS := $(local_javac_flags)
-LOCAL_ERROR_PRONE_FLAGS := -Xep:TryFailThrowable:ERROR
+LOCAL_ERROR_PRONE_FLAGS := -Xep:TryFailThrowable:ERROR -Xep:ComparisonOutOfRange:ERROR
 LOCAL_JAVA_LANGUAGE_VERSION := 1.8
 LOCAL_MODULE := core-tests
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
@@ -512,7 +512,7 @@
  -knowntags ./libcore/known_oj_tags.txt \
  -hdf android.whichdoc offline
 
-LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=build/tools/droiddoc/templates-sdk
+LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=external/doclava/res/assets/templates-sdk
 
 include $(BUILD_DROIDDOC)
 
diff --git a/expectations/knownfailures.txt b/expectations/knownfailures.txt
index 1f0ef32..f1bac82 100644
--- a/expectations/knownfailures.txt
+++ b/expectations/knownfailures.txt
@@ -1503,13 +1503,5 @@
   names: [
     "com.android.org.apache.harmony.luni.tests.java.net.URLClassLoaderImplTest#test_Constructor$Ljava_net_URLLjava_lang_ClassLoaderLjava_net_URLStreamHandlerFactory"
   ]
-},
-{
-  description: "Waiting for ICU 58 to be merged",
-  bug: 31516121,
-  result: EXEC_FAILED,
-  names: [
-    "libcore.java.text.OldBidiTest#testUnicode9EmojisAreLtrNeutral"
-  ]
 }
 ]
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/io/ObjectInputStream2Test.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/io/ObjectInputStream2Test.java
index af5fce5..e81224a 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/io/ObjectInputStream2Test.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/io/ObjectInputStream2Test.java
@@ -17,8 +17,10 @@
 
 package org.apache.harmony.tests.java.io;
 
+import dalvik.system.DexFile;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InvalidClassException;
@@ -27,6 +29,9 @@
 import java.io.ObjectStreamClass;
 import java.io.ObjectStreamException;
 import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
 import java.util.ArrayList;
 
 import junit.framework.TestCase;
@@ -210,4 +215,54 @@
             // Excpected
         }
     }
+
+    // http://b/29721023
+    public void test_sameName() throws Exception {
+        // Load class from dex, it's not possible to create a class with same-named
+        // fields in java (but it's allowed in dex).
+        File sameFieldNames = File.createTempFile("sameFieldNames", ".dex");
+        InputStream dexIs = this.getClass().getClassLoader().
+            getResourceAsStream("tests/api/java/io/sameFieldNames.dex");
+        assertNotNull(dexIs);
+
+        Class<?> clazz = null;
+
+        // Get the class object
+        try {
+            Files.copy(dexIs, sameFieldNames.toPath(), StandardCopyOption.REPLACE_EXISTING);
+            DexFile dexFile = new DexFile(sameFieldNames);
+            clazz = dexFile.loadClass("sameFieldNames", getClass().getClassLoader());
+            dexFile.close();
+        } finally {
+            if (sameFieldNames.exists()) {
+                sameFieldNames.delete();
+            }
+        }
+
+        // Create class instance, fill it with content
+        Object o1 = clazz.getConstructor().newInstance();
+        int v = 123;
+        for(Field f : clazz.getFields()) {
+            if (f.getType() == Integer.class) {
+                f.set(o1, new Integer(v++));
+            } else if (f.getType() == Long.class) {
+                f.set(o1, new Long(v++));
+            }
+        }
+
+        // Serialize and deserialize
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream oos = new ObjectOutputStream(baos);
+        oos.writeObject(o1);
+        oos.close();
+        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(
+                baos.toByteArray()));
+        Object o2 = ois.readObject();
+        ois.close();
+
+        // Compare content
+        for(Field f : clazz.getFields()) {
+            assertEquals(f.get(o1), f.get(o2));
+        }
+    }
 }
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/io/ObjectStreamClassTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/io/ObjectStreamClassTest.java
index bebeb6e..6253b6b 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/io/ObjectStreamClassTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/io/ObjectStreamClassTest.java
@@ -17,17 +17,23 @@
 
 package org.apache.harmony.tests.java.io;
 
+import dalvik.system.DexFile;
 import dalvik.system.VMRuntime;
 import java.io.Externalizable;
+import java.io.File;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.io.ObjectStreamClass;
 import java.io.ObjectStreamField;
 import java.io.Serializable;
+import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
 import junit.framework.TestCase;
 
 public class ObjectStreamClassTest extends TestCase {
@@ -319,4 +325,27 @@
                     hasStaticInitializer.invoke(null, NoClinitChildWithNoClinitParent.class,
                                                 true /* checkSuperclass */));
     }
+
+    // http://b/29721023
+    public void testClassWithSameFieldName() throws Exception {
+        // Load class from dex, it's not possible to create a class with same-named
+        // fields in java (but it's allowed in dex).
+        File sameFieldNames = File.createTempFile("sameFieldNames", ".dex");
+        InputStream dexIs = this.getClass().getClassLoader().
+            getResourceAsStream("tests/api/java/io/sameFieldNames.dex");
+        assertNotNull(dexIs);
+
+        try {
+            Files.copy(dexIs, sameFieldNames.toPath(), StandardCopyOption.REPLACE_EXISTING);
+            DexFile dexFile = new DexFile(sameFieldNames);
+            Class<?> clazz = dexFile.loadClass("sameFieldNames", getClass().getClassLoader());
+            ObjectStreamClass osc = ObjectStreamClass.lookup(clazz);
+            assertEquals(4, osc.getFields().length);
+            dexFile.close();
+        } finally {
+            if (sameFieldNames.exists()) {
+                sameFieldNames.delete();
+            }
+        }
+    }
 }
diff --git a/luni/src/test/java/libcore/java/io/FileInputStreamTest.java b/luni/src/test/java/libcore/java/io/FileInputStreamTest.java
index b85f69a..c199bca 100644
--- a/luni/src/test/java/libcore/java/io/FileInputStreamTest.java
+++ b/luni/src/test/java/libcore/java/io/FileInputStreamTest.java
@@ -264,11 +264,6 @@
                 assertEquals(0, Libcore.os.lseek(fis.getFD(), 0, OsConstants.SEEK_CUR));
                 assertEquals(lastByte, fis.skip(lastByte));
             }
-
-            FileInputStream fis = new FileInputStream(largeFile);
-            long lastByte = 3 * 1024 * 1024 * 1024L - 1;
-            assertEquals(0, Libcore.os.lseek(fis.getFD(), 0, OsConstants.SEEK_CUR));
-            assertEquals(lastByte, fis.skip(lastByte));
         } finally {
             // Proactively cleanup - it's a pretty large file.
             assertTrue(largeFile.delete());
diff --git a/luni/src/test/java/tests/security/cert/CertificateTest.java b/luni/src/test/java/tests/security/cert/CertificateTest.java
index 156ccd2..d49b08f 100644
--- a/luni/src/test/java/tests/security/cert/CertificateTest.java
+++ b/luni/src/test/java/tests/security/cert/CertificateTest.java
@@ -174,7 +174,7 @@
         byte[] actualEncoding = actual.getEncoded();
         assertTrue(Arrays.equals(expectedEncoding, actualEncoding));
 
-        assertFalse(expectedEncoding[4] == 200);
+        assertFalse(expectedEncoding[4] == (byte) 200);
         expectedEncoding[4] = (byte) 200;
         try {
             cf.generateCertificate(new ByteArrayInputStream(expectedEncoding));
diff --git a/ojluni/src/main/java/java/net/URL.java b/ojluni/src/main/java/java/net/URL.java
index 8b6c6e0..576439d 100644
--- a/ojluni/src/main/java/java/net/URL.java
+++ b/ojluni/src/main/java/java/net/URL.java
@@ -665,8 +665,8 @@
      * @param file the file on the host
      * @param ref the internal reference in the URL
      */
-    protected void set(String protocol, String host,
-                       int port, String file, String ref) {
+    void set(String protocol, String host, int port,
+             String file, String ref) {
         synchronized (this) {
             this.protocol = protocol;
             this.host = host;
@@ -702,9 +702,9 @@
      * @param query the query part of this URL
      * @since 1.3
      */
-    protected void set(String protocol, String host, int port,
-                       String authority, String userInfo, String path,
-                       String query, String ref) {
+    void set(String protocol, String host, int port,
+             String authority, String userInfo, String path,
+             String query, String ref) {
         synchronized (this) {
             this.protocol = protocol;
             this.host = host;
diff --git a/ojluni/src/main/java/java/util/Collections.java b/ojluni/src/main/java/java/util/Collections.java
index 4818ee6..315a7d1 100644
--- a/ojluni/src/main/java/java/util/Collections.java
+++ b/ojluni/src/main/java/java/util/Collections.java
@@ -4705,11 +4705,11 @@
      * Returns an immutable set containing only the specified object.
      * The returned set is serializable.
      *
-     * @param  <E> the class of the objects in the set
+     * @param  <T> the class of the objects in the set
      * @param o the sole object to be stored in the returned set.
      * @return an immutable set containing only the specified object.
      */
-    public static <E> Set<E> singleton(E o) {
+    public static <T> Set<T> singleton(T o) {
         return new SingletonSet<>(o);
     }
 
@@ -4826,12 +4826,12 @@
      * Returns an immutable list containing only the specified object.
      * The returned list is serializable.
      *
-     * @param  <E> the class of the objects in the list
+     * @param  <T> the class of the objects in the list
      * @param o the sole object to be stored in the returned list.
      * @return an immutable list containing only the specified object.
      * @since 1.3
      */
-    public static <E> List<E> singletonList(E o) {
+    public static <T> List<T> singletonList(T o) {
         return new SingletonList<>(o);
     }