Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2083102 | 5.0 | Jeff Suttor | P3 | Resolved | Fixed | beta2 |
Name: erR10175 Date: 04/30/2004
The following methods in the class javax.xml.datatype.XMLGregorianCalendar
public static XMLGregorianCalendar createDateTime(BigInteger year, int month, int day,
int hours, int minutes, int seconds, BigDecimal fractionalSecond, int timezone)
public static XMLGregorianCalendar createDateTime(int year, int month, int day,
int hour, int minute, int second)
public static XMLGregorianCalendar createDateTime(int year, int month, int day,
int hours, int minutes, int seconds, int milliseconds, int timezone)
public static XMLGregorianCalendar createDate(int year, int month, int day, int timezone)
public static XMLGregorianCalendar createTime(int hours, int minutes, int seconds,
int timezone)
public static XMLGregorianCalendar createTime(int hours, int minutes, int seconds,
BigDecimal fractionalSecond, int timezone)
public static XMLGregorianCalendar createTime(int hours, int minutes, int seconds,
int milliseconds, int timezone)
public static XMLGregorianCalendar parse(String lexicalRepresentation)
public Object clone()
throw IllegalArgumentException if created XMLGregorianCalendar is invalid despite of
all its fields satisfy the corresponding maximum value constraints (e.g. 29th February
of a non-leap year).
The javadoc of the the class reads:
"
All maximum value space constraints listed for the fields in the table above are checked
by factory methods, setter methods and parse methods of this class. IllegalArgumentException
is thrown when parameter's value is outside the maximum value constraint for the field.
Validation checks, for example, whether days in month should be limited to 29, 30 or 31 days,
that are dependent on the values of other fields are not checked by these methods.
"
According to the javadoc the validation checks are not checked by these methods so these
methods may throw IllegalArgumentException only if some field doesn't satisfy the
maximum value constraint. The isValid() method is purposed for the validation checks.
The bug affects the following new JCK-15 beta2 tests:
api/javax_xml/datatype/XMLGregorianCalendar/index.html#IsValid[IsValid001]
api/javax_xml/datatype/XMLGregorianCalendar/index.html#IsValid[IsValid002]
The bug is found in jdk1.5.0/beta2/b49.
To reproduce the bug compile and run the following code as shown in the log below.
------------------------------------------ test.java
import javax.xml.datatype.XMLGregorianCalendar;
import java.math.BigInteger;
import java.math.BigDecimal;
class test {
public static void main(String [] args) throws Exception {
XMLGregorianCalendar.createDateTime(new BigInteger("2001"), 2, 29
, 0, 0, 0, new BigDecimal(0), 0);
XMLGregorianCalendar.createDateTime(2001, 2, 29, 0, 0, 0);
XMLGregorianCalendar.createDateTime(2001, 2, 29
, 0, 0, 0, 0, 0);
XMLGregorianCalendar.createDate(2001, 2, 29, 0);
XMLGregorianCalendar.createTime(24, 1, 1, 0);
XMLGregorianCalendar.createTime(24, 1, 1, new BigDecimal(0), 0);
XMLGregorianCalendar.createTime(24, 1, 1, 0, 0);
XMLGregorianCalendar.parse("2001-02-29");
XMLGregorianCalendar.parse("2001-02-29").clone();
System.out.println("OK");
}
}
----------------------------------------------------
------------------------------------------------ log
$javac test.java && java -showversion test
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b49)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b49, mixed mode)
Exception in thread "main" java.lang.IllegalArgumentException: year = 2001, month = 2, day = 29, hour = 0, minute = 0, second = 0, fractionalSecond = 0, timezone = 0, is not a valid representation of an XML Gregorian Calendar value.
at javax.xml.datatype.XMLGregorianCalendar.<init>(XMLGregorianCalendar.java:602)
at javax.xml.datatype.XMLGregorianCalendar.createDateTime(XMLGregorianCalendar.java:699)
at test.main(test.java:7)
----------------------------------------------------
======================================================================
The following methods in the class javax.xml.datatype.XMLGregorianCalendar
public static XMLGregorianCalendar createDateTime(BigInteger year, int month, int day,
int hours, int minutes, int seconds, BigDecimal fractionalSecond, int timezone)
public static XMLGregorianCalendar createDateTime(int year, int month, int day,
int hour, int minute, int second)
public static XMLGregorianCalendar createDateTime(int year, int month, int day,
int hours, int minutes, int seconds, int milliseconds, int timezone)
public static XMLGregorianCalendar createDate(int year, int month, int day, int timezone)
public static XMLGregorianCalendar createTime(int hours, int minutes, int seconds,
int timezone)
public static XMLGregorianCalendar createTime(int hours, int minutes, int seconds,
BigDecimal fractionalSecond, int timezone)
public static XMLGregorianCalendar createTime(int hours, int minutes, int seconds,
int milliseconds, int timezone)
public static XMLGregorianCalendar parse(String lexicalRepresentation)
public Object clone()
throw IllegalArgumentException if created XMLGregorianCalendar is invalid despite of
all its fields satisfy the corresponding maximum value constraints (e.g. 29th February
of a non-leap year).
The javadoc of the the class reads:
"
All maximum value space constraints listed for the fields in the table above are checked
by factory methods, setter methods and parse methods of this class. IllegalArgumentException
is thrown when parameter's value is outside the maximum value constraint for the field.
Validation checks, for example, whether days in month should be limited to 29, 30 or 31 days,
that are dependent on the values of other fields are not checked by these methods.
"
According to the javadoc the validation checks are not checked by these methods so these
methods may throw IllegalArgumentException only if some field doesn't satisfy the
maximum value constraint. The isValid() method is purposed for the validation checks.
The bug affects the following new JCK-15 beta2 tests:
api/javax_xml/datatype/XMLGregorianCalendar/index.html#IsValid[IsValid001]
api/javax_xml/datatype/XMLGregorianCalendar/index.html#IsValid[IsValid002]
The bug is found in jdk1.5.0/beta2/b49.
To reproduce the bug compile and run the following code as shown in the log below.
------------------------------------------ test.java
import javax.xml.datatype.XMLGregorianCalendar;
import java.math.BigInteger;
import java.math.BigDecimal;
class test {
public static void main(String [] args) throws Exception {
XMLGregorianCalendar.createDateTime(new BigInteger("2001"), 2, 29
, 0, 0, 0, new BigDecimal(0), 0);
XMLGregorianCalendar.createDateTime(2001, 2, 29, 0, 0, 0);
XMLGregorianCalendar.createDateTime(2001, 2, 29
, 0, 0, 0, 0, 0);
XMLGregorianCalendar.createDate(2001, 2, 29, 0);
XMLGregorianCalendar.createTime(24, 1, 1, 0);
XMLGregorianCalendar.createTime(24, 1, 1, new BigDecimal(0), 0);
XMLGregorianCalendar.createTime(24, 1, 1, 0, 0);
XMLGregorianCalendar.parse("2001-02-29");
XMLGregorianCalendar.parse("2001-02-29").clone();
System.out.println("OK");
}
}
----------------------------------------------------
------------------------------------------------ log
$javac test.java && java -showversion test
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b49)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b49, mixed mode)
Exception in thread "main" java.lang.IllegalArgumentException: year = 2001, month = 2, day = 29, hour = 0, minute = 0, second = 0, fractionalSecond = 0, timezone = 0, is not a valid representation of an XML Gregorian Calendar value.
at javax.xml.datatype.XMLGregorianCalendar.<init>(XMLGregorianCalendar.java:602)
at javax.xml.datatype.XMLGregorianCalendar.createDateTime(XMLGregorianCalendar.java:699)
at test.main(test.java:7)
----------------------------------------------------
======================================================================
- backported by
-
JDK-2083102 XMLGregorianCalendar factory and parse methods shouldn't validate instance
- Resolved
- relates to
-
JDK-5060307 wrong DatatypeFactory mention in XMLGregorianCalendar spec
- Resolved