aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Laplante <chris.laplante@agilent.com>2019-11-06 13:41:35 -0500
committerRichard Leitner <richard.leitner@skidata.com>2019-11-11 09:34:59 +0100
commit8089e738f40ef630fe34568fe3688ce1d8244d28 (patch)
tree11bf6d1b1cb14582915765a5582774436c3b09b1
parentb5db760e6a6048381301414be387c08a3025dc6e (diff)
downloadmeta-java-master-next.tar.gz
meta-java-master-next.tar.bz2
meta-java-master-next.zip
classpath: add patch to fix BigDecimal.stripTrailingZeros()'s handling of 0.HEADmaster-nextmaster
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.patch51
-rw-r--r--recipes-core/classpath/classpath-native_0.99.bb1
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 @@
+From 14fa6fc320eb84d0adb9ae00dd66ddb1caaae2a6 Mon Sep 17 00:00:00 2001
+From: Chris Laplante <chris.laplante@agilent.com>
+Date: Wed, 2 Oct 2019 21:46:01 -0400
+Subject: [PATCH 2/2] 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/
+
+Upstream-Status: Inappropriate [dead project]
+
+Signed-off-by: Chris Laplante <chris.laplante@agilent.com>
+---
+ java/math/BigDecimal.java | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/java/math/BigDecimal.java b/java/math/BigDecimal.java
+index e14d894..5e30f1c 100644
+--- a/java/math/BigDecimal.java
++++ b/java/math/BigDecimal.java
+@@ -1335,17 +1335,22 @@ public class BigDecimal extends Number implements Comparable<BigDecimal>
+ */
+ public BigDecimal stripTrailingZeros()
+ {
++ if (intVal.intValue() == 0)
++ return ZERO;
++
+ String intValStr = intVal.toString();
+ int newScale = scale;
+ int pointer = intValStr.length() - 1;
++
+ // This loop adjusts pointer which will be used to give us the substring
+ // of intValStr to use in our new BigDecimal, and also accordingly
+ // adjusts the scale of our new BigDecimal.
+- while (intValStr.charAt(pointer) == '0')
++ while (pointer >= 0 && intValStr.charAt(pointer) == '0')
+ {
+ pointer --;
+ newScale --;
+ }
++
+ // Create a new BigDecimal with the appropriate substring and then
+ // set its scale.
+ BigDecimal result = new BigDecimal(intValStr.substring(0, pointer + 1));
+--
+2.7.4
+
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 += " \
file://miscompilation.patch \
file://toolwrapper-exithook.patch \
file://0001-Fix-bad-implementation-of-compareTo-in-BigDecimal.patch \
+ file://0002-Fix-BigDecimal.stripTrailingZeros-s-handling-of-0.patch \
"
SRC_URI[md5sum] = "0ae1571249172acd82488724a3b8acb4"
SRC_URI[sha256sum] = "f929297f8ae9b613a1a167e231566861893260651d913ad9b6c11933895fecc8"