OSDN Git Service

Make Half class use public APIs
authorNeil Fuller <nfuller@google.com>
Mon, 2 Jul 2018 11:04:39 +0000 (12:04 +0100)
committerNeil Fuller <nfuller@google.com>
Mon, 2 Jul 2018 11:04:39 +0000 (12:04 +0100)
Half has a dependency on an internal sun.misc.FloatingDecimal
that can be replaced by an equivalent call on java.lang.Float
(which calls through to FloatingDecimal).

Any performance hit is worth it for a smaller API surface.

Bug: 111055375
Test: Build
Change-Id: Iecdf3aa9414922a77edbdc439b0c2b88033b3af8

core/java/android/util/Half.java

index 84c2e83..5718d99 100644 (file)
@@ -20,8 +20,6 @@ import android.annotation.HalfFloat;
 import android.annotation.NonNull;
 import android.annotation.Nullable;
 
-import sun.misc.FloatingDecimal;
-
 /**
  * <p>The {@code Half} class is a wrapper and a utility class to manipulate half-precision 16-bit
  * <a href="https://en.wikipedia.org/wiki/Half-precision_floating-point_format">IEEE 754</a>
@@ -1026,7 +1024,7 @@ public final class Half extends Number implements Comparable<Half> {
      *         half-precision float value
      */
     public static @HalfFloat short parseHalf(@NonNull String s) throws NumberFormatException {
-        return toHalf(FloatingDecimal.parseFloat(s));
+        return toHalf(Float.parseFloat(s));
     }
 
     /**