Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2076566 | 5.0 | Kohsuke Kawaguchi | P3 | Closed | Fixed | b30 |
Name: erR10175 Date: 10/30/2003
The method javax.xml.datatype.Duration.multiply(BigDecimal factor)
does not throw IllegalStateException if 1 year is multiplied by 0.5.
The documentation of the method reads:
"An IllegalStateException is thrown If the operation produces fraction
in the months or year field. For example if you multiple one month or
year by 0.5."
So, even if 1 year * 0.5 is exactly 6 months, the method must throw
IllegalStateException, to conform to the doc, because 0.5 years has
a fraction part.
This bug affects new test in JCK 1.5 (not yet integrated)
api/javax_xml/datatype/Duration/index.html#DurationTests[Multiply003]
The bug is found in jdk1.5.0/beta/b25.
To reproduce the bug compile and run the following code as shown
in the log below:
------------------------------ test.java
import javax.xml.datatype.Duration;
import java.math.BigDecimal;
public class test {
public static void main(String [] args) {
System.out.println("new Duration(\"P1Y\")"
+".multiply(new BigDecimal(\"0.5\")) returns "
+ new Duration("P1Y").multiply(new BigDecimal("0.5"))
+ ", expected IllegalStateException");
}
}
----------------------------------------------------
------------------------------------------------ log
$javac test.java && java -cp . -showversion test
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b25)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b25, mixed mode)
new Duration("P1Y").multiply(new BigDecimal("0.5")) returns P0Y6M, expected IllegalStateException
----------------------------------------------------
======================================================================
The method javax.xml.datatype.Duration.multiply(BigDecimal factor)
does not throw IllegalStateException if 1 year is multiplied by 0.5.
The documentation of the method reads:
"An IllegalStateException is thrown If the operation produces fraction
in the months or year field. For example if you multiple one month or
year by 0.5."
So, even if 1 year * 0.5 is exactly 6 months, the method must throw
IllegalStateException, to conform to the doc, because 0.5 years has
a fraction part.
This bug affects new test in JCK 1.5 (not yet integrated)
api/javax_xml/datatype/Duration/index.html#DurationTests[Multiply003]
The bug is found in jdk1.5.0/beta/b25.
To reproduce the bug compile and run the following code as shown
in the log below:
------------------------------ test.java
import javax.xml.datatype.Duration;
import java.math.BigDecimal;
public class test {
public static void main(String [] args) {
System.out.println("new Duration(\"P1Y\")"
+".multiply(new BigDecimal(\"0.5\")) returns "
+ new Duration("P1Y").multiply(new BigDecimal("0.5"))
+ ", expected IllegalStateException");
}
}
----------------------------------------------------
------------------------------------------------ log
$javac test.java && java -cp . -showversion test
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b25)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b25, mixed mode)
new Duration("P1Y").multiply(new BigDecimal("0.5")) returns P0Y6M, expected IllegalStateException
----------------------------------------------------
======================================================================
- backported by
-
JDK-2076566 Duration.multiply() does not throw IllegalStateException for 1 year * 0.5
- Closed