8191306: Math.abs corner case with optimistic typing

Reviewed-by: jlaskey, hannesw
This commit is contained in:
Athijegannathan Sundararajan 2017-11-15 19:55:21 +05:30
parent 616491477f
commit f441abcff1
3 changed files with 36 additions and 2 deletions

View file

@ -105,8 +105,8 @@ public final class NativeMath extends ScriptObject {
* @return abs of argument
*/
@SpecializedFunction
public static int abs(final Object self, final int x) {
return Math.abs(x);
public static double abs(final Object self, final int x) {
return x == Integer.MIN_VALUE? Math.abs((double)x) : Math.abs(x);
}
/**