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

XMLGregorianCalendar.toString throws IllegalStateException

    Details

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

      Backports

        Description

        Name: erR10175 Date: 05/18/2004



         The following method of the class javax.xml.datatype.XMLGregorianCalendar

        public String toString()

        throws IllegalStateException if the XMLGregorianCalendar instance does not
        represent any XML Schema datatype.

        The javadoc of the method specifies no exception to be thrown.

        This bug affects new test in JCK 1.5
          api/javax_xml/datatype/XMLGregorianCalendar/index.html#ToXML[ToString001]

        The bug is found in jdk1.5.0/beta/b51.

        To reproduce the bug compile and run test.java as shown in the log below:
        ------------------------------------------ test.java
        import javax.xml.datatype.XMLGregorianCalendar;
        import javax.xml.datatype.DatatypeFactory;
        import javax.xml.datatype.DatatypeConstants;

        class test {

            static final int undef = DatatypeConstants.FIELD_UNDEFINED;
            static final int [][] values = {
                {undef, undef, undef, undef, undef, undef},
                {1970, 1, 1, 0, 0, 0}, // ok
                {1970, 1, 1, 0, 0, undef},
                {1970, 1, 1, 0, undef, 0},
                {1970, 1, 1, undef, 0, 0},
                {1970, 1, undef, 0, 0, 0},
                {1970, undef, 1, 0, 0, 0},
                {undef, 1, 1, 0, 0, 0},
                {1970, 1, 1, 0, undef, undef},
                {1970, 1, 1, undef, 0, undef},
                {1970, 1, undef, 0, 0, undef},
                {1970, undef, 1, 0, 0, undef},
                {undef, 1, 1, 0, undef, 0},
                {1970, undef, 1, undef, 1, undef},
            };

            public static void main(String [] args) throws Exception {
                DatatypeFactory df = DatatypeFactory.newInstance();
                String status = "Passed.";

                for(int i = 0; i < values.length; ++i) {
                    XMLGregorianCalendar calendar
                        = i != 0
                        ? df.newXMLGregorianCalendar(
                            values[i][0], values[i][1], values[i][2],
                            values[i][3], values[i][4], values[i][5],
                            undef, undef)
                        : df.newXMLGregorianCalendar();
                    try {
                        String returned = calendar.toString();
                    } catch (Exception e) {
                        System.out.println(i + ": " + e);
                        status = "Failed.";
                    }
                }
                System.out.println(status);
            }
        }
        ----------------------------------------------------

        ------------------------------------------------ log
        $javac test.java && java -cp . -showversion test
        java version "1.5.0-beta2"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b51)
        Java HotSpot(TM) Client VM (build 1.5.0-beta2-b51, mixed mode)

        0: java.lang.IllegalStateException: invalid set of fields set for XMLGregorianCalendar
        2: java.lang.IllegalStateException: invalid set of fields set for XMLGregorianCalendar
        3: java.lang.IllegalStateException: invalid set of fields set for XMLGregorianCalendar
        4: java.lang.IllegalStateException: invalid set of fields set for XMLGregorianCalendar
        5: java.lang.IllegalStateException: invalid set of fields set for XMLGregorianCalendar
        6: java.lang.IllegalStateException: invalid set of fields set for XMLGregorianCalendar
        7: java.lang.IllegalStateException: invalid set of fields set for XMLGregorianCalendar
        8: java.lang.IllegalStateException: invalid set of fields set for XMLGregorianCalendar
        9: java.lang.IllegalStateException: invalid set of fields set for XMLGregorianCalendar
        10: java.lang.IllegalStateException: invalid set of fields set for XMLGregorianCalendar
        11: java.lang.IllegalStateException: invalid set of fields set for XMLGregorianCalendar
        12: java.lang.IllegalStateException: invalid set of fields set for XMLGregorianCalendar
        13: java.lang.IllegalStateException: invalid set of fields set for XMLGregorianCalendar
        Failed.
        ----------------------------------------------------

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

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  jsuttorsunw Jeff Suttor (Inactive)
                  Reporter:
                  reysunw Rey Rey (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: