-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.3.0
-
sparc
-
solaris_2.5.1
Name: sdC67446 Date: 06/22/99
The behavior for methods:
public void setID(String ID)
public boolean hasSameRules(TimeZone other)
of class java.util.TimeZone in jdk1.3G has been changed since
jdk1.3F. The spec for these methods doesn't specify expected
behavior if input parameter (ID, other) == null.
Currently:
setID(null) throws NPE in Kestrel-G and doesn't in Kestrel-F;
hasSameRules(null) doesn't throw NPE in Kestrel-G and does in Kestrel-F;
Thus the jck1.3 test api/java/util/TimeZone/index.html#misc now fails.
The doc says:
-------------------------------------------------------------
/**
* Sets the time zone ID. This does not change any other data in
* the time zone object.
* @param ID the new time zone ID.
*/
public void setID(String ID)
/**
* Returns true if this zone has the same rule and offset as another zone.
* That is, if this zone differs only in ID, if at all.
* @param other the <code>TimeZone</code> object to be compared with
* @return true if the given zone is the same as this one,
* with the possible exception of the ID
*/
public boolean hasSameRules(TimeZone other)
The test demonstrating the bug:
-------------------------------------------------------------
import java.util.*;
public class DummyTimeZone extends TimeZone {
int offset;
boolean useDaylight;
DummyTimeZone() {
this("");
}
DummyTimeZone(String ID) {
this(ID, 0, false);
}
DummyTimeZone(String ID, int offset, boolean useDailight) {
setID(ID);
setRawOffset(offset);
this.useDaylight = useDaylight;
}
public void setRawOffset(int offset) {
this.offset = offset;
}
public int getRawOffset() {
return offset;
}
public boolean useDaylightTime() {
return useDaylight;
}
public boolean inDaylightTime(Date date) {
return useDaylight;
}
public int getOffset(int era, int year, int month,
int day, int dayOfWeek, int millis
) {
return useDaylight ? offset + 3600000 : offset;
}
public String toString() {
return "DummyTimeZone";
}
public static void main(String[] args) {
DummyTimeZone tz = new DummyTimeZone();
try {
tz.setID(null);
System.out.println("This is Kestrel F.");
} catch (NullPointerException e) {
System.out.println("This is Kestrel G.");
}
try {
tz.hasSameRules(null);
System.out.println("This is Kestrel G.");
} catch (NullPointerException e) {
System.out.println("This is Kestrel F.");
}
}
}
Test output:
-------------------------------------------------------------
] ###@###.### ~/jtest
] java -version
java version "1.3"
Classic VM (build JDK-1.3-F, green threads, sunwjit)
] ###@###.### ~/jtest
] java DummyTimeZone
This is Kestrel F.
This is Kestrel F.
.....
] ###@###.### ~/jtest
] java -version
java version "1.3"
Classic VM (build JDK-1.3-G, green threads, sunwjit)
] ###@###.### ~/jtest
] java DummyTimeZone
This is Kestrel G.
This is Kestrel G.
------------------------------------------------------------
======================================================================
- relates to
-
JDK-4159922 Unspecified behaviour of TimeZone.setID and SimpleTimeZone ctors in case of null
- Resolved