diff options
author | Chris Laplante <chris.laplante@agilent.com> | 2019-11-06 13:41:35 -0500 |
---|---|---|
committer | Richard Leitner <richard.leitner@skidata.com> | 2019-11-11 09:34:59 +0100 |
commit | 8089e738f40ef630fe34568fe3688ce1d8244d28 (patch) | |
tree | 11bf6d1b1cb14582915765a5582774436c3b09b1 | |
parent | b5db760e6a6048381301414be387c08a3025dc6e (diff) | |
download | meta-java-8089e738f40ef630fe34568fe3688ce1d8244d28.tar.gz |
classpath: add patch to fix BigDecimal.stripTrailingZeros()'s handling of 0.
Previously, 'new BigDecimal("0").stripTrailingZeros()' would blow up:
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.charAt
at java.math.BigDecimal.stripTrailingZeros
Fixes https://sourceforge.net/p/saxon/mailman/message/27204592/
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/0002-Fix-BigDecimal.stripTrailingZeros-s-handling-of-0.patch | 51 | ||||
-rw-r--r-- | recipes-core/classpath/classpath-native_0.99.bb | 1 |
2 files changed, 52 insertions, 0 deletions
diff --git a/recipes-core/classpath/classpath-0.99/0002-Fix-BigDecimal.stripTrailingZeros-s-handling-of-0.patch b/recipes-core/classpath/classpath-0.99/0002-Fix-BigDecimal.stripTrailingZeros-s-handling-of-0.patch new file mode 100644 index 0000000..645b010 --- /dev/null +++ b/recipes-core/classpath/classpath-0.99/0002-Fix-BigDecimal.stripTrailingZeros-s-handling-of-0.patch | |||
@@ -0,0 +1,51 @@ | |||
1 | From 14fa6fc320eb84d0adb9ae00dd66ddb1caaae2a6 Mon Sep 17 00:00:00 2001 | ||
2 | From: Chris Laplante <chris.laplante@agilent.com> | ||
3 | Date: Wed, 2 Oct 2019 21:46:01 -0400 | ||
4 | Subject: [PATCH 2/2] Fix BigDecimal.stripTrailingZeros()'s handling of 0. | ||
5 | |||
6 | Previously, 'new BigDecimal("0").stripTrailingZeros()' would blow up: | ||
7 | |||
8 | Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1 | ||
9 | at java.lang.String.charAt | ||
10 | at java.math.BigDecimal.stripTrailingZeros | ||
11 | |||
12 | Fixes https://sourceforge.net/p/saxon/mailman/message/27204592/ | ||
13 | |||
14 | Upstream-Status: Inappropriate [dead project] | ||
15 | |||
16 | Signed-off-by: Chris Laplante <chris.laplante@agilent.com> | ||
17 | --- | ||
18 | java/math/BigDecimal.java | 7 ++++++- | ||
19 | 1 file changed, 6 insertions(+), 1 deletion(-) | ||
20 | |||
21 | diff --git a/java/math/BigDecimal.java b/java/math/BigDecimal.java | ||
22 | index e14d894..5e30f1c 100644 | ||
23 | --- a/java/math/BigDecimal.java | ||
24 | +++ b/java/math/BigDecimal.java | ||
25 | @@ -1335,17 +1335,22 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> | ||
26 | */ | ||
27 | public BigDecimal stripTrailingZeros() | ||
28 | { | ||
29 | + if (intVal.intValue() == 0) | ||
30 | + return ZERO; | ||
31 | + | ||
32 | String intValStr = intVal.toString(); | ||
33 | int newScale = scale; | ||
34 | int pointer = intValStr.length() - 1; | ||
35 | + | ||
36 | // This loop adjusts pointer which will be used to give us the substring | ||
37 | // of intValStr to use in our new BigDecimal, and also accordingly | ||
38 | // adjusts the scale of our new BigDecimal. | ||
39 | - while (intValStr.charAt(pointer) == '0') | ||
40 | + while (pointer >= 0 && intValStr.charAt(pointer) == '0') | ||
41 | { | ||
42 | pointer --; | ||
43 | newScale --; | ||
44 | } | ||
45 | + | ||
46 | // Create a new BigDecimal with the appropriate substring and then | ||
47 | // set its scale. | ||
48 | BigDecimal result = new BigDecimal(intValStr.substring(0, pointer + 1)); | ||
49 | -- | ||
50 | 2.7.4 | ||
51 | |||
diff --git a/recipes-core/classpath/classpath-native_0.99.bb b/recipes-core/classpath/classpath-native_0.99.bb index 93d67b2..daf7611 100644 --- a/recipes-core/classpath/classpath-native_0.99.bb +++ b/recipes-core/classpath/classpath-native_0.99.bb | |||
@@ -11,6 +11,7 @@ SRC_URI += " \ | |||
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 | file://0001-Fix-bad-implementation-of-compareTo-in-BigDecimal.patch \ |
14 | file://0002-Fix-BigDecimal.stripTrailingZeros-s-handling-of-0.patch \ | ||
14 | " | 15 | " |
15 | SRC_URI[md5sum] = "0ae1571249172acd82488724a3b8acb4" | 16 | SRC_URI[md5sum] = "0ae1571249172acd82488724a3b8acb4" |
16 | SRC_URI[sha256sum] = "f929297f8ae9b613a1a167e231566861893260651d913ad9b6c11933895fecc8" | 17 | SRC_URI[sha256sum] = "f929297f8ae9b613a1a167e231566861893260651d913ad9b6c11933895fecc8" |