diffs for time and debugging

Patrick Tullmann tullmann at cs.utah.edu
Thu May 13 15:44:59 PDT 1999


Attached is a patch against the most recent CVS snapshot of Kaffe.  A
number of things are fixed/added. A couple of changes could be
interpreted as personal preferences, so feel free to drop them (or,
let me know and I'll send a new diff).

I was looking into the time/date printing problem, and got a bit
sidetracked.  I endup tweaking the intialization of the TimeZone and
Calendar stuff, and tweaking the default locale format for time/date
printing (to match that of JDK 1.1.7...).  I also had some debugging
changes to other parts of kaffe (networking mostly), so I've included
those. 

I tried to fix System.c to detect the local timezone (via time() +
localtime()).  But, that returns 'MDT' for my machine, and
SimpleTimeZone only groks 'MST' with daylight hacks.  I'm tempted to
have System.c change 'xDx' -> 'xSx' just to get this to work better.
Ah, well.  Any suggestions?  I left the change in so Kaffe will get
the right timezone 50% of the time...

-Pat

Here's a (long) change-log-style description.

1999-05-13  Patrick A Tullmann  <tullmann at cs.utah.edu>

	* configure.in: be verbose about static/shared libraries,
	add check for ctime() and localtime() (for timezone check).
	* kaffe/kaffevm/debug.c,kaffe/kaffevm/debug.h: add NATIVENET
	flag for debugging network accesses.
	* kaffe/kaffevm/lookup.c: add more printf for the MLOOKUP
	debug method
	* kaffe/kaffevm/stackTrace.c,kaffe/kaffevm/stackTrace.h:
	clean up stale debug stuff, change 0 to NULL.
	* kaffe/kaffevm/support.c: add a number of asserts for 
	sanity checking method lookups and invocations.
	* libraries/clib/native/System.c: try to figure out the
	local timezone via localtime().  Default to 'PST'.  Not perfect.
	* libraries/clib/net/PlainSocketImpl.c: add a lot of debugging
	support via NATIVENET switch.
	* libraries/javalib/Makefile.am: add '-q' to the ZIP command
	so that it doesn't list the contents as it zips.
	* libraries/javalib/rebuildLib.in: remove '-verbose' from the
	JAVAC command line.
	* libraries/javalib/java/lang/System.java: Tweak static
	initializer to init SimpleTimeZone and GregorianCalendar
	without wasting time/space creating objects.
	* libraries/javalib/java/text/SimpleDateFormat.java: change
	order of field modifiers (cosmetic).
	* libraries/javalib/java/util/GregorianCalendar.java: 
	directly create the desired Calendar, instead of generic one
	plus modification to it.
	* libraries/javalib/java/util/SimpleTimeZone.java: add 
	daylight savings info to MST description.
	* libraries/javalib/java/util/TimeZone.java: throw an
	InternalError() if a defaultTimeZone cannot be found.
	getTimeZone(): use Hashtable.get() instead of iteration to lookup
	a timezone.
	* libraries/javalib/kaffe/text/dateformat/locale_en_US.java:
	Tweak time and date formats to match JDK 1.1.7 formats.

Index: configure.in
===================================================================
RCS file: /home/cvspublic/kaffe/configure.in,v
diff -u -b -r1.100 configure.in
@@ -260,6 +260,14 @@
 AC_SUBST_FILE(engine_frag)dnl
 engine_frag=$srcdir/kaffe/kaffevm/$with_engine/Makefile.frag
 
+dnl =========================================================================
+
+AC_MSG_CHECKING(library type)
+if test "$dynamic_libraries" = "no" ; then
+	AC_MSG_RESULT(static)
+else
+	AC_MSG_RESULT(shared)
+fi
 AC_CHECK_FUNCS(getpagesize)
 
 dnl =========================================================================
@@ -676,6 +684,7 @@
 AC_CHECK_FUNCS(memcpy memmove)
 AC_CHECK_FUNCS(mkdir)
 AC_CHECK_FUNCS(getcwd getwd gettimeofday ftime time uname getuid)
+AC_CHECK_FUNCS(ctime localtime)
 
 KSAVE_LIBS="$LIBS"
 LIBS="$M_LIBS $LIBS"
Index: kaffe/kaffevm/debug.c
===================================================================
RCS file: /home/cvspublic/kaffe/kaffe/kaffevm/debug.c,v
diff -u -b -r1.19 debug.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998 The University of Utah. All rights reserved.
+ * Copyright (c) 1998, 1999 The University of Utah. All rights reserved.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file.
@@ -108,6 +108,7 @@
 	D(NEWOBJECT, 	"Show when new objects are allocated."),
 	D(FINALIZE, 	"Debug finalization."),
 	D(LIBTOOL, 	"Debug libtool stuff."),
+	D(NATIVENET,	"Show network accesses from the native code."),
 
 	/* you can define combinations too */
 	{ "lookup", DBG_MLOOKUP|DBG_ELOOKUP|DBG_FLOOKUP, 
Index: kaffe/kaffevm/debug.h
===================================================================
RCS file: /home/cvspublic/kaffe/kaffe/kaffevm/debug.h,v
diff -u -b -r1.18 debug.h
@@ -85,6 +85,7 @@
 # define DBG_NEWOBJECT		DBG_BIT(41)
 # define DBG_FINALIZE		DBG_BIT(42)
 # define DBG_LIBTOOL		DBG_BIT(43)
+# define DBG_NATIVENET		DBG_BIT(44)
 
 /* let's reserve 50-63 for temporary uses */
 # define DBG_SLACKANAL		DBG_BIT(50) 
Index: kaffe/kaffevm/lookup.c
===================================================================
RCS file: /home/cvspublic/kaffe/kaffe/kaffevm/lookup.c,v
diff -u -b -r1.12 lookup.c
@@ -223,6 +223,7 @@
 {
 	Method* mptr;
 	int n;
+
 	/*
 	 * Lookup method - this could be alot more efficient but never mind.
 	 * Also there is no attempt to honour PUBLIC, PRIVATE, etc.
@@ -234,10 +235,19 @@
 				SET_METHOD_NATIVECODE(mptr, (void*)throwAbstractMethodError);
 				mptr->accflags |= ACC_NATIVE;
 			}
+DBG(MLOOKUP,
+			dprintf("findMethodLocal(%s,%s,%s) -> %p\n",
+				class->name->data, name->data, signature->data, mptr); )
+
 			return (mptr);
 		}
 	}
-	return (0);
+
+DBG(MLOOKUP,
+	dprintf("findMethodLocal(%s,%s,%s) -> BZZZT\n",
+		class->name->data, name->data, signature->data, mptr); )
+
+	return NULL;
 }
 
 /*
Index: kaffe/kaffevm/stackTrace.c
===================================================================
RCS file: /home/cvspublic/kaffe/kaffe/kaffevm/stackTrace.c,v
diff -u -b -r1.10 stackTrace.c
@@ -9,8 +9,6 @@
  * of this file. 
  */
 
-#define	DBG(s)
-
 #include "config.h"
 #include "config-std.h"
 #include "config-signal.h"
Index: kaffe/kaffevm/stackTrace.h
===================================================================
RCS file: /home/cvspublic/kaffe/kaffe/kaffevm/stackTrace.h,v
diff -u -b -r1.6 stackTrace.h
@@ -52,7 +52,7 @@
 	}
 #define	STACKTRACESTEP(S)	((S).frame = nextFrame((S).frame))
 #define STACKTRACEPC(S)		(PCFRAME((S).frame))
-#define	STACKTRACEMETHCREATE(S)	(0)
+#define	STACKTRACEMETHCREATE(S)	(NULL)
 #define	STACKTRACEEND(S)	((S).frame == 0)
 
 #endif
Index: kaffe/kaffevm/support.c
===================================================================
RCS file: /home/cvspublic/kaffe/kaffe/kaffevm/support.c,v
diff -u -b -r1.33 support.c
@@ -65,6 +65,8 @@
 	errorInfo info;
 
 	if (mb == 0) {
+		assert(method_name);
+		assert(signature);
 		if (isStaticCall) {
 			mb = lookupClassMethod((Hjava_lang_Class*)obj, method_name, signature, &info);
 		}
@@ -72,6 +74,7 @@
 			mb = lookupObjectMethod((Hjava_lang_Object*)obj, method_name, signature, &info);
 		}
 	}
+
 	/* No method or wrong type - throw exception */
 	if (mb == 0) {
 		throwError(&info);
@@ -94,6 +97,8 @@
 	va_list argptr;
 	jvalue retval;
 
+	assert(method_name || mb);
+
 	va_start(argptr, isStaticCall);
 	retval = do_execute_java_method_v(obj, method_name, signature, mb, isStaticCall, argptr);
 	va_end(argptr);
@@ -686,6 +691,10 @@
 	Method *meth;
 	Utf8Const *name_utf8, *sig_utf8;
 
+	assert(cls);
+	assert(name);
+	assert(sig);
+
 	name_utf8 = utf8ConstNew(name, -1);
 	sig_utf8 = utf8ConstNew(sig, -1);
 	meth = findMethod(cls, name_utf8, sig_utf8, einfo);
@@ -700,6 +709,9 @@
 Method*
 lookupObjectMethod(Hjava_lang_Object* obj, const char* name, const char* sig, errorInfo *einfo)
 {
+	assert(obj);
+	assert(name);
+	assert(sig);
 	return (lookupClassMethod(OBJECT_CLASS(obj), name, sig, einfo));
 }
 
Index: libraries/clib/native/System.c
===================================================================
RCS file: /home/cvspublic/kaffe/libraries/clib/native/System.c,v
diff -u -b -r1.15 System.c
@@ -277,7 +277,25 @@
 	/* We should try to work this stuff out really - XXX */
 	setProperty(p, "user.language", "EN");
 	setProperty(p, "user.region", "US");
+
+	/* Figure out the local time zone. */
+#if defined(HAVE_CTIME) && defined(HAVE_LOCALTIME)
+	{
+		struct tm *timeODay;
+		time_t now;
+		if (-1 != time(&now))
+		{
+			timeODay = localtime(&now);
+			setProperty(p, "user.timezone", timeODay->tm_zone);
+		}
+		else
+		{
+			setProperty(p, "user.timezone", "PST");
+		}
+	}
+#else
 	setProperty(p, "user.timezone", "PST");
+#endif
 
 	setProperty(p, "file.encoding.pkg", "kaffe.io");
 	setProperty(p, "file.encoding", "Default");
Index: libraries/clib/net/PlainSocketImpl.c
===================================================================
RCS file: /home/cvspublic/kaffe/libraries/clib/net/PlainSocketImpl.c,v
diff -u -b -r1.14 PlainSocketImpl.c
@@ -22,6 +22,7 @@
 #include "java_net_SocketOptions.h"
 #include "nets.h"
 #include <jsyscall.h>
+#include "../../../kaffe/kaffevm/debug.h"
 
 /*
  * Supported socket options
@@ -48,6 +49,49 @@
 #endif
   };
 
+#ifdef DEBUG
+	static const struct {
+		int opt;
+		char *name;
+	} optionNames[] = {
+#ifdef SO_SNDBUF
+		{ java_net_SocketOptions_SO_SNDBUF, "SO_SNDBUF" },
+#endif
+#ifdef SO_RCVBUF
+		{ java_net_SocketOptions_SO_RCVBUF, "SO_RCVBUF" },
+#endif
+#ifdef SO_LINGER
+		{ java_net_SocketOptions_SO_LINGER, "SO_LINGER" },
+#endif
+#ifdef SO_REUSEADDR
+		{ java_net_SocketOptions_SO_REUSEADDR, "SO_REUSEADDR" },
+#endif
+#ifdef TCP_NODELAY
+		{ java_net_SocketOptions_TCP_NODELAY, "TCP_NODELAY" },
+#endif
+		{ java_net_SocketOptions_SO_BINDADDR, "SO_BINDADDR" },
+		{ java_net_SocketOptions_SO_TIMEOUT, "SO_TIMEOUT" },
+		{ java_net_SocketOptions_IP_MULTICAST_IF, "IP_MULTICAST_IF" }
+	};
+#endif /*DEBUG*/
+
+#ifdef DEBUG
+static char *
+addr2dottedfour(unsigned int addr) 
+{
+	static char addrbuf[(4 * 3) + 3];
+	unsigned int top = (addr >> 24);
+	unsigned int tmid = (addr >> 16) & 0xFF;
+	unsigned int bmid = (addr >> 8) & 0xFF;
+	unsigned int bottom = addr & 0xFF;
+
+	sprintf(addrbuf, "%u.%u.%u.%u", top, tmid, bmid, bottom);
+	return addrbuf;
+}
+#endif /* def DEBUG */
+
+
+
 /*
  * Create a stream or datagram socket.
  */
@@ -65,11 +109,21 @@
 		type = SOCK_STREAM;
 	}
 
+	DBG(NATIVENET,
+	    dprintf("socketCreate(%p, %s)\n", this, stream ? "stream" : "datagram");
+	    )
+
 	rc = KSOCKET(AF_INET, type, 0, &fd);
 	if (rc) {
 		unhand(unhand(this)->fd)->fd = -1;
 		SignalError("java.io.IOException", SYS_ERROR(rc));
 	}
+
+	DBG(NATIVENET,
+	    dprintf("socketCreate(%p, %s) -> fd=%d\n", 
+		    this, stream ? "stream" : "datagram", fd);
+	    )
+
 	unhand(unhand(this)->fd)->fd = fd;
 }
 
@@ -77,13 +131,20 @@
  * Connect the socket to someone.
  */
 void
-java_net_PlainSocketImpl_socketConnect(struct Hjava_net_PlainSocketImpl* this, struct Hjava_net_InetAddress* daddr, jint dport)
+java_net_PlainSocketImpl_socketConnect(struct Hjava_net_PlainSocketImpl* this,
+				       struct Hjava_net_InetAddress* daddr, 
+				       jint dport)
 {
 	int fd;
 	int r;
 	struct sockaddr_in addr;
 	size_t alen;
 
+	DBG(NATIVENET,
+	    dprintf("socketConnect(%p, %s, %d)\n", 
+		    this, addr2dottedfour(unhand(daddr)->address), dport);
+	    )
+
 	memset(&addr, 0, sizeof(addr));
 #if defined(BSD44)
 	addr.sin_len = sizeof(addr);
@@ -105,6 +166,13 @@
 		SignalError("java.io.IOException", SYS_ERROR(r));
 	}
 
+	DBG(NATIVENET,
+	    dprintf("socketConnect(%p, %s, %d) -> (lport: %d)\n",
+		    this, addr2dottedfour(unhand(daddr)->address), dport,
+		    ntohs(addr.sin_port)
+		    );
+	    )
+
 	unhand(this)->address = daddr;
 	unhand(this)->port = dport;
 	unhand(this)->localport = ntohs(addr.sin_port);
@@ -114,7 +182,9 @@
  * Bind this socket to an address.
  */
 void
-java_net_PlainSocketImpl_socketBind(struct Hjava_net_PlainSocketImpl* this, struct Hjava_net_InetAddress* laddr, jint lport)
+java_net_PlainSocketImpl_socketBind(struct Hjava_net_PlainSocketImpl* this,
+				    struct Hjava_net_InetAddress* laddr, 
+				    jint lport)
 {
 	int r;
 	struct sockaddr_in addr;
@@ -122,6 +192,11 @@
 	int on = 1;
 	size_t alen;
 
+	DBG(NATIVENET,
+	    dprintf("socketBind(%p, %s, %d)\n", 
+		    this, addr2dottedfour(unhand(laddr)->address), lport);
+	    )
+
 	memset(&addr, 0, sizeof(addr));
 #if defined(BSD44)
 	addr.sin_len = sizeof(addr);
@@ -150,6 +225,11 @@
 		lport = ntohs(addr.sin_port);
 	}
 	unhand(this)->localport = lport;
+
+	DBG(NATIVENET,
+	    dprintf("socketBind(%p, %s, -) -> (lport: %d)\n", this,
+		    addr2dottedfour(unhand(laddr)->address), lport);
+	    );
 }
 
 /*
@@ -160,6 +240,10 @@
 {
 	int r;
 
+	DBG(NATIVENET,
+	    dprintf("socketListen(%p, count=%d)\n", this, count);
+	    )
+
 	r = KLISTEN(unhand(unhand(this)->fd)->fd, count);
 	if (r) {
 		SignalError("java.io.IOException", SYS_ERROR(r));
@@ -185,6 +269,11 @@
 	addr.sin_port = htons(unhand(sock)->localport);
 	addr.sin_addr.s_addr = htonl(unhand(unhand(sock)->address)->address);
 
+	DBG(NATIVENET,
+	    dprintf("socketAccept(%p, localport=%d, addr=%s)\n", 
+		    this, addr.sin_port, addr2dottedfour(ntohl(addr.sin_addr.s_addr)));
+	    )
+
 	alen = sizeof(addr);
 	rc = KACCEPT(unhand(unhand(this)->fd)->fd, (struct sockaddr*)&addr, &alen, unhand(this)->timeout, &r);
 	if (rc == EINTR) {
@@ -205,6 +294,11 @@
 
 	unhand(unhand(sock)->address)->address = ntohl(addr.sin_addr.s_addr);
 	unhand(sock)->port = ntohs(addr.sin_port);
+
+	DBG(NATIVENET,
+	    dprintf("socketAccept(%p, localport=-, addr=-) -> (sock: %p; addr: %s; port:%d)\n", 
+		    this, sock, addr2dottedfour(ntohl(addr.sin_addr.s_addr)), addr.sin_port);
+	    )
 }
 
 /*
@@ -216,6 +310,10 @@
 	int r;
 	jint len;
 
+	DBG(NATIVENET,
+	    dprintf("socketAvailable(%p)\n", this);
+	    )
+
 #if defined(HAVE_IOCTL) && defined(FIONREAD)
 	/* XXX make part of system call interface to protect errno */
 	r = ioctl(unhand(unhand(this)->fd)->fd, FIONREAD, &len);
@@ -241,6 +339,11 @@
 		len = 0;
 	}
 #endif
+
+	DBG(NATIVENET,
+	    dprintf("socketAvailable(%p) -> %d\n", this, len);
+	    )
+
 	return (len);
 }
 
@@ -252,6 +355,10 @@
 {
 	int r;
 
+	DBG(NATIVENET,
+	    dprintf("socketClose(%p)\n", this);
+	    )
+
 	if (unhand(unhand(this)->fd)->fd != -1) {
 		r = KSOCKCLOSE(unhand(unhand(this)->fd)->fd);
 		unhand(unhand(this)->fd)->fd = -1;
@@ -262,10 +369,20 @@
 }
 
 void
-java_net_PlainSocketImpl_socketSetOption(struct Hjava_net_PlainSocketImpl* this, jint opt, struct Hjava_lang_Object* arg)
+java_net_PlainSocketImpl_socketSetOption(struct Hjava_net_PlainSocketImpl* this,
+					 jint opt, 
+					 struct Hjava_lang_Object* arg)
 {
 	int k, r, v;
 
+	DBG(NATIVENET,
+	    char *optstr = "UNKNOWN";
+	    for (k = 0; k < sizeof(optionNames) / sizeof(optionNames[0]); k++) 
+		    if (optionNames[k].opt == opt)
+			    optstr = optionNames[k].name;
+	    dprintf("socketSetOption(%p, %s, arg=%p)\n", this, optstr, arg);
+	    )
+
 	/* Do easy cases */
 	for (k = 0; k < sizeof(socketOptions) / sizeof(*socketOptions); k++) {
 		if (opt == socketOptions[k].jopt) {
@@ -301,6 +418,14 @@
 	int k, r, v;
 	int vsize = sizeof(v);
 
+	DBG(NATIVENET,
+	    char *optstr = "UNKNOWN";
+	    for (k = 0; k < sizeof(optionNames) / sizeof(optionNames[0]); k++) 
+		    if (optionNames[k].opt == opt)
+			    optstr = optionNames[k].name;
+	    dprintf("socketGetOption(%p, %s)\n", this, optstr);
+	    )
+
 	/* Do easy cases */
 	for (k = 0; k < sizeof(socketOptions) / sizeof(*socketOptions); k++) {
 		if (opt == socketOptions[k].jopt) {
@@ -310,6 +435,9 @@
 			if (r) {
 				SignalError("java.net.SocketException", SYS_ERROR(r));
 			}
+			DBG(NATIVENET,
+			    dprintf("socketGetOption(%p, -) -> %d\n", this, v);
+			    )
 			return v;
 		}
 	}
@@ -329,6 +457,9 @@
 	default:
 		SignalError("java.net.SocketException", "Unimplemented socket option");    
 	} 
+	DBG(NATIVENET,
+	    dprintf("socketGetOption(%p, -) -> %d\n", this, r);
+	    )
 	return (r);
 }
 
@@ -339,6 +470,11 @@
 	int rc;
 	int fd;
 
+	DBG(NATIVENET,
+	    dprintf("socket_read(%p, %p, %d, %d)\n", 
+		    this, buf, offset, len);
+	    )
+
 	fd = unhand(unhand(this)->fd)->fd;
 	if (fd < 0) {
 		SignalError("java.io.IOException", "fd invalid"); 
@@ -363,8 +499,14 @@
 void
 java_net_PlainSocketImpl_write(struct Hjava_net_PlainSocketImpl* this, HArrayOfByte* buf, jint offset, jint len)
 {
-	int r, fd;
+        int r;
+	int fd;
 	ssize_t nw;
+
+	DBG(NATIVENET,
+	    dprintf("socket_write(%p, %p, %d, %d)\n", 
+		    this, buf, offset, len);
+	    )
 
 	fd = unhand(unhand(this)->fd)->fd;
 	if (fd >= 0) {
Index: libraries/javalib/Makefile.am
===================================================================
RCS file: /home/cvspublic/kaffe/libraries/javalib/Makefile.am,v
diff -u -b -r1.14 Makefile.am
@@ -669,7 +669,7 @@
 jar-classes $(LIBDIR)/Klasses.jar: $(LIBDIR)/stamp
 	rm -f $(LIBDIR)/$(CLASSFILE)
 	cp $(srcdir)/kaffe/lang/unicode.idx $(srcdir)/kaffe/lang/unicode.tbl $(LIBDIR)/kaffe/lang
-	(cd $(LIBDIR) && $(ZIP) -r $(CLASSFILE) $(SRCDIRS))
+	(cd $(LIBDIR) && $(ZIP) -rq $(CLASSFILE) $(SRCDIRS))
 
 .PHONY: build-classes Klasses
 build-classes Klasses: $(LIBDIR)/$(CLASSFILE)
Index: libraries/javalib/rebuildLib.in
===================================================================
RCS file: /home/cvspublic/kaffe/libraries/javalib/rebuildLib.in,v
diff -u -b -r1.12 rebuildLib.in
@@ -45,4 +45,5 @@
 cd $SRCDIR
 
 echo "Compiling classes ..."
-$JAVAC -verbose -d $LIBDIR -classpath $CPATH ${1+"$@"}
+#$JAVAC -verbose -d $LIBDIR -classpath $CPATH ${1+"$@"}
+$JAVAC -d $LIBDIR -classpath $CPATH ${1+"$@"}
Index: libraries/javalib/java/lang/System.java
===================================================================
RCS file: /home/cvspublic/kaffe/libraries/javalib/java/lang/System.java,v
diff -u -b -r1.11 System.java
@@ -17,9 +17,7 @@
 import java.io.FileOutputStream;
 import java.io.InputStream;
 import java.io.PrintStream;
-import java.util.GregorianCalendar;
 import java.util.Properties;
-import java.util.SimpleTimeZone;
 
 final public class System
 {
@@ -31,18 +29,28 @@
 	private static SecurityManager security;
 
 static {
+		// XXX what are the constraints on the initialization order in here?
+
 	security = defaultSecurityManager;
 
 	props = initProperties(new Properties());
 
-	// Initiate the timezone & calendar.
-	new SimpleTimeZone(0, "GMT");
-	new GregorianCalendar();
-
 	// Initialise the I/O
 	in = new BufferedInputStream(new FileInputStream(FileDescriptor.in), 128);
 	out = new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.out), 128), true);
 	err = new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.err), 128), true);	
+
+	// Initiate the default timezone implementation & default calendar implementation.  
+	try
+	{
+		Class.forName("java.util.SimpleTimeZone");
+		Class.forName("java.util.GregorianCalendar");
+	}
+	catch (ClassNotFoundException _)
+	{
+		// Kaffe won't let exceptions be thrown this early in
+		// the init process, anyway...
+	}
 }
 
 private System() { }
Index: libraries/javalib/java/text/SimpleDateFormat.java
===================================================================
RCS file: /home/cvspublic/kaffe/libraries/javalib/java/text/SimpleDateFormat.java,v
diff -u -b -r1.10 SimpleDateFormat.java
@@ -22,7 +22,7 @@
   extends DateFormat
 {
 	private static final long serialVersionUID = 4774881970558875024L;
-	final private static String DEFAULTPATTERNCHARS = "GyMdkHmsSEDFwWahKz";
+	private static final String DEFAULTPATTERNCHARS = "GyMdkHmsSEDFwWahKz";
 	private DateFormatSymbols syms;
 	private String pattern;
 
Index: libraries/javalib/java/util/GregorianCalendar.java
===================================================================
RCS file: /home/cvspublic/kaffe/libraries/javalib/java/util/GregorianCalendar.java,v
diff -u -b -r1.4 GregorianCalendar.java
@@ -29,8 +29,8 @@
 	private Calendar dateChange = null;
 
 static {
-	stdDateChange = new GregorianCalendar();
-	stdDateChange.set(1582, Calendar.OCTOBER, 15);
+        // initialize the day that switched to Gregorian (from Julian) date keeping
+	stdDateChange = new GregorianCalendar(1582, Calendar.OCTOBER, 15);
 }
 
 public GregorianCalendar()
Index: libraries/javalib/java/util/SimpleTimeZone.java
===================================================================
RCS file: /home/cvspublic/kaffe/libraries/javalib/java/util/SimpleTimeZone.java,v
diff -u -b -r1.5 SimpleTimeZone.java
@@ -35,7 +35,7 @@
 	new SimpleTimeZone(-9*60*60*1000, "AST");
 	new SimpleTimeZone(-8*60*60*1000, "PST", Calendar.APRIL, 1, Calendar.SUNDAY, 2*60*60*1000, Calendar.OCTOBER, -1, Calendar.SUNDAY, 2*60*60*1000);
 	new SimpleTimeZone(-7*60*60*1000, "PNT");
-	new SimpleTimeZone(-7*60*60*1000, "MST");
+	new SimpleTimeZone(-7*60*60*1000, "MST", Calendar.APRIL, 1, Calendar.SUNDAY, 2*60*60*1000, Calendar.OCTOBER, -1, Calendar.SUNDAY, 2*60*60*1000);
 	new SimpleTimeZone(-6*60*60*1000, "CST");
 	new SimpleTimeZone(-5*60*60*1000, "EST");
 	new SimpleTimeZone(-5*60*60*1000, "IET");
@@ -69,7 +69,9 @@
 	useDaylight = false;
 }
 
-public SimpleTimeZone(int rawOffset, String ID, int startMonth, int startDayOfWeekInMonth, int startDayOfWeek, int startTime, int endMonth, int endDayOfWeekInMonth, int endDayOfWeek, int endTime)
+public SimpleTimeZone(int rawOffset, String ID,
+		      int startMonth, int startDayOfWeekInMonth, int startDayOfWeek, int startTime,
+		      int endMonth, int endDayOfWeekInMonth, int endDayOfWeek, int endTime)
 	{
 	this.startYear = 0;
 	this.rawOffset = rawOffset;
Index: libraries/javalib/java/util/TimeZone.java
===================================================================
RCS file: /home/cvspublic/kaffe/libraries/javalib/java/util/TimeZone.java,v
diff -u -b -r1.4 TimeZone.java
@@ -17,8 +17,9 @@
   implements Serializable, Cloneable
 {
 	private static final long serialVersionUID = 3581463369166924961L;
-	private static TimeZone defaultTimeZone;
+	private static TimeZone defaultTimeZone = null;
 	private static Hashtable zones = new Hashtable();
+
 	private String timezoneID = null;
 
 public TimeZone()
@@ -84,8 +85,10 @@
 	if (defaultTimeZone == null) {
 		String zne = System.getProperty("user.timezone", "GMT");
 		defaultTimeZone = getTimeZone(zne);
-		if (defaultTimeZone == null) {
+		if (defaultTimeZone == null)
 			defaultTimeZone = getTimeZone("GMT");
+		if (defaultTimeZone == null) {
+			throw new InternalError("Cannot intialize timezone.  GMT & " +zne+ " zones are undefined.");
 		}
 	}
 	return (defaultTimeZone);
@@ -102,16 +105,8 @@
 
 public static synchronized TimeZone getTimeZone(String ID)
 {
-	Enumeration e = zones.elements();
-
-	while (e.hasMoreElements()) {
-		TimeZone tz = (TimeZone)e.nextElement();
-		if (ID.equals(tz.getID())) {
-			return (tz);
-		}
-	}
-
-	return (null);
+	TimeZone tz = (TimeZone)zones.get(ID);
+	return tz;
 }
 
 abstract public boolean inDaylightTime(Date date);
Index: libraries/javalib/kaffe/text/dateformat/locale_en_US.java
===================================================================
RCS file: /home/cvspublic/kaffe/libraries/javalib/kaffe/text/dateformat/locale_en_US.java,v
diff -u -b -r1.2 locale_en_US.java
@@ -11,8 +11,8 @@
 	 */
 
 	// Full, Long, Medium, Short
-	{ "date", new String[]{ "EEEE, MMMM d, yyyy", "MMMM d, yyyy", "d-MMM-yy", "M/d/yy" } },
-	{ "time", new String[]{ "h:mm:ss;SS 'o''''clock' a z", "h:mm:ss a z", "h:mm:ss a", "h:mm a" } },
+	{ "date", new String[]{ "EEEE, MMMM d, yyyy", "MMMM d, yyyy", "dd-MMM-yy", "M/d/yy" } },
+	{ "time", new String[]{ "h:mm:ss 'o''''clock' a z", "h:mm:ss a z", "h:mm:ss a", "h:mm a" } },
 
 	/*
 	 * DateFormatSymbols information


More information about the kaffe mailing list