summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Laplante <chris.laplante@agilent.com>2019-11-06 13:41:34 -0500
committerRichard Leitner <richard.leitner@skidata.com>2019-11-11 09:34:59 +0100
commitb5db760e6a6048381301414be387c08a3025dc6e (patch)
treed39d3810d95e8d906d03adf270bf6ae8a157092d
parent72d32b73861edeed08e9463ceb6e3995f1982be6 (diff)
downloadmeta-java-b5db760e6a6048381301414be387c08a3025dc6e.tar.gz
classpath: add patch to fix BigDecimal.compareTo()
Prior to this patch compareTo couldn't handle operands with negative scales. It passes the following unit test from JDK8: http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/tip/test/java/math/BigDecimal/CompareToTests.java Signed-off-by: Chris Laplante <chris.laplante@agilent.com> Signed-off-by: Richard Leitner <richard.leitner@skidata.com>
-rw-r--r--recipes-core/classpath/classpath-0.99/0001-Fix-bad-implementation-of-compareTo-in-BigDecimal.patch68
-rw-r--r--recipes-core/classpath/classpath-native_0.99.bb11
2 files changed, 74 insertions, 5 deletions
diff --git a/recipes-core/classpath/classpath-0.99/0001-Fix-bad-implementation-of-compareTo-in-BigDecimal.patch b/recipes-core/classpath/classpath-0.99/0001-Fix-bad-implementation-of-compareTo-in-BigDecimal.patch
new file mode 100644
index 0000000..35fb81e
--- /dev/null
+++ b/recipes-core/classpath/classpath-0.99/0001-Fix-bad-implementation-of-compareTo-in-BigDecimal.patch
@@ -0,0 +1,68 @@
1From b561cdb6f3fef251696216775c775f84369278cc Mon Sep 17 00:00:00 2001
2From: Chris Laplante <chris.laplante@agilent.com>
3Date: Wed, 2 Oct 2019 21:38:11 -0400
4Subject: [PATCH 1/2] Fix bad implementation of compareTo in BigDecimal
5
6Prior to this patch compareTo couldn't handle operands with negative
7scales. It passes the following unit test from JDK8:
8http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/tip/test/java/math/BigDecimal/CompareToTests.java
9
10Upstream-Status: Inappropriate [dead project]
11
12Signed-off-by: Chris Laplante <chris.laplante@agilent.com>
13---
14 java/math/BigDecimal.java | 32 ++++++++++++++++++--------------
15 1 file changed, 18 insertions(+), 14 deletions(-)
16
17diff --git a/java/math/BigDecimal.java b/java/math/BigDecimal.java
18index 7f4546c..e14d894 100644
19--- a/java/math/BigDecimal.java
20+++ b/java/math/BigDecimal.java
21@@ -861,26 +861,30 @@ public class BigDecimal extends Number implements Comparable<BigDecimal>
22 if (scale == val.scale)
23 return intVal.compareTo (val.intVal);
24
25- BigInteger thisParts[] =
26- intVal.divideAndRemainder (BigInteger.TEN.pow (scale));
27- BigInteger valParts[] =
28- val.intVal.divideAndRemainder (BigInteger.TEN.pow (val.scale));
29+ BigInteger[] thisParts = new BigInteger[2];
30+ BigInteger[] valParts = new BigInteger[2];
31+
32+ if (scale > 0)
33+ thisParts = intVal.divideAndRemainder (BigInteger.TEN.pow (scale));
34+ else
35+ {
36+ thisParts[0] = intVal.multiply (BigInteger.TEN.pow (-scale));
37+ thisParts[1] = BigInteger.ZERO;
38+ }
39+
40+ if (val.scale > 0)
41+ valParts = val.intVal.divideAndRemainder (BigInteger.TEN.pow (val.scale));
42+ else
43+ {
44+ valParts[0] = val.intVal.multiply (BigInteger.TEN.pow (-val.scale));
45+ valParts[1] = BigInteger.ZERO;
46+ }
47
48 int compare;
49 if ((compare = thisParts[0].compareTo (valParts[0])) != 0)
50 return compare;
51
52 // quotients are the same, so compare remainders
53-
54- // Add some trailing zeros to the remainder with the smallest scale
55- if (scale < val.scale)
56- thisParts[1] = thisParts[1].multiply
57- (BigInteger.valueOf (10).pow (val.scale - scale));
58- else if (scale > val.scale)
59- valParts[1] = valParts[1].multiply
60- (BigInteger.valueOf (10).pow (scale - val.scale));
61-
62- // and compare them
63 return thisParts[1].compareTo (valParts[1]);
64 }
65
66--
672.7.4
68
diff --git a/recipes-core/classpath/classpath-native_0.99.bb b/recipes-core/classpath/classpath-native_0.99.bb
index a1e1e0f..93d67b2 100644
--- a/recipes-core/classpath/classpath-native_0.99.bb
+++ b/recipes-core/classpath/classpath-native_0.99.bb
@@ -5,11 +5,12 @@ DEPENDS += "classpath-initial-native ecj-initial-native virtual/java-initial-nat
5PR = "${INC_PR}.0" 5PR = "${INC_PR}.0"
6 6
7SRC_URI += " \ 7SRC_URI += " \
8 file://sun-security-getproperty.patch;striplevel=0 \ 8 file://sun-security-getproperty.patch;striplevel=0 \
9 file://ecj_java_dir.patch \ 9 file://ecj_java_dir.patch \
10 file://autotools.patch \ 10 file://autotools.patch \
11 file://miscompilation.patch \ 11 file://miscompilation.patch \
12 file://toolwrapper-exithook.patch \ 12 file://toolwrapper-exithook.patch \
13 file://0001-Fix-bad-implementation-of-compareTo-in-BigDecimal.patch \
13 " 14 "
14SRC_URI[md5sum] = "0ae1571249172acd82488724a3b8acb4" 15SRC_URI[md5sum] = "0ae1571249172acd82488724a3b8acb4"
15SRC_URI[sha256sum] = "f929297f8ae9b613a1a167e231566861893260651d913ad9b6c11933895fecc8" 16SRC_URI[sha256sum] = "f929297f8ae9b613a1a167e231566861893260651d913ad9b6c11933895fecc8"