Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4941653

javax.xml.datatype.Duration("P1M").multiply(-1) throws IllegalArgumentException

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.3
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        Name: erR10175 Date: 10/22/2003



          Method javax.xml.datatype.Duration.multiply(int factor) throws
        IllegalArgumentException if the factor is negative.

        The documentation of the method does not explicitly forbid
        to use negative values for the argument 'factor'. Besides
        IllegalArgumentException is not specified to be throwable by the
        method. So the expected befaviour is to change the sign of the
        duration object and multiply it with the absolute value of
        the factor.

        This bug affects new test in JCK 1.5 (not yet integrated)
           api/javax_xml/datatype/Duration/index.html#DurationTests[Multiply001]

        To reproduce the bug compile and run the following code as shown
        in the log below:
        ------------------------------ test.java
        import javax.xml.datatype.Duration;

        public class test {
            public static void main(String [] args) {
                Duration d = new Duration("-PT1M");
                d.multiply(-1);
            }
        }
        ----------------------------------------------------

        ------------------------------------------------ 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-b24)
        Java HotSpot(TM) Server VM (build 1.5.0-beta-b24, mixed mode)

        Exception in thread "main" java.lang.IllegalArgumentException: MINUTES is negative
                at javax.xml.datatype.Duration.testNonNegative(Duration.java:200)
                at javax.xml.datatype.Duration.<init>(Duration.java:190)
                at javax.xml.datatype.Duration.multiply(Duration.java:1005)
                at javax.xml.datatype.Duration.multiply(Duration.java:929)
                at test.main(test.java:6)
        ----------------------------------------------------

        ======================================================================

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                kkawagucsunw Kohsuke Kawaguchi (Inactive)
                Reporter:
                reysunw Rey Rey (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: