From 8089e738f40ef630fe34568fe3688ce1d8244d28 Mon Sep 17 00:00:00 2001 From: Chris Laplante Date: Wed, 6 Nov 2019 13:41:35 -0500 Subject: 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 Signed-off-by: Richard Leitner --- ...ecimal.stripTrailingZeros-s-handling-of-0.patch | 51 ++++++++++++++++++++++ recipes-core/classpath/classpath-native_0.99.bb | 1 + 2 files changed, 52 insertions(+) create mode 100644 recipes-core/classpath/classpath-0.99/0002-Fix-BigDecimal.stripTrailingZeros-s-handling-of-0.patch 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 +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 +--- + 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 + */ + 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" -- cgit v1.2.3-54-g00ecf