Index: modules/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java =================================================================== --- modules/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java.orig 2006-05-22 18:42:44.000000000 +0100 +++ modules/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java 2006-05-22 19:48:01.000000000 +0100 @@ -111,10 +111,20 @@ if (end + 1 == length) throw new NumberFormatException(s); - if (s.charAt(end + 1) == '+') - e = Integer.parseInt(s.substring(end + 2, length)); - else - e = Integer.parseInt(s.substring(end + 1, length)); + int exponent_offset = end + 1; + if (s.charAt(exponent_offset) == '+') { + if (s.charAt(exponent_offset + 1) == '-') { + throw new NumberFormatException(s); + } + exponent_offset++; // skip the plus sign + } + try { + e = Integer.parseInt(s.substring(exponent_offset, + length)); + } catch (NumberFormatException ex) { + throw new NumberFormatException(s); + } + } else { end = length; } Index: modules/luni/src/test/java/tests/api/java/lang/DoubleTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/DoubleTest.java.orig 2006-05-22 18:42:12.000000000 +0100 +++ modules/luni/src/test/java/tests/api/java/lang/DoubleTest.java 2006-05-22 19:02:18.000000000 +0100 @@ -303,6 +303,14 @@ Double d = new Double("39089.88888888888888888888888888888888"); assertEquals("Created incorrect double", 39089.88888888888888888888888888888888, d.doubleValue()); + + // REGRESSION for HARMONY-489 + try { + d = new Double("1E+-20"); + fail("new Double(\"1E+-20\") should throw exception"); + } catch (NumberFormatException e) { + // expected + } } /**