-
Bug
-
Resolution: Fixed
-
P3
-
1.1.4
-
1.1.6
-
sparc
-
solaris_2.5
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2017731 | 1.2.0 | John Oconner | P3 | Closed | Fixed | 1.2beta4 |
Name: dfC67450 Date: 11/04/97
java.text.DecimalFormat.format(double n, StringBuffer str, FieldPosition fp) throws
unexpected ArrayIndexOutOfBoundsException if maximumFractionDigits setting is
greater than some limit. This limit depends on value of n.
Here is the test demonstrating the bug:
-----------------Test.java------------------------
import java.text.*;
import java.math.*;
public class Test {
public static void main (String args[]){
double d = 1;
System.out.println("d = " + d);
DecimalFormat df = new DecimalFormat();
StringBuffer sb;
FieldPosition fp;
for (int i = 17; i <= 20; i++) {
df.setMaximumFractionDigits(i);
sb = new StringBuffer("");
fp = new FieldPosition(0);
System.out.println(" getMaximumFractionDigits() = " + i);
System.out.println(" formated: " + df.format(d, sb, fp));
System.out.println();
}
}
}
---------Output from the test---------------------
d = 1.0
getMaximumFractionDigits() = 17
formated: 1
getMaximumFractionDigits() = 18
formated: 1
getMaximumFractionDigits() = 19
formated: 0.9223372036854775807
getMaximumFractionDigits() = 20
java.lang.ArrayIndexOutOfBoundsException: 19
at java.text.DigitList.set(DigitList.java)
at java.text.DecimalFormat.format(DecimalFormat.java)
at Test2.main(Test2.java:15)
--------------------------------------------------
======================================================================
- backported by
-
JDK-2017731 java.text.DecimalFormat.format() throws unexpected exception
- Closed