Exposes BigInteger.valueOf(double) method.

This makes cross testing easier without native method hacks
and provides a more optimal API alternative to the public
Double.valuOf(long).

PiperOrigin-RevId: 332556629
Change-Id: Ie496859c3311a9227b81fbea711870bc46c1bdc2
diff --git a/user/super/com/google/gwt/emul/java/math/BigInteger.java b/user/super/com/google/gwt/emul/java/math/BigInteger.java
index 11b8f8b..c3b4660 100644
--- a/user/super/com/google/gwt/emul/java/math/BigInteger.java
+++ b/user/super/com/google/gwt/emul/java/math/BigInteger.java
@@ -162,7 +162,7 @@
     return new BigInteger(1, intCount + 1, resDigits);
   }
 
-  static BigInteger valueOf(double val) {
+  public static BigInteger valueOf(double val) {
     if (val < 0) {
       if (val != -1) {
         return new BigInteger(-1, -val);
diff --git a/user/test/com/google/gwt/emultest/java/math/BigIntegerConstructorsTest.java b/user/test/com/google/gwt/emultest/java/math/BigIntegerConstructorsTest.java
index a7757e8..3229ee3 100644
--- a/user/test/com/google/gwt/emultest/java/math/BigIntegerConstructorsTest.java
+++ b/user/test/com/google/gwt/emultest/java/math/BigIntegerConstructorsTest.java
@@ -39,7 +39,8 @@
 
 import com.google.gwt.emultest.java.util.EmulTestBase;
 import com.google.gwt.testing.TestUtils;
-
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
 import java.math.BigInteger;
 import java.util.Random;
 
@@ -786,25 +787,39 @@
       // JRE implementation doesn't have the method tested here
       return;
     }
-    BigInteger val = BigIntegerViolator.fromDouble(1.0);
+    BigInteger val = BigInteger.valueOf(noopToCompileForJvm(1.0));
     assertEquals("1", val.toString());
-    val = BigIntegerViolator.fromDouble(100.0);
+    val = BigInteger.valueOf(noopToCompileForJvm(100.0));
     assertEquals("100", val.toString());
-    val = BigIntegerViolator.fromDouble(2147483647.0);
+    val = BigInteger.valueOf(noopToCompileForJvm(2147483647.0));
     assertEquals("2147483647", val.toString());
-    val = BigIntegerViolator.fromDouble(-2147483647.0);
+    val = BigInteger.valueOf(noopToCompileForJvm(-2147483647.0));
     assertEquals("-2147483647", val.toString());
-    val = BigIntegerViolator.fromDouble(2147483648.0);
+    val = BigInteger.valueOf(noopToCompileForJvm(2147483648.0));
     assertEquals("2147483648", val.toString());
-    val = BigIntegerViolator.fromDouble(-2147483648.0);
+    val = BigInteger.valueOf(noopToCompileForJvm(-2147483648.0));
     assertEquals("-2147483648", val.toString());
-    val = BigIntegerViolator.fromDouble(4294967295.0);
+    val = BigInteger.valueOf(noopToCompileForJvm(4294967295.0));
     assertEquals("4294967295", val.toString());
-    val = BigIntegerViolator.fromDouble(-4294967295.0);
+    val = BigInteger.valueOf(noopToCompileForJvm(-4294967295.0));
     assertEquals("-4294967295", val.toString());
-    val = BigIntegerViolator.fromDouble(4294967296.0);
+    val = BigInteger.valueOf(noopToCompileForJvm(4294967296.0));
     assertEquals("4294967296", val.toString());
-    val = BigIntegerViolator.fromDouble(-4294967296.0);
+    val = BigInteger.valueOf(noopToCompileForJvm(-4294967296.0));
     assertEquals("-4294967296", val.toString());
   }
+
+  @Target({ElementType.METHOD})
+  private @interface GwtIncompatible {}
+
+  @GwtIncompatible
+  private static long noopToCompileForJvm(double d) {
+    // The BigInteger.valueOf(double) doesn't exist on JVM. This methods exists to so that this test
+    // can be compiled with the standard JRE.
+    throw new AssertionError();
+  }
+
+  private static double noopToCompileForJvm(Double d) {
+    return d;
+  }
 }
diff --git a/user/test/com/google/gwt/emultest/java/math/BigIntegerViolator.java b/user/test/com/google/gwt/emultest/java/math/BigIntegerViolator.java
deleted file mode 100644
index 81edf89..0000000
--- a/user/test/com/google/gwt/emultest/java/math/BigIntegerViolator.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- * 
- * Licensed 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 com.google.gwt.emultest.java.math;
-
-import java.math.BigInteger;
-
-/**
- * Used to delay referencing methods only present in the emulated JRE until they
- * are actually used.
- */
-public class BigIntegerViolator {
-  
-  public static native BigInteger fromDouble(double v) /*-{
-    return @java.math.BigInteger::valueOf(D)(v);
-  }-*/;
-}
\ No newline at end of file