Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4946108
Votes 0
Synopsis Duration.multiply() does not throw IllegalStateException for 1 year * 0.5
Category jaxp:other
Reported Against tiger-beta
Release Fixed 1.3, 1.5(tiger-b30) (Bug ID:2076566)
State 10-Fix Delivered, Needs Verification, bug
Priority: 3-Medium
Related Bugs
Submit Date 30-OCT-2003
Description


 
  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
----------------------------------------------------

======================================================================
Work Around
N/A
Evaluation
This was a javadoc bug. 1 year * 0.5 should be 6 months.

  xxxxx@xxxxx   2003-10-31
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang