diff options
| -rw-r--r-- | recipes-core/classpath/classpath-0.99/0001-Fix-bad-implementation-of-compareTo-in-BigDecimal.patch | 68 | ||||
| -rw-r--r-- | recipes-core/classpath/classpath-native_0.99.bb | 11 |
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 @@ | |||
| 1 | From b561cdb6f3fef251696216775c775f84369278cc Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Chris Laplante <chris.laplante@agilent.com> | ||
| 3 | Date: Wed, 2 Oct 2019 21:38:11 -0400 | ||
| 4 | Subject: [PATCH 1/2] Fix bad implementation of compareTo in BigDecimal | ||
| 5 | |||
| 6 | Prior to this patch compareTo couldn't handle operands with negative | ||
| 7 | scales. It passes the following unit test from JDK8: | ||
| 8 | http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/tip/test/java/math/BigDecimal/CompareToTests.java | ||
| 9 | |||
| 10 | Upstream-Status: Inappropriate [dead project] | ||
| 11 | |||
| 12 | Signed-off-by: Chris Laplante <chris.laplante@agilent.com> | ||
| 13 | --- | ||
| 14 | java/math/BigDecimal.java | 32 ++++++++++++++++++-------------- | ||
| 15 | 1 file changed, 18 insertions(+), 14 deletions(-) | ||
| 16 | |||
| 17 | diff --git a/java/math/BigDecimal.java b/java/math/BigDecimal.java | ||
| 18 | index 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 | -- | ||
| 67 | 2.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 | |||
| 5 | PR = "${INC_PR}.0" | 5 | PR = "${INC_PR}.0" |
| 6 | 6 | ||
| 7 | SRC_URI += " \ | 7 | SRC_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 | " |
| 14 | SRC_URI[md5sum] = "0ae1571249172acd82488724a3b8acb4" | 15 | SRC_URI[md5sum] = "0ae1571249172acd82488724a3b8acb4" |
| 15 | SRC_URI[sha256sum] = "f929297f8ae9b613a1a167e231566861893260651d913ad9b6c11933895fecc8" | 16 | SRC_URI[sha256sum] = "f929297f8ae9b613a1a167e231566861893260651d913ad9b6c11933895fecc8" |
