1From NetBSD http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/lang/openjdk7/hacks.mk
2Work around incorrect constant folding of subnormals in javac when the FPU
3does not handle subnormal arithmetic, like on ARM in flush-to-zero mode.
4These workarounds avoid underflow conditions during the bootstrap so the JDK
5can correctly build itself.  Compiling or running programs other than OpenJDK
6itself on such hardware may still cause unexpected behaviour.
7
8--- jdk/src/share/classes/java/lang/Double.java.orig	2014-03-04 02:57:59 UTC
9+++ jdk/src/share/classes/java/lang/Double.java
10@@ -86,7 +86,7 @@ public final class Double extends Number
11      *
12      * @since 1.6
13      */
14-    public static final double MIN_NORMAL = 0x1.0p-1022; // 2.2250738585072014E-308
15+    public static final double MIN_NORMAL = Double.longBitsToDouble(0x10000000000000L); // 2.2250738585072014E-308
16
17     /**
18      * A constant holding the smallest positive nonzero value of type
19@@ -95,7 +95,7 @@ public final class Double extends Number
20      * {@code 0x0.0000000000001P-1022} and also equal to
21      * {@code Double.longBitsToDouble(0x1L)}.
22      */
23-    public static final double MIN_VALUE = 0x0.0000000000001P-1022; // 4.9e-324
24+    public static final double MIN_VALUE = Double.longBitsToDouble(0x1L); // 4.9e-324
25
26     /**
27      * Maximum exponent a finite {@code double} variable may have.
28--- jdk/src/share/classes/java/lang/Float.java.orig	2014-03-04 02:57:59 UTC
29+++ jdk/src/share/classes/java/lang/Float.java
30@@ -85,7 +85,7 @@ public final class Float extends Number
31      *
32      * @since 1.6
33      */
34-    public static final float MIN_NORMAL = 0x1.0p-126f; // 1.17549435E-38f
35+    public static final float MIN_NORMAL = Float.intBitsToFloat(0x800000); // 1.17549435E-38f
36
37     /**
38      * A constant holding the smallest positive nonzero value of type
39@@ -93,7 +93,7 @@ public final class Float extends Number
40      * hexadecimal floating-point literal {@code 0x0.000002P-126f}
41      * and also equal to {@code Float.intBitsToFloat(0x1)}.
42      */
43-    public static final float MIN_VALUE = 0x0.000002P-126f; // 1.4e-45f
44+    public static final float MIN_VALUE = Float.intBitsToFloat(0x1); // 1.4e-45f
45
46     /**
47      * Maximum exponent a finite {@code float} variable may have.  It
48--- jdk/src/share/classes/sun/misc/DoubleConsts.java.orig	2014-03-04 02:58:49 UTC
49+++ jdk/src/share/classes/sun/misc/DoubleConsts.java
50@@ -52,7 +52,7 @@ public class DoubleConsts {
51      *
52      * @since 1.5
53      */
54-    public static final double  MIN_NORMAL      = 2.2250738585072014E-308;
55+    public static final double  MIN_NORMAL      = Double.longBitsToDouble(0x10000000000000L);
56
57
58     /**
59--- jdk/src/share/classes/sun/misc/FloatConsts.java.orig	2014-03-04 02:58:49 UTC
60+++ jdk/src/share/classes/sun/misc/FloatConsts.java
61@@ -49,7 +49,7 @@ public class FloatConsts {
62      * <code>float</code>, 2<sup>-126</sup>.  It is equal to the value
63      * returned by <code>Float.intBitsToFloat(0x00800000)</code>.
64      */
65-    public static final float   MIN_NORMAL      = 1.17549435E-38f;
66+    public static final float   MIN_NORMAL      = Float.intBitsToFloat(0x800000);
67
68     /**
69      * The number of logical bits in the significand of a
70--- langtools/src/share/classes/com/sun/tools/javac/jvm/Items.java.orig	2014-03-04 02:51:48 UTC
71+++ langtools/src/share/classes/com/sun/tools/javac/jvm/Items.java
72@@ -623,12 +623,12 @@ public class Items {
73             /** Return true iff float number is positive 0.
74              */
75             private boolean isPosZero(float x) {
76-                return x == 0.0f && 1.0f / x > 0.0f;
77+                return Float.floatToIntBits(x) == 0x0;
78             }
79             /** Return true iff double number is positive 0.
80              */
81             private boolean isPosZero(double x) {
82-                return x == 0.0d && 1.0d / x > 0.0d;
83+                return Double.doubleToLongBits(x) == 0x0L;
84             }
85
86         CondItem mkCond() {
87--- langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java.orig	2015-09-29 16:38:49 UTC
88+++ langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java
89@@ -703,7 +703,7 @@ public class JavacParser implements Pars
90                 // error already reported in scanner
91                 n = Float.NaN;
92             }
93-            if (n.floatValue() == 0.0f && !isZero(proper))
94+            if (n.floatValue() == 0.0f && !isZero(proper) && Float.floatToIntBits(n) != 0x1)
95                 error(token.pos, "fp.number.too.small");
96             else if (n.floatValue() == Float.POSITIVE_INFINITY)
97                 error(token.pos, "fp.number.too.large");
98@@ -722,7 +722,7 @@ public class JavacParser implements Pars
99                 // error already reported in scanner
100                 n = Double.NaN;
101             }
102-            if (n.doubleValue() == 0.0d && !isZero(proper))
103+            if (n.doubleValue() == 0.0d && !isZero(proper) && Double.doubleToLongBits(n) != 0x1L)
104                 error(token.pos, "fp.number.too.small");
105             else if (n.doubleValue() == Double.POSITIVE_INFINITY)
106                 error(token.pos, "fp.number.too.large");
107