Merge changes from topic "oj11-update--math-localtime-duration"

* changes:
  Update LocalTime partially to 11+28
  Update Math and StrictMath partially to 11+28
diff --git a/JavaLibrary.bp b/JavaLibrary.bp
index 2d275e2..92bbc66 100644
--- a/JavaLibrary.bp
+++ b/JavaLibrary.bp
@@ -223,8 +223,10 @@
     name: "core-oj",
     visibility: [
         "//art/build/apex",
+        "//art/build/sdk",
         "//external/wycheproof",
         "//libcore/benchmarks",
+        "//packages/modules/ArtPrebuilt",
     ],
     apex_available: [
         "com.android.art",
@@ -274,6 +276,7 @@
         "//external/wycheproof",
         "//libcore/benchmarks",
         "//frameworks/layoutlib",
+        "//packages/modules/ArtPrebuilt",
     ],
     apex_available: [
         "com.android.art",
diff --git a/api/current.txt b/api/current.txt
index f114f36..c0ba527 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -13645,6 +13645,7 @@
   }
 
   public interface Set<E> extends java.util.Collection<E> {
+    method public static <E> java.util.Set<E> copyOf(java.util.Collection<? extends E>);
     method @NonNull public static <E> java.util.Set<E> of();
     method @NonNull public static <E> java.util.Set<E> of(@NonNull E);
     method @NonNull public static <E> java.util.Set<E> of(@NonNull E, @NonNull E);
diff --git a/luni/src/main/java/libcore/icu/ICU.java b/luni/src/main/java/libcore/icu/ICU.java
index f7f2042..031ddfa 100644
--- a/luni/src/main/java/libcore/icu/ICU.java
+++ b/luni/src/main/java/libcore/icu/ICU.java
@@ -49,6 +49,7 @@
   private static Locale[] availableLocalesCache;
 
   private static String[] isoCountries;
+  private static Set<String> isoCountriesSet;
 
   private static String[] isoLanguages;
 
@@ -92,12 +93,33 @@
    * Returns an array of two-letter ISO 3166 country codes, either from ICU or our cache.
    */
   public static String[] getISOCountries() {
+    return getISOCountriesInternal().clone();
+  }
+
+  /**
+   * Returns true if the string is a 2-letter ISO 3166 country code.
+   */
+  public static boolean isIsoCountry(String country) {
+    if (isoCountriesSet == null) {
+      String[] isoCountries = getISOCountriesInternal();
+      Set<String> newSet = new HashSet<>(isoCountries.length);
+      for (String isoCountry : isoCountries) {
+        newSet.add(isoCountry);
+      }
+      isoCountriesSet = newSet;
+    }
+    return country != null && isoCountriesSet.contains(country);
+  }
+
+  private static String[] getISOCountriesInternal() {
     if (isoCountries == null) {
       isoCountries = getISOCountriesNative();
     }
-    return isoCountries.clone();
+    return isoCountries;
   }
 
+
+
   private static final int IDX_LANGUAGE = 0;
   private static final int IDX_SCRIPT = 1;
   private static final int IDX_REGION = 2;
diff --git a/luni/src/main/java/libcore/io/Streams.java b/luni/src/main/java/libcore/io/Streams.java
index f83f5c1..43a4460 100644
--- a/luni/src/main/java/libcore/io/Streams.java
+++ b/luni/src/main/java/libcore/io/Streams.java
@@ -29,7 +29,7 @@
 import libcore.util.ArrayUtils;
 
 /** @hide */
-@libcore.api.CorePlatformApi
+@libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
 public final class Streams {
     private static AtomicReference<byte[]> skipBuffer = new AtomicReference<byte[]>();
 
@@ -98,10 +98,14 @@
     }
 
     /**
-     * Returns a byte[] containing the remainder of 'in', closing it when done.
+     * Returns a byte[] containing the remainder of {@code in} stream and
+     * closes it. Also see {@link #readFullyNoClose(InputStream)}.
+     *
+     * @return remaining bytes in {@code in} stream.
+     * @throws IOException thrown by {@link InputStream#read(byte[])}.
      */
     @UnsupportedAppUsage
-    @libcore.api.CorePlatformApi
+    @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
     public static byte[] readFully(InputStream in) throws IOException {
         try {
             return readFullyNoClose(in);
@@ -111,9 +115,13 @@
     }
 
     /**
-     * Returns a byte[] containing the remainder of 'in'.
+     * Returns a byte[] containing the remainder of {@code in} stream, without
+     * closing it.
+     *
+     * @return remaining bytes in {@code in} stream.
+     * @throws IOException thrown by {@link InputStream#read(byte[])}.
      */
-    @libcore.api.CorePlatformApi
+    @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
     public static byte[] readFullyNoClose(InputStream in) throws IOException {
         ByteArrayOutputStream bytes = new ByteArrayOutputStream();
         byte[] buffer = new byte[1024];
@@ -125,9 +133,13 @@
     }
 
     /**
-     * Returns the remainder of 'reader' as a string, closing it when done.
+     * Reads the remainder of {@code reader} as a string, closing it when done.
+     *
+     * @param reader {@link Reader} instance.
+     * @return remainder of {@code reader} as {@link String}.
+     * @throws IOException thrown by {@link Reader#read(java.nio.CharBuffer)}.
      */
-    @libcore.api.CorePlatformApi
+    @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
     public static String readFully(Reader reader) throws IOException {
         try {
             StringWriter writer = new StringWriter();
@@ -189,11 +201,15 @@
     }
 
     /**
-     * Copies all of the bytes from {@code in} to {@code out}. Neither stream is closed.
-     * Returns the total number of bytes transferred.
+     * Copies all of the bytes from {@code in} to {@code out}. Neither stream is
+     * closed.
+     *
+     * @return the total number of bytes transferred.
+     * @throws IOException reading from {@link InputStream} or writing to
+     * {@link OutputStream}.
      */
     @UnsupportedAppUsage
-    @libcore.api.CorePlatformApi
+    @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
     public static int copy(InputStream in, OutputStream out) throws IOException {
         int total = 0;
         byte[] buffer = new byte[8192];
diff --git a/mmodules/core_platform_api/api/stable_platform/current.txt b/mmodules/core_platform_api/api/stable_platform/current.txt
index cf723c5..381ac75 100644
--- a/mmodules/core_platform_api/api/stable_platform/current.txt
+++ b/mmodules/core_platform_api/api/stable_platform/current.txt
@@ -64,6 +64,17 @@
 
 }
 
+package libcore.io {
+
+  public final class Streams {
+    method public static int copy(java.io.InputStream, java.io.OutputStream) throws java.io.IOException;
+    method public static byte[] readFully(java.io.InputStream) throws java.io.IOException;
+    method public static String readFully(java.io.Reader) throws java.io.IOException;
+    method public static byte[] readFullyNoClose(java.io.InputStream) throws java.io.IOException;
+  }
+
+}
+
 package libcore.util {
 
   public class HexEncoding {
diff --git a/nullability_warnings.txt b/nullability_warnings.txt
index e69de29..8bfd6a8 100644
--- a/nullability_warnings.txt
+++ b/nullability_warnings.txt
@@ -0,0 +1,2 @@
+WARNING: method java.util.Set.copyOf(java.util.Collection<? extends E>), parameter coll, MISSING
+WARNING: method java.util.Set.copyOf(java.util.Collection<? extends E>), return value, MISSING
diff --git a/ojluni/src/main/java/java/util/Currency.java b/ojluni/src/main/java/java/util/Currency.java
index 94629c7..c7b8b16 100644
--- a/ojluni/src/main/java/java/util/Currency.java
+++ b/ojluni/src/main/java/java/util/Currency.java
@@ -361,16 +361,21 @@
         */
         android.icu.util.Currency icuInstance =
                 android.icu.util.Currency.getInstance(locale);
+        // Unknown historical reason to append variant to country code. The API documentation
+        // does not mention the effect of locale variant. The actual effect here is throwing
+        // IllegalArgumentException because the code like FR_EURO is not a valid country code.
         String variant = locale.getVariant();
         if (!variant.isEmpty() && (variant.equals("EURO") || variant.equals("HK") ||
                 variant.equals("PREEURO"))) {
             country = country + "_" + variant;
         }
-        String currencyCode = ICU.getCurrencyCode(country);
-        if (currencyCode == null) {
+        if (!ICU.isIsoCountry(country)) {
+            // Throws IllegalArgumentException as required by the API documentation.
             throw new IllegalArgumentException("Unsupported ISO 3166 country: " + locale);
         }
-        if (icuInstance == null || icuInstance.getCurrencyCode().equals("XXX")) {
+        String currencyCode = ICU.getCurrencyCode(country);
+        if (currencyCode == null || icuInstance == null ||
+                icuInstance.getCurrencyCode().equals("XXX")) { // XXX is not a real currency.
             return null;
         }
         return getInstance(currencyCode);
diff --git a/ojluni/src/main/java/java/util/Set.java b/ojluni/src/main/java/java/util/Set.java
index 0499ea3..c2f6560 100644
--- a/ojluni/src/main/java/java/util/Set.java
+++ b/ojluni/src/main/java/java/util/Set.java
@@ -700,4 +700,30 @@
                 return new ImmutableCollections.SetN<>(elements);
         }
     }
+
+    /**
+     * Returns an <a href="#unmodifiable">unmodifiable Set</a> containing the elements
+     * of the given Collection. The given Collection must not be null, and it must not
+     * contain any null elements. If the given Collection contains duplicate elements,
+     * an arbitrary element of the duplicates is preserved. If the given Collection is
+     * subsequently modified, the returned Set will not reflect such modifications.
+     *
+     * @implNote
+     * If the given Collection is an <a href="#unmodifiable">unmodifiable Set</a>,
+     * calling copyOf will generally not create a copy.
+     *
+     * @param <E> the {@code Set}'s element type
+     * @param coll a {@code Collection} from which elements are drawn, must be non-null
+     * @return a {@code Set} containing the elements of the given {@code Collection}
+     * @throws NullPointerException if coll is null, or if it contains any nulls
+     * @since 10
+     */
+    @SuppressWarnings("unchecked")
+    static <E> Set<E> copyOf(Collection<? extends E> coll) {
+        if (coll instanceof ImmutableCollections.AbstractImmutableSet) {
+            return (Set<E>)coll;
+        } else {
+            return (Set<E>)Set.of(new HashSet<>(coll).toArray());
+        }
+    }
 }
diff --git a/ojluni/src/test/java/util/Collection/SetFactories.java b/ojluni/src/test/java/util/Collection/SetFactories.java
new file mode 100644
index 0000000..653f419
--- /dev/null
+++ b/ojluni/src/test/java/util/Collection/SetFactories.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package test.java.util.Collection;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import static org.testng.Assert.assertEquals;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertNotEquals;
+import static org.testng.Assert.assertNotSame;
+import static org.testng.Assert.assertSame;
+
+/*
+ * @test
+ * @bug 8048330
+ * @summary Test convenience static factory methods on Set.
+ * @run testng SetFactories
+ */
+
+@Test
+public class SetFactories {
+
+    Set<Integer> genSet() {
+        return new HashSet<>(Arrays.asList(1, 2, 3));
+    }
+
+    @Test
+    public void copyOfResultsEqual() {
+        Set<Integer> orig = genSet();
+        Set<Integer> copy = Set.copyOf(orig);
+
+        assertEquals(orig, copy);
+        assertEquals(copy, orig);
+    }
+
+    @Test
+    public void copyOfModifiedUnequal() {
+        Set<Integer> orig = genSet();
+        Set<Integer> copy = Set.copyOf(orig);
+        orig.add(4);
+
+        assertNotEquals(orig, copy);
+        assertNotEquals(copy, orig);
+    }
+
+    @Test
+    public void copyOfIdentity() {
+        Set<Integer> orig = genSet();
+        Set<Integer> copy1 = Set.copyOf(orig);
+        Set<Integer> copy2 = Set.copyOf(copy1);
+
+        assertNotSame(orig, copy1);
+        assertSame(copy1, copy2);
+    }
+
+    @Test(expectedExceptions=NullPointerException.class)
+    public void copyOfRejectsNullCollection() {
+        Set<Integer> set = Set.copyOf(null);
+    }
+
+    @Test(expectedExceptions=NullPointerException.class)
+    public void copyOfRejectsNullElements() {
+        Set<Integer> set = Set.copyOf(Arrays.asList(1, null, 3));
+    }
+
+    @Test
+    public void copyOfAcceptsDuplicates() {
+        Set<Integer> set = Set.copyOf(Arrays.asList(1, 1, 2, 3, 3, 3));
+        assertEquals(set, Set.of(1, 2, 3));
+    }
+}