[OPTIMIZED] java.lang

Robert Zawiasa bozo at bibl.u-szeged.hu
Mon Feb 22 05:12:08 PST 1999


hi again,

here is a somewhat bigger patch for the java.lang package,
it applies cleanly on the current public cvs (checked in an hour):

highlights:

* Runtime.runFinalizersOnExit(boolean) must be static
* Serializable declarations and serialVersionUID definitions completed
* Integer.decode(String) threw NumberFormatException on pure "0" (zero)
* some uninstantiable classes missed the private constructor
* do not observe String internals from classes other than StringBuffer
* wrong conversion value in Character.toTitleCase(char)
* some StringIndexOutOfBoundsException checks were missing
* some checkPropertiesAccess()s were missing from 
* the rest is heavy code optimization and clean-up


one thing I was not really sure how to deal with:

take an as-of-the-spec-synchronized method which itself does not do 
anything dangerous, but calls an other synchronized method e.g.:

public final /* synchronized */ void join(long millis) throws InterruptedException
{
        join(millis, 0);
}

do we need this method to be explicitly synchronized conforming to the spec, 
or we can omit the synchronized keyword as that is an implementation 
detail and our code is "more optimized" without that?

I was brave and commented out 9 occurences of the synchronized keyword,
tested and it seems to be OK. you can easily withdraw these changes in
the patch: search for the '/\* synchronized \*/' regexp.


core team: please consider to check in my changes,
see the attachment..
-------------- next part --------------
diff -urN kaffe/libraries/clib/native/Runtime.c kaffe-patched/libraries/clib/native/Runtime.c
--- kaffe/libraries/clib/native/Runtime.c	Mon Feb  8 06:07:19 1999
+++ kaffe-patched/libraries/clib/native/Runtime.c	Mon Feb 22 11:57:17 1999
@@ -175,7 +175,7 @@
  * Inform the runtime that it must run the finalizer when it exits.
  */
 void
-java_lang_Runtime_runFinalizersOnExit(struct Hjava_lang_Runtime* this, jbool on)
+java_lang_Runtime_runFinalizersOnExit(jbool on)
 {
 	runFinalizerOnExit = on;
 }
diff -urN kaffe/libraries/javalib/java/lang/Boolean.java kaffe-patched/libraries/javalib/java/lang/Boolean.java
--- kaffe/libraries/javalib/java/lang/Boolean.java	Wed Feb 10 22:34:45 1999
+++ kaffe-patched/libraries/javalib/java/lang/Boolean.java	Mon Feb 22 11:57:17 1999
@@ -1,6 +1,3 @@
-package java.lang;
-
-
 /*
  * Java core library component.
  *
@@ -10,53 +7,61 @@
  * See the file "license.terms" for information on usage and redistribution
  * of this file.
  */
-final public class Boolean {
 
-public static final Boolean TRUE = new Boolean(true);
-public static final Boolean FALSE = new Boolean(false);
-public static final Class TYPE = Class.getPrimitiveClass("boolean");
-private final boolean value;
+package java.lang;
+
+public final class Boolean
+	implements java.io.Serializable
+{
+	private final boolean value;
 
-public Boolean(String s) {
-	value = (s != null && s.toLowerCase().equals("true"));
+	public static final Boolean TRUE = new Boolean(true);
+	public static final Boolean FALSE = new Boolean(false);
+	public static final Class TYPE = Class.getPrimitiveClass("boolean");
+
+	/* This is what Sun's JDK1.1 "serialver java.lang.Boolean" spits out */
+	private static final long serialVersionUID = -3665804199014368530L;
+
+public Boolean(boolean value)
+{
+	this.value = value;
 }
 
-public Boolean(boolean value) {
-	this.value=value;
+public Boolean(String s)
+{
+	value = ((s != null) && s.toLowerCase().equals("true"));
 }
 
-public boolean booleanValue() {
+public boolean booleanValue()
+{
 	return (value);
 }
 
-public boolean equals(Object obj) {
-	if ((obj!=null) && (obj instanceof Boolean)) {
-		return (this.booleanValue()==((Boolean )obj).booleanValue());
-	}
-	else {
-		return false;
-	}
-}
-
-public static boolean getBoolean(String name) {
-	String value = System.getProperty(name);
-	if (value == null) {
-		return (false);
-	}
-	else {
-		return (value.equals("true"));
-	}
+public boolean equals(Object obj)
+{
+	return (obj != null) &&
+	       (obj instanceof Boolean) &&
+	       (((Boolean)obj).value == value);
+}
+
+public static boolean getBoolean(String name)
+{
+	String s = System.getProperty(name);
+	return (s != null) && s.toLowerCase().equals("true");
 }
 
-public int hashCode() {
+public int hashCode()
+{
 	return (value ? 1231 : 1237);
 }
 
-public String toString() {
+public String toString()
+{
 	return (value ? "true" : "false");
 }
 
-public static Boolean valueOf(String s) {
+public static Boolean valueOf(String s)
+{
 	return new Boolean(s);
 }
 }
diff -urN kaffe/libraries/javalib/java/lang/Byte.java kaffe-patched/libraries/javalib/java/lang/Byte.java
--- kaffe/libraries/javalib/java/lang/Byte.java	Mon Feb  8 05:49:13 1999
+++ kaffe-patched/libraries/javalib/java/lang/Byte.java	Mon Feb 22 11:57:17 1999
@@ -1,6 +1,3 @@
-package java.lang;
-
-
 /*
  * Java core library component.
  *
@@ -10,42 +7,50 @@
  * See the file "license.terms" for information on usage and redistribution
  * of this file.
  */
-final public class Byte extends Number
+
+package java.lang;
+
+public final class Byte extends Number
 {
+	private final byte value;
+
 	public static final byte MIN_VALUE = -0x80;
 	public static final byte MAX_VALUE = 0x7F;
 	public static final Class TYPE = Class.getPrimitiveClass("byte");
-	private final byte value;
 
-public Byte(String s) throws NumberFormatException {
-	this(parseByte(s));
-}
+	/* This is what Sun's JDK1.1 "serialver java.lang.Byte" spits out */
+	private static final long serialVersionUID = -7183698231559129828L;
 
 public Byte(byte value) {
 	this.value = value;
 }
 
-public static Byte decode(String nm) throws NumberFormatException {
-	byte val;
+public Byte(String s) throws NumberFormatException {
+	this.value = parseByte(s);
+}
+
+public static Byte decode(String nm) throws NumberFormatException
+{
+        byte b;
 
-	if (nm.value[nm.offset] == '#') {
-		val = parseByte(nm.substring(1), 16);
+        if (nm.startsWith("0x")) {
+                b = parseByte(nm.substring(2), 16);
+        }
+        else if (nm.startsWith("#")) {
+                b = parseByte(nm.substring(1), 16);
 	}
-	else if (nm.value[nm.offset] == '0') {
-		if ( (nm.count > 1) && (nm.value[nm.offset+1] == 'x') )
-			val = parseByte( nm.substring(2), 16);
-		else
-			val = parseByte(nm.substring(1), 8);
+        else if (nm.startsWith("0") && nm.length() > 1) {
+                b = parseByte(nm.substring(1), 8);
 	}
 	else {
-		val = parseByte(nm, 10);
+                b = parseByte(nm, 10);
 	}
 
-	return new Byte(val);
+        return new Byte(b);
 }
 
 public double doubleValue() {
-	return ((double)value);
+	return (double)value;
 }
 
 public boolean equals(Object obj) {
@@ -55,50 +60,45 @@
 }
 
 public float floatValue() {
-	return ((float)value);
+	return (float)value;
 }
 
 public int hashCode() {
-	return (value);	// What should this be do you suppose ???
-}
-
-public byte byteValue() {
-	return (value);
-}
-
-public short shortValue() {
-	return ((short)value);
+	return (int)value;	// What should this be do you suppose ???
 }
 
 public int intValue() {
-	return ((int)value);
+	return (int)value;
 }
 
 public long longValue() {
-	return ((long)value);
+	return (long)value;
 }
 
 public static byte parseByte(String s) throws NumberFormatException {
-	return (parseByte(s, 10));
+	return parseByte(s, 10);
 }
 
 public static byte parseByte(String s, int radix) throws NumberFormatException {
-	return ((byte)Integer.parseInt(s, radix));
+	int i = Integer.parseInt(s, radix);
+	if (i < MIN_VALUE || MAX_VALUE < i)
+		throw new NumberFormatException();
+	return (byte)i;
 }
 
 public String toString() {
-	return (toString(value));
+	return toString(value);
 }
 
-public static String toString(byte s) {
-	return Integer.toString((int)s);
+public static String toString(byte b) {
+	return Integer.toString((int)b);
 }
 
 public static Byte valueOf(String s) throws NumberFormatException {
-	return (new Byte(parseByte(s)));
+	return new Byte(parseByte(s));
 }
 
 public static Byte valueOf(String s, int radix) throws NumberFormatException {
-	return (new Byte(parseByte(s, radix)));
+	return new Byte(parseByte(s, radix));
 }
 }
diff -urN kaffe/libraries/javalib/java/lang/Character.java kaffe-patched/libraries/javalib/java/lang/Character.java
--- kaffe/libraries/javalib/java/lang/Character.java	Mon Feb  8 05:49:13 1999
+++ kaffe-patched/libraries/javalib/java/lang/Character.java	Mon Feb 22 11:57:17 1999
@@ -14,8 +14,9 @@
 
 package java.lang;
 
-public final class Character extends Object {
-
+public final class Character
+	implements java.io.Serializable
+{
   public static final int MIN_RADIX = 2;
   public static final int MAX_RADIX = 36;
   public static final char MIN_VALUE = 0x0000;
@@ -52,40 +53,43 @@
   public static final Class TYPE = Class.getPrimitiveClass("char");
 
   private final char value;
+  
+  /* This is what Sun's JDK1.1 "serialver java.lang.Character" spits out */
+  private static final long serialVersionUID = 3786198910865385080L;
 
   public Character(char value)
   {
-    this.value=value;
+    this.value = value;
   }
 
   public char charValue()
   {
-    return (value);
+    return value;
   }
 
   public int hashCode()
   {
-    return ((int)value);
+    return (int)value;
   }
 
   public boolean equals(Object obj)
   {
-    if (obj instanceof Character) {
-      return (charValue() == ((Character)obj).charValue());
-    }
-    else {
-      return (false);
-    }    
+    return (obj != null)
+	&& (obj instanceof Character)
+	&& (((Character)obj).value == value);
   }
 
   public String toString()
   {
-    return (String.valueOf(value));
+    return String.valueOf(value);
   }
 
+  /**
+   * @deprecated Replaced by isWhitespace(char).
+   */
   public static boolean isSpace(char ch)
   {
-    return (isWhitespace(ch));
+    return isWhitespace(ch);
   }
 
   public static boolean isLetterOrDigit(char ch)
@@ -93,14 +97,20 @@
     return (isLetter(ch) || isDigit(ch));
   }
   
+  /**
+   * @deprecated Replaced by isJavaIdentifierStart(char).
+   */
   public static boolean isJavaLetter(char ch)
   {
-    return (isJavaIdentifierStart(ch));
+    return isJavaIdentifierStart(ch);
   }
   
+  /**
+   * @deprecated Replaced by isJavaIdentifierPart(char).
+   */
   public static boolean isJavaLetterOrDigit(char ch)
   {
-    return (isJavaIdentifierPart(ch));
+    return isJavaIdentifierPart(ch);
   }
 
   public static boolean isTitleCase(char ch)
@@ -110,22 +120,13 @@
   
   public static char toTitleCase(char ch)
   {
-    if (ch == 0x01C6) {
-      return (0x01C6);
-    }
-    else if (ch == 0x01C9) {
-      return (0x01C8);
-    }
-    else if (ch == 0x01CC) {
-      return (0x01CB);
-    }
-    else if (ch == 0x01F3) {
-      return (0x01F2);
-    }
-    else {
+    if (ch == 0x01C6) return (0x01C5);
+    if (ch == 0x01C9) return (0x01C8);
+    if (ch == 0x01CC) return (0x01CB);
+    if (ch == 0x01F3) return (0x01F2);
+
       return (ch);
     }
-  }
 
   /**
    * Determines if a character has a defined meaning in Unicode. 
@@ -135,8 +136,7 @@
    *   Its value is in the range 0xF900 <= ch <= 0xFA2D.  <br>
    */
   public static boolean isDefined(char ch) {
-	if (0x3040 <= ch && ch <= 0x9FA5 ||
-	    0xF900 <= ch && ch <= 0xFA2D) {
+	if (0x3040 <= ch && ch <= 0x9FA5 || 0xF900 <= ch && ch <= 0xFA2D) {
 		return (true);
 	}
 	/* FIXME: we do not check for entry in Unicode attribute table.
@@ -147,18 +147,13 @@
 
   public static boolean isIdentifierIgnorable(char ch)
   {
-    if ((ch >= 0x0000 && ch <= 0x0008) ||
-        (ch >= 0x000E && ch <= 0x001B) ||
-        (ch >= 0x007F && ch <= 0x009F) ||
-        (ch >= 0x200C && ch <= 0x200F) ||
-        (ch >= 0x202A && ch <= 0x202E) ||
-        (ch >= 0x206A && ch <= 0x206F) ||
-        (ch == 0xFEFF)) {
-      return (true);
-    }
-    else {
-      return (false);
-    }
+    return (ch >= 0x0000 && ch <= 0x0008)
+	|| (ch >= 0x000E && ch <= 0x001B)
+	|| (ch >= 0x007F && ch <= 0x009F)
+	|| (ch >= 0x200C && ch <= 0x200F)
+	|| (ch >= 0x202A && ch <= 0x202E)
+	|| (ch >= 0x206A && ch <= 0x206F)
+	|| (ch == 0xFEFF);
   }
 
   public static boolean isLowerCase(char ch)
@@ -178,25 +173,18 @@
 
   public static boolean isLetter(char ch)
   {
-    return ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'));
+    return (ch >= 'a' && ch <= 'z')
+	|| (ch >= 'A' && ch <= 'Z');
   }
 
   public static char toLowerCase(char ch)
   {
-    char result=ch;
-
-    if (isUpperCase(ch)) result=(char )(((int )ch)+32);
-
-    return result;
+    return isUpperCase(ch) ? (char)((int)ch + 32) : ch;
   }
 
   public static char toUpperCase(char ch)
   {
-    char result=ch;
-
-    if (isLowerCase(ch)) result=(char )(((int )ch)-32);
-
-    return result;
+    return isLowerCase(ch) ? (char)((int)ch - 32) : ch;
   }
 
   public static int digit(char ch, int radix)
@@ -210,33 +198,28 @@
       val = ch - '0';
     }
     else if (isLetter(ch)) {
-      val = ((int)toLowerCase(ch)) - ((int)'a') + 10;
+      val = toLowerCase(ch) - 'a' + 10;
     }
 
-    if (val < radix) {
-      return (val);
-    }
-    else {
-      return (-1);
-    }
+    return (val < radix) ? (val) : (-1);
   }
 
   public static char forDigit(int digit, int radix)
   {
-    if ((radix<MIN_RADIX) || (radix>MAX_RADIX)) return 0x0000;
-    if (digit>radix) return 0x0000;
+    if ((radix < MIN_RADIX) || (radix > MAX_RADIX)) return 0x0000;
+    if (digit > radix) return 0x0000;
 
-    if (digit<10) {
-      return (char )(((int )'0')+digit);
+    if (digit < 10) {
+      return ('0' + digit);
     }
     else {
-      return (char )(((int )'a')+(digit-10));
+      return ('a' + digit - 10);
     }
   }
 
   public static int getNumericValue(char ch)
   {
-    return (digit(ch, 10));
+    return digit(ch, 10);
   }
 
   public static int getType(char ch)
@@ -246,22 +229,16 @@
 
   public static boolean isISOControl(char ch)
   {
-    if ((ch >= 0x0000 && ch <= 0x001F) ||
-        (ch >= 0x007F && ch <= 0x009F)) {
-      return (true);
-    }
-    else {
-      return (false);
-    }
+    return (ch >= 0x0000 && ch <= 0x001F)
+	|| (ch >= 0x007F && ch <= 0x009F);
   }
 
   public static boolean isJavaIdentifierPart(char ch)
   {
-      return ((ch >= 0x0000 && ch <= 0x0008) ||
-	(ch >= 0x000e && ch <= 0x001b) ||
-	(ch >= 0x007f && ch <= 0x009f) ||
-	ch == '$' || ch == '_' ||
-        isLetter(ch) || isDigit(ch));
+    return (ch >= 0x0000 && ch <= 0x0008)
+	|| (ch >= 0x000e && ch <= 0x001b)
+	|| (ch >= 0x007f && ch <= 0x009f)
+	|| ch == '$' || ch == '_' || isLetter(ch) || isDigit(ch);
   }
 
   public static boolean isJavaIdentifierStart(char ch)
@@ -286,9 +263,8 @@
 
   public static boolean isWhitespace(char ch)
   {
-    return((ch == ' ')
+    return (ch == ' ')
 	|| (ch >= 0x0009 && ch <= 0x000d)
-	|| (ch >= 0x001c && ch <= 0x001f) );
+	|| (ch >= 0x001c && ch <= 0x001f);
   }
 }
-
diff -urN kaffe/libraries/javalib/java/lang/Class.java kaffe-patched/libraries/javalib/java/lang/Class.java
--- kaffe/libraries/javalib/java/lang/Class.java	Fri Feb 12 07:14:56 1999
+++ kaffe-patched/libraries/javalib/java/lang/Class.java	Mon Feb 22 11:57:17 1999
@@ -19,9 +19,17 @@
 import java.net.URL;
 import kaffe.lang.SystemClassLoader;
 
-final public class Class implements Serializable {
+public final class Class implements Serializable
+{
+
+private Class() { }
+
+private void checkMemberAccess(int which) {
+	System.getSecurityManager().checkMemberAccess(this, which);
+}
 
-native public static Class forName(String className) throws ClassNotFoundException;
+public static native Class forName(String className)
+	throws ClassNotFoundException;
 
 private String fullResourceName(String name) {
 	if (name.charAt(0) != '/') {
@@ -52,71 +60,75 @@
 	return (getClassLoader0());
 }
 
-native private ClassLoader getClassLoader0();
+private native ClassLoader getClassLoader0();
 
 public Class[] getClasses() {
 	return (getClasses0(false));
 }
 
-native private Class[] getClasses0(boolean declared);
+private native Class[] getClasses0(boolean declared);
 
-native public Class getComponentType();
+public native Class getComponentType();
 
-public Constructor getConstructor(Class parameterTypes[]) throws NoSuchMethodException, SecurityException
+public Constructor getConstructor(Class parameterTypes[])
+	throws NoSuchMethodException, SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.PUBLIC);
+	checkMemberAccess(Member.PUBLIC);
 	return (getConstructor0(parameterTypes, false));
 }
 
-native private Constructor getConstructor0(Class[] args, boolean declared);
+private native Constructor getConstructor0(Class[] args, boolean declared);
 
 public Constructor[] getConstructors() throws SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.PUBLIC);
+	checkMemberAccess(Member.PUBLIC);
 	return (getConstructors0(false));
 }
 
-native private Constructor[] getConstructors0(boolean declared);
+private native Constructor[] getConstructors0(boolean declared);
 
 public Class[] getDeclaredClasses() throws SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.DECLARED);
+	checkMemberAccess(Member.DECLARED);
 	return (getClasses0(true));
 }
 
-public Constructor getDeclaredConstructor(Class parameterTypes[]) throws NoSuchMethodException, SecurityException
+public Constructor getDeclaredConstructor(Class parameterTypes[])
+	throws NoSuchMethodException, SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.DECLARED);
+	checkMemberAccess(Member.DECLARED);
 	return (getConstructor0(parameterTypes, true));
 }
 
 public Constructor[] getDeclaredConstructors() throws SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.DECLARED);
+	checkMemberAccess(Member.DECLARED);
 	return (getConstructors0(true));
 }
 
-public Field getDeclaredField(String name) throws NoSuchFieldException, SecurityException
+public Field getDeclaredField(String name)
+	throws NoSuchFieldException, SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.DECLARED);
+	checkMemberAccess(Member.DECLARED);
 	return (getField0(name, true));
 }
 
 public Field[] getDeclaredFields() throws SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.DECLARED);
+	checkMemberAccess(Member.DECLARED);
 	return (getFields0(true));
 }
 
-public Method getDeclaredMethod(String name, Class parameterTypes[]) throws NoSuchMethodException, SecurityException
+public Method getDeclaredMethod(String name, Class parameterTypes[])
+	throws NoSuchMethodException, SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.DECLARED);
+	checkMemberAccess(Member.DECLARED);
 	return (getMethod0(name, parameterTypes, true));
 }
 
 public Method[] getDeclaredMethods() throws SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.DECLARED);
+	checkMemberAccess(Member.DECLARED);
 	return (getMethods0(true));
 }
 
@@ -126,45 +138,47 @@
 	return (null);
 }
 
-public Field getField(String name) throws NoSuchFieldException, SecurityException
+public Field getField(String name)
+	throws NoSuchFieldException, SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.PUBLIC);
+	checkMemberAccess(Member.PUBLIC);
 	return (getField0(name, false));
 }
 
-native private Field getField0(String name, boolean declared);
+private native Field getField0(String name, boolean declared);
 
 public Field[] getFields() throws SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.PUBLIC);
+	checkMemberAccess(Member.PUBLIC);
 	return (getFields0(false));
 }
 
-native private Field[] getFields0(boolean declared);
+private native Field[] getFields0(boolean declared);
 
-native public Class[] getInterfaces();
+public native Class[] getInterfaces();
 
-public Method getMethod(String name, Class parameterTypes[]) throws NoSuchMethodException, SecurityException
+public Method getMethod(String name, Class parameterTypes[])
+	throws NoSuchMethodException, SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.PUBLIC );
+	checkMemberAccess(Member.PUBLIC );
 	return (getMethod0(name, parameterTypes, false));
 }
 
-native private Method getMethod0(String name, Class[] args, boolean declared);
+private native Method getMethod0(String name, Class[] args, boolean declared);
 
 public Method[] getMethods() throws SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.PUBLIC);
+	checkMemberAccess(Member.PUBLIC);
 	return (getMethods0(false));
 }
 
-native private Method[] getMethods0(boolean declared);
+private native Method[] getMethods0(boolean declared);
 
-native public int getModifiers();
+public native int getModifiers();
 
-native public String getName();
+public native String getName();
 
-native public static Class getPrimitiveClass(String name);
+public native static Class getPrimitiveClass(String name);
 
 /**
  * Finds a resource with the specified name.  
@@ -205,36 +219,33 @@
  */
 public InputStream getResourceAsStream(String name) {
 	ClassLoader loader = getClassLoader();
-	if (loader == null)  {
+	if (loader == null) {
 		loader = SystemClassLoader.getClassLoader();
 	}
 	return (loader.getResourceAsStream(fullResourceName(name)));
 }
 
-native public Object[] getSigners();
+public native Object[] getSigners();
 
-native public Class getSuperclass();
+public native Class getSuperclass();
 
-native public boolean isArray();
+public native boolean isArray();
 
-native public boolean isAssignableFrom(Class cls);
+public native boolean isAssignableFrom(Class cls);
 
-native public boolean isInstance(Object obj);
+public native boolean isInstance(Object obj);
 
-native public boolean isInterface();
+public native boolean isInterface();
 
-native public boolean isPrimitive();
+public native boolean isPrimitive();
 
-native public Object newInstance() throws InstantiationException, IllegalAccessException;
+public native Object newInstance()
+	throws InstantiationException, IllegalAccessException;
 
 /*
  * toString() 
  */
 public String toString() {
-	if (isInterface()) {
-		return ("interface " + getName());
-	} else {
-		return ("class " + getName());
-	}
+	return (isInterface() ? "interface " : "class ") + getName();
 }
 }
diff -urN kaffe/libraries/javalib/java/lang/ClassLoader.java kaffe-patched/libraries/javalib/java/lang/ClassLoader.java
--- kaffe/libraries/javalib/java/lang/ClassLoader.java	Fri Dec 18 00:18:26 1998
+++ kaffe-patched/libraries/javalib/java/lang/ClassLoader.java	Mon Feb 22 11:57:17 1999
@@ -37,8 +37,8 @@
 	this.parent = parent;
 }
 
-final protected Class defineClass(String name, byte data[], int offset, int length) {
-	Class clazz =defineClass0(name, data, offset, length);
+protected final Class defineClass(String name, byte data[], int offset, int length) {
+	Class clazz = defineClass0(name, data, offset, length);
 	if (name != null) {
 		loadedClasses.put(name, clazz);
 	} else {
@@ -50,16 +50,16 @@
 /**
  * @deprecated
  */
-final protected Class defineClass(byte data[], int offset, int length) {
-	return (defineClass(null, data, offset, length));
+protected final Class defineClass(byte data[], int offset, int length) {
+	return defineClass(null, data, offset, length);
 }
 
-final protected Class findLoadedClass(String name) {
-	return (findLoadedClass0(name));
+protected final Class findLoadedClass(String name) {
+	return findLoadedClass0(name);
 }
 
-final protected Class findSystemClass(String name) throws ClassNotFoundException {
-	return (findSystemClass0(name));
+protected final Class findSystemClass(String name) throws ClassNotFoundException {
+	return findSystemClass0(name);
 }
 
 public URL getResource(String name) {
@@ -70,7 +70,7 @@
 	return (null); // Default implementation just returns null
 }
 
-final public static URL getSystemResource(String name) {
+public static final URL getSystemResource(String name) {
 	try {
 		return (new URL("system", "", 0, name));
 	}
@@ -81,19 +81,16 @@
 
 public static final InputStream getSystemResourceAsStream(String name) {
 	byte[] data = getSystemResourceAsBytes0(name);
-	if (data == null) {
-		return (null);
-	}
-	else {
-		return (new ByteArrayInputStream(data));
-	}
+	return (data != null) ? new ByteArrayInputStream(data) : null;
 }
 
 public Class loadClass(String name) throws ClassNotFoundException {
-	return (loadClass(name, true));
+	return loadClass(name, true);
 }
 
-protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException {
+protected Class loadClass(String name, boolean resolve)
+	throws ClassNotFoundException
+{
 	Class cls = findLoadedClass(name);
 	if (cls == null) {
 		try {
@@ -121,11 +118,11 @@
 	throw new ClassNotFoundException(name);
 }
 
-final protected void resolveClass(Class c) {
+protected final void resolveClass(Class c) {
 	resolveClass0(c);
 }
 
-final protected void setSigners(Class cl, Object signers[]) {
+protected final void setSigners(Class cl, Object signers[]) {
 	// Signer's are not currently supported.
 }
 
@@ -166,16 +163,17 @@
 	throw new kaffe.util.NotImplemented();
 }
 
-native private Class defineClass0(String name, byte data[], int offset, int length);
-native private Class findSystemClass0(String name);
-native private Class findLoadedClass0(String name);
-native private void resolveClass0(Class cls);
+private native Class defineClass0(String name, byte data[], int offset, int length);
+private native Class findSystemClass0(String name);
+private native Class findLoadedClass0(String name);
+private native void resolveClass0(Class cls);
+
 /**
  *  This is not part of the public interface.
  */
-native public static byte[] getSystemResourceAsBytes0(String name);
+public static native byte[] getSystemResourceAsBytes0(String name);
 
-final native private void finalize0();
+private final native void finalize0();
 
 private Object finalizeHelper = new Object() {
     protected void finalize() throws Throwable {
diff -urN kaffe/libraries/javalib/java/lang/Cloneable.java kaffe-patched/libraries/javalib/java/lang/Cloneable.java
--- kaffe/libraries/javalib/java/lang/Cloneable.java	Thu Dec 10 03:48:18 1998
+++ kaffe-patched/libraries/javalib/java/lang/Cloneable.java	Mon Feb 22 11:57:17 1999
@@ -18,5 +18,5 @@
 	 * This is our sanity check to guard against people using the
 	 * wrong jar file.
 	 */
-        final public static int KAFFE_VERSION = 103;
+	public static final int KAFFE_VERSION = 103;
 };
diff -urN kaffe/libraries/javalib/java/lang/Double.java kaffe-patched/libraries/javalib/java/lang/Double.java
--- kaffe/libraries/javalib/java/lang/Double.java	Mon Feb  8 05:49:14 1999
+++ kaffe-patched/libraries/javalib/java/lang/Double.java	Mon Feb 22 11:57:17 1999
@@ -10,15 +10,20 @@
 
 package java.lang;
 
-public final class Double extends Number {
+public final class Double extends Number
+{
+  private final double value;
+
   public static final double POSITIVE_INFINITY = 1.0 / 0.0;
   public static final double NEGATIVE_INFINITY = -1.0 / 0.0;
   public static final double NaN = 0.0 / 0.0;
   public static final double MAX_VALUE = 1.79769313486231570E+308;
+  //public static final double MIN_VALUE = 4.94065645841246544E-324;
   public static final double MIN_VALUE = 2.2250738585072014E-308;
   public static final Class TYPE = Class.getPrimitiveClass("double");
 
-  private final double value;
+  /* This is what Sun's JDK1.1 "serialver java.lang.Double" spits out */
+  private static final long serialVersionUID = -9172774392245257468L;
 
   public static native String toString(double d);
   public static native Double valueOf(String s) throws NumberFormatException;
@@ -26,74 +31,74 @@
   public static native double longBitsToDouble(long bits);
   
   public Double(double value) {
-    this.value=value;
+    this.value = value;
   }
 
   public Double(String s) throws NumberFormatException {
-    this(Double.valueOf(s).doubleValue());
+    this(valueOf(s).value);
   }
 
   public double doubleValue() {
     return value;
   }
 
-  public String toString() {
-    return Double.toString(doubleValue());
-  }
-
   public boolean equals(Object obj) {
-    if ( (obj!=null) && (obj instanceof Double)) {
-      Double that=(Double )obj;
-      if ((this.isNaN()==true) && (that.isNaN()==true)) return true;
+    if ((obj != null) && (obj instanceof Double)) {
+      Double that = (Double)obj;
+      if (this.isNaN() && that.isNaN()) return true;
     
-      double left, right;
-      left=this.doubleValue();
-      right=that.doubleValue();
+      double left = this.value;
+      double right = that.value;
 
-      if ((left==+0.0) && (right==-0.0)) return false;
-      if ((left==-0.0) && (right==+0.0)) return false;
+      if ((left == +0.0) && (right == -0.0)) return false;
+      if ((left == -0.0) && (right == +0.0)) return false;
 
-      return (left==right);
+      return (left == right);
     }
-    else {
+
       return false;
     }
-  }
   
   public float floatValue()
   {
-    return ((float)value);
+    return (float)value;
   }
 
   public int hashCode()
   {
-    return (this.intValue());
+    return (int)value;
   }
   
   public int intValue()
   {
-    return ((int)value);
+    return (int)value;
   }
   
   public boolean isInfinite() {
-    return ((doubleValue()==POSITIVE_INFINITY) || (doubleValue()==NEGATIVE_INFINITY));		
+    return ((value == POSITIVE_INFINITY) || (value == NEGATIVE_INFINITY));
   }
   
   public static boolean isInfinite(double v) {
-    return ((v==POSITIVE_INFINITY) || (v==NEGATIVE_INFINITY));
+    return ((v == POSITIVE_INFINITY) || (v == NEGATIVE_INFINITY));
   }
   
   public boolean isNaN() {
-    return Double.isNaN(value);
+    return isNaN(value);
   }
   
   public static boolean isNaN(double v) {
-    /* A tricky little problem solved here.. NaN does equal NaN ever, so how do you test for NaN...
-       Simple: It the only number (well not a number!) which doesn't equal itself! */
-    return (v!=v);
+    /* A tricky little problem solved here..
+     * NaN does equal NaN ever, so how do you test for NaN...
+     * Simple: It the only number (well not a number!)
+     * which doesn't equal itself! */
+    return (v != v);
   }
 
   public long longValue() {
-    return (long )value;
+    return (long)value;
+  }
+
+  public String toString() {
+    return toString(value);
   }
 }
diff -urN kaffe/libraries/javalib/java/lang/Float.java kaffe-patched/libraries/javalib/java/lang/Float.java
--- kaffe/libraries/javalib/java/lang/Float.java	Mon Feb  8 05:49:14 1999
+++ kaffe-patched/libraries/javalib/java/lang/Float.java	Mon Feb 22 11:57:17 1999
@@ -10,7 +10,8 @@
 
 package java.lang;
 
-public final class Float extends Number {
+public final class Float extends Number
+{
   private final float value;
   
   public static final float POSITIVE_INFINITY = 1.0f / 0.0f;
@@ -21,87 +22,92 @@
   public static final float MIN_VALUE = 1.40129846432481707e-38f;
   public static final Class TYPE = Class.getPrimitiveClass("float");
   
+  /* This is what Sun's JDK1.1 "serialver java.lang.Float" spits out */
+  private static final long serialVersionUID = -2671257302660747028L;
+
   public Float(float value) {
-    this.value=value;
+    this.value = value;
   }
   
   public Float(double value) {
-    this((float )value);
+    this.value = (float)value;
   }
   
   public Float(String s) throws NumberFormatException {
-    this(Float.valueOf(s).floatValue());
+    this(valueOf(s).value);
   }
   
   public boolean equals(Object obj) {
-    if ((obj!=null) && (obj instanceof Float)) {
+    if ((obj != null) && (obj instanceof Float)) {
 
-      int leftBits=floatToIntBits(this.floatValue());
-      int rightBits=floatToIntBits(((Float )obj).floatValue());
-      int nanBits=floatToIntBits(NaN);
-      int posBits=floatToIntBits(POSITIVE_INFINITY);
-      int negBits=floatToIntBits(NEGATIVE_INFINITY);
+      int leftBits = floatToIntBits(value);
+      int rightBits = floatToIntBits(((Float)obj).value);
+      int nanBits = floatToIntBits(NaN);
+      int posBits = floatToIntBits(POSITIVE_INFINITY);
+      int negBits = floatToIntBits(NEGATIVE_INFINITY);
 
-      if ((this.isNaN()==true) && (((Float )obj).isNaN()==true)) {
+      if (isNaN() && ((Float)obj).isNaN()) {
         return true;
       }
 
-      if (((leftBits==posBits) && (rightBits==negBits)) || ((leftBits==posBits) && (rightBits==negBits))) {
+      if (((leftBits == posBits) && (rightBits == posBits)) ||
+	  ((leftBits == negBits) && (rightBits == negBits))) {
 	return true;
       }
     
-      return (leftBits==rightBits);
-    }
-    else {
-      return false;
-    }
+      return (leftBits == rightBits);
   }
   
-  public int hashCode() {
-    return this.intValue();
+    return false;
   }
   
   public double doubleValue() {
-    return (double )value;
+    return (double)value;
   }
   
+  public static native int floatToIntBits(float value);
+
   public float floatValue() {
     return value;
   }
   
-  public long longValue() {
-    return (long )value;
-  }
-  
-  public int intValue() {
-    return (int )value;
+  public int hashCode() {
+    return (int)value;
   }
   
-  public static native int floatToIntBits(float value);
   public static native float intBitsToFloat(int bits);
   
-  public static native String toString(float f);
-
-  public String toString() {
-    return toString(this.floatValue());
+  public int intValue() {
+    return (int)value;
   }
   
-  public static native Float valueOf(String s) throws NumberFormatException;
-  
   public static boolean isNaN(float v) {
     /* See class Double */
-    return (v!=v);
+    return (v != v);
   }
   
   public boolean isNaN() {
-    return isNaN(this.floatValue());
+    return isNaN(value);
   }
   
   public static boolean isInfinite(float v) {
-    return (floatToIntBits(v)==floatToIntBits(POSITIVE_INFINITY)) || (floatToIntBits(v)==floatToIntBits(NEGATIVE_INFINITY));
+    return (floatToIntBits(v) == floatToIntBits(POSITIVE_INFINITY))
+	|| (floatToIntBits(v) == floatToIntBits(NEGATIVE_INFINITY));
   }
   
   public boolean isInfinite() {
-    return isInfinite(this.floatValue());
+    return isInfinite(value);
   }
+
+  public long longValue() {
+    return (long)value;
+  }
+
+  public static native String toString(float f);
+
+  public String toString() {
+    return toString(value);
+  }
+
+  public static native Float valueOf(String s) throws NumberFormatException;
 }
diff -urN kaffe/libraries/javalib/java/lang/Integer.java kaffe-patched/libraries/javalib/java/lang/Integer.java
--- kaffe/libraries/javalib/java/lang/Integer.java	Wed Feb 10 22:34:45 1999
+++ kaffe-patched/libraries/javalib/java/lang/Integer.java	Mon Feb 22 11:57:17 1999
@@ -1,6 +1,3 @@
-package java.lang;
-
-
 /*
  * Java core library component.
  *
@@ -10,25 +7,28 @@
  * See the file "license.terms" for information on usage and redistribution
  * of this file.
  */
-final public class Integer
-  extends Number
+
+package java.lang;
+
+public final class Integer extends Number
 {
 	private final int value;
-	public static final Class TYPE = Class.getPrimitiveClass("int");
+
 	public static final int MIN_VALUE = 0x80000000;
 	public static final int MAX_VALUE = 0x7fffffff;
+	public static final Class TYPE = Class.getPrimitiveClass("int");
 
 	/* This is what Sun's JDK1.1 "serialver java.lang.Integer" spits out */
 	private static final long serialVersionUID = 1360826667806852920L;
 
-public Integer(String s) throws NumberFormatException
+public Integer(int value)
 {
-	this(parseInt(s));
+	this.value = value;
 }
 
-public Integer(int value)
+public Integer(String s) throws NumberFormatException
 {
-	this.value=value;
+	value = parseInt(s);
 }
 
 public static Integer decode(String nm) throws NumberFormatException
@@ -49,7 +49,7 @@
 		base = 16;
 		nm = nm.substring(1);
 	}
-	else if (nm.startsWith("0")) {
+	else if (nm.startsWith("0") && nm.length() > 1) {
 		base = 8;
 		nm = nm.substring(1);
 	}
@@ -61,36 +61,29 @@
 }
 
 public double doubleValue() {
-	return (double )value;
+	return (double)value;
 }
 
 public boolean equals(Object obj) {
-	if ((obj!=null) && (obj instanceof Integer)) {
-		return (this.intValue()==((Integer )obj).intValue());
-	}
-	else {
-		return false;
-	}
+	return (obj != null) &&
+	       (obj instanceof Integer) &&
+	       (((Integer)obj).value == value);
 }
 
 public float floatValue() {
-	return (float )value;
+	return (float)value;
 }
 
 public static Integer getInteger(String nm) {
-	return getInteger(nm, (Integer) null);
+	return getInteger(nm, (Integer)null);
 }
 
 public static Integer getInteger(String nm, Integer val) {
-	String arg;
+	String arg = (val != null) ? val.toString() : null;
+
+	String prop = System.getProperty(nm, arg);
+	if (prop == null) return val;
 
-	String prop = System.getProperty(nm);
-	if (prop == null) {
-		if (val == null) {
-			return (null);
-		}
-		prop = val.toString();
-	}
 	try {
 		return (decode(prop));
 	}
@@ -103,48 +96,46 @@
 	return getInteger(nm, new Integer(val));
 }
 
-public int hashCode() {
-	return this.intValue();
+public int hashCode()
+{
+	return value;
 }
 
 public int intValue()
-	{
+{
 	return value;
 }
 
 public long longValue() {
-	return (long )value;
+	return (long)value;
 }
 
 public static int parseInt(String s) throws NumberFormatException
 {
-	return (parseInt(s, 10));
+	return parseInt(s, 10);
 }
 
 public static int parseInt(String s, int radix) throws NumberFormatException
 {
-	if (s==null || s.length()<=0) throw new NumberFormatException();
+	if (s == null || s.length() <= 0) throw new NumberFormatException();
 
 	/* Check for negativity */
-	if (s.charAt(0)=='-')
+	if (s.charAt(0) == '-')
 		{
-		return parseInt(s.substring(1), radix)*-1;
+		return -parseInt(s.substring(1), radix);
 	}
-	else
-		{
-		int result=0;
-		int position;
 
-		for (position=0; position<s.length(); position++)
+	int result = 0;
+
+	for (int position = 0; position < s.length(); position++)
 			{
-			int digit=Character.digit(s.charAt(position), radix);
-			if (digit==-1) throw new NumberFormatException();
+		int digit = Character.digit(s.charAt(position), radix);
+		if (digit == -1) throw new NumberFormatException();
 
-			result=(result*radix)+digit;
+		result = (result * radix) + digit;
 		}
 
 		return result;
-	}
 }
 
 public static String toBinaryString(int i) {
@@ -160,7 +151,7 @@
 }
 
 public String toString() {
-	return toString(this.intValue());		
+	return toString(value);
 }
 
 public static String toString(int i) {
@@ -177,10 +168,7 @@
 	}
 
 	StringBuffer buf = new StringBuffer();
-	int sign = 1;
-	if (i < 0) {
-		sign = -1;
-	}
+	int sign = (i < 0) ? -1 : 1;
 	while (i != 0) {
 		char digit = Character.forDigit(Math.abs(i % radix), radix);
 		i = i / radix;
@@ -190,7 +178,7 @@
 		buf.append('-');
 	}
 	buf.reverse();
-	return (buf.toString());
+	return buf.toString();
 }
 
 public static Integer valueOf(String s) throws NumberFormatException
@@ -209,14 +197,14 @@
 	}
 
 	StringBuffer buf = new StringBuffer();
-	int radix = 1 << bits, mask = radix-1;
+	int radix = 1 << bits, mask = radix - 1;
 	while (i != 0) {
 		char digit = Character.forDigit(i & mask, radix);
 		i >>>= bits;
 		buf.append(digit);
 	}
 	buf.reverse();
-	return (buf.toString());
+	return buf.toString();
 }
 
 }
diff -urN kaffe/libraries/javalib/java/lang/Long.java kaffe-patched/libraries/javalib/java/lang/Long.java
--- kaffe/libraries/javalib/java/lang/Long.java	Mon Feb  8 05:49:14 1999
+++ kaffe-patched/libraries/javalib/java/lang/Long.java	Mon Feb 22 11:57:17 1999
@@ -10,51 +10,48 @@
 
 package java.lang;
 
-
-final public class Long
-  extends Number
+public final class Long extends Number
 {
 	private final long value;
+
 	public static final long MIN_VALUE = 0x8000000000000000L;
 	public static final long MAX_VALUE = 0x7fffffffffffffffL;
 	public static final Class TYPE = Class.getPrimitiveClass("long");
 
-public Long(String s) throws NumberFormatException {
-	this(valueOf(s).longValue());
-}
+	/* This is what Sun's JDK1.1 "serialver java.lang.Long" spits out */
+	private static final long serialVersionUID = 4290774380558885855L;
 
 public Long(long value) {
-	this.value=value;
+	this.value = value;
+}
+
+public Long(String s) throws NumberFormatException {
+	this(valueOf(s).value);
 }
 
 public double doubleValue() {
-	return (double )value;
+	return (double)value;
 }
 
 public boolean equals(Object obj) {
-	if ((obj!=null) && (obj instanceof Long)) {
-		return (this.longValue()==((Long )obj).longValue());
-	}
-	else {
-		return false;
-	}
+	return (obj != null) &&
+	       (obj instanceof Long) &&
+	       (((Long)obj).value == value);
 }
 
 public float floatValue() {
-	return (float )value;
+	return (float)value;
 }
 
 public static Long getLong(String nm) {
-	return getLong(nm, (Long )null);
+	return getLong(nm, (Long)null);
 }
 
 public static Long getLong(String nm, Long val) {
-	String arg;
-
-	if (val==null) arg=null; else arg=val.toString();
+	String arg = (val != null) ? val.toString() : null;
 
-	String property=System.getProperty(nm, arg);
-	if (property==null) return val;
+	String property = System.getProperty(nm, arg);
+	if (property == null) return val;
 	else {
 		String toParse;
 		int radixToParse;
@@ -66,30 +63,30 @@
 		if (property.endsWith("l") || property.endsWith("L")) return val;
 
 		if (property.startsWith("0x")) {
-			toParse=property.substring(2);
-			radixToParse=16;
+			toParse = property.substring(2);
+			radixToParse = 16;
 		}
 		else if (property.startsWith("#")) {
-			toParse=property.substring(1);
-			radixToParse=16;
+			toParse = property.substring(1);
+			radixToParse = 16;
 		}
 		else if (property.startsWith("0")) {
-			toParse=property.substring(1);
-			radixToParse=8;
+			toParse = property.substring(1);
+			radixToParse = 8;
 		}
 		else {
-			toParse=property;
-			radixToParse=10;
+			toParse = property;
+			radixToParse = 10;
 		}
 
-		if (toParse.length()==0) {
+		if (toParse.length() == 0) {
 			return val;
 		}
 		else {
 			try {
 				return Long.valueOf(toParse, radixToParse);
 			}
-			catch (NumberFormatException e1) {
+			catch (NumberFormatException e) {
 				return val;
 			}
 		}
@@ -101,11 +98,11 @@
 }
 
 public int hashCode() {
-	return this.intValue();
+	return (int)value;
 }
 
 public int intValue() {
-	return (int )value;	
+	return (int)value;
 }
 
 public long longValue() {
@@ -117,41 +114,41 @@
 }
 
 public static long parseLong(String s, int radix) {
-	if (s.length()<=0) throw new NumberFormatException();
+	if (s.length() <= 0) throw new NumberFormatException();
 
 	/* Check for negativity */
-	if (s.charAt(0)=='-') {
-		return parseLong(s.substring(1))*-1;
+	if (s.charAt(0) == '-')
+	{
+		return -parseLong(s.substring(1));
 	}
-	else {
-		long result=0;
-		int position;
 
-		for (position=0; position<s.length(); position++) {
-			int digit=Character.digit(s.charAt(position), radix);
-			if (digit==-1) throw new NumberFormatException();
+	long result = 0;
+
+	for (int position = 0; position < s.length(); position++)
+	{
+		int digit = Character.digit(s.charAt(position), radix);
+		if (digit == -1) throw new NumberFormatException();
 
-			result=(result*radix)+digit;
+		result = (result * radix) + digit;
 		}
 
 		return result;
-	}			
 }
 
-public static String toBinaryString ( long i ) {
+public static String toBinaryString(long i) {
 	return toUnsignedString(i, 1);
 }
 
-public static String toHexString ( long i ) {
+public static String toHexString(long i) {
 	return toUnsignedString(i, 4);
 }
 
-public static String toOctalString ( long i ) {
+public static String toOctalString(long i) {
 	return toUnsignedString(i, 3);
 }
 
 public String toString() {
-	return toString(this.longValue());
+	return toString(value);
 }
 
 public static String toString(long i) {
@@ -168,10 +165,7 @@
 	}
 
 	StringBuffer buf = new StringBuffer();
-	int sign = 1;
-	if (i < 0) {
-		sign = -1;
-	}
+	int sign = (i < 0) ? -1 : 1;
 	while (i != 0) {
 		char digit = Character.forDigit(Math.abs((int)(i % radix)), radix);
 		i = i / (long)radix;
@@ -181,7 +175,7 @@
 		buf.append('-');
 	}
 	buf.reverse();
-	return (buf.toString());
+	return buf.toString();
 }
 
 private static String toUnsignedString(long i, int bits) {
@@ -190,14 +184,14 @@
 	}
 
 	StringBuffer buf = new StringBuffer();
-	int radix = 1 << bits, mask = radix-1;
+	int radix = 1 << bits, mask = radix - 1;
 	while (i != 0) {
 		char digit = Character.forDigit(((int)i) & mask, radix);
 		i >>>= bits;
 		buf.append(digit);
 	}
 	buf.reverse();
-	return (buf.toString());
+	return buf.toString();
 }
 
 public static Long valueOf(String s) throws NumberFormatException {
diff -urN kaffe/libraries/javalib/java/lang/Math.java kaffe-patched/libraries/javalib/java/lang/Math.java
--- kaffe/libraries/javalib/java/lang/Math.java	Fri Sep 11 13:30:40 1998
+++ kaffe-patched/libraries/javalib/java/lang/Math.java	Mon Feb 22 11:57:17 1999
@@ -1,7 +1,3 @@
-package java.lang;
-
-import java.util.Random;
-
 /*
  * Java core library component.
  *
@@ -11,176 +7,94 @@
  * See the file "license.terms" for information on usage and redistribution
  * of this file.
  */
-final public class Math
+
+package java.lang;
+
+import java.util.Random;
+
+public final class Math
 {
-	final public static double E = 2.7182818284590452354;
-	final public static double PI = 3.14159265358979323846;
+	public static final double E = 2.7182818284590452354;
+	public static final double PI = 3.14159265358979323846;
 	public static Random randomGenerator = new Random();
 
-native public static double IEEEremainder(double f1, double f2);
+private Math() { }
 
-public static double abs(double a) {
-	if (a < 0.0) {
-		return (-a);
-	}
-	else {
-		return (a);
-	}
-}
+public static native double IEEEremainder(double f1, double f2);
 
-public static float abs(float a) {
-	if (a < 0.0f) {
-		return (-a);
-	}
-	else {
-		return (a);
-	}
-}
+public static double abs(double a) { return (a < 0.0) ? (-a) : (a); }
 
-public static int abs(int a) {
-	if (a < 0) {
-		return (-a);
-	}
-	else {
-		return (a);
-	}
-}
+public static float abs(float a) { return (a < 0.0f) ? (-a) : (a); }
 
-public static long abs(long a) {
-	if (a < 0L) {
-		return (-a);
-	}
-	else {
-		return (a);
-	}
-}
+public static int abs(int a) { return (a < 0) ? (-a) : (a); }
 
-native public static double acos(double a);
+public static long abs(long a) { return (a < 0L) ? (-a) : (a); }
 
-native public static double asin(double a);
+public static native double acos(double a);
 
-native public static double atan(double a);
+public static native double asin(double a);
 
-native public static double atan2(double a, double b);
+public static native double atan(double a);
 
-native public static double ceil(double a);
+public static native double atan2(double a, double b);
 
-native public static double cos(double a);
+public static native double ceil(double a);
 
-native public static double exp(double a);
+public static native double cos(double a);
 
-native public static double floor(double a);
+public static native double exp(double a);
 
-native public static double log(double a);
+public static native double floor(double a);
 
-public static double max(double a, double b) {
-	if (b > a) {
-		return (b);
-	}
-	else {
-		return (a);
-	}
-}
+public static native double log(double a);
 
-public static float max(float a, float b) {
-	if (b > a) {
-		return (b);
-	}
-	else {
-		return (a);
-	}
-}
+public static double max(double a, double b) { return (b > a) ? (b) : (a); }
 
-public static int max(int a, int b) {
-	if (b > a) {
-		return (b);
-	}
-	else {
-		return (a);
-	}
-}
+public static float max(float a, float b) { return (b > a) ? (b) : (a); }
 
-public static long max(long a, long b) {
-	if (b > a) {
-		return (b);
-	}
-	else {
-		return (a);
-	}
-}
+public static int max(int a, int b) { return (b > a) ? (b) : (a); }
 
-public static double min(double a, double b) {
-	if (a < b) {
-		return (a);
-	}
-	else {
-		return (b);
-	}
-}
+public static long max(long a, long b) { return (b > a) ? (b) : (a); }
 
-public static float min(float a, float b) {
-	if (a < b) {
-		return (a);
-	}
-	else {
-		return (b);
-	}
-}
+public static double min(double a, double b) { return (a < b) ? (a) : (b); }
 
-public static int min(int a, int b) {
-	if (a < b) {
-		return (a);
-	}
-	else {
-		return (b);
-	}
-}
+public static float min(float a, float b) { return (a < b) ? (a) : (b); }
 
-public static long min(long a, long b) {
-	if (a < b) {
-		return (a);
-	}
-	else {
-		return (b);
-	}
-}
+public static int min(int a, int b) { return (a < b) ? (a) : (b); }
+
+public static long min(long a, long b) { return (a < b) ? (a) : (b); }
 
-native public static double pow(double a, double b);
+public static native double pow(double a, double b);
 
 public static synchronized double random() {
-	double dbl=randomGenerator.nextDouble();
-	return dbl;
+	return randomGenerator.nextDouble();
 }
 
-native public static double rint(double a);
+public static native double rint(double a);
 
 public static long round(double a) {
-	if ((a<(double )Long.MIN_VALUE) || (a==Double.NEGATIVE_INFINITY)) {
+	if ((a < (double)Long.MIN_VALUE) || (a == Double.NEGATIVE_INFINITY))
 		return Long.MIN_VALUE;
-	}
-	else if ((a>(double )Long.MAX_VALUE) || (a==Double.POSITIVE_INFINITY)) {
+
+	if ((a > (double)Long.MAX_VALUE) || (a == Double.POSITIVE_INFINITY))
 		return Long.MAX_VALUE;
-	}
-	else {
-		return (long )rint(a);
-	}
+
+	return (long)rint(a);
 }
 
 public static int round(float a) {
-	if ((a<(float )Integer.MIN_VALUE) || (a==Float.NEGATIVE_INFINITY)) {
+	if ((a < (float)Integer.MIN_VALUE) || (a == Float.NEGATIVE_INFINITY))
 		return Integer.MIN_VALUE;
-	}
-	else if ((a>(float )Integer.MAX_VALUE) || (a==Float.POSITIVE_INFINITY)) {
+
+	if ((a > (float)Integer.MAX_VALUE) || (a == Float.POSITIVE_INFINITY))
 		return Integer.MAX_VALUE;
-	}
-	else {
-		return (int )rint((double )a);
-	}
+
+	return (int)rint((double)a);
 }
 
-native public static double sin(double a);
+public static native double sin(double a);
 
-native public static double sqrt(double a);
+public static native double sqrt(double a);
 
-native public static double tan(double a);
+public static native double tan(double a);
 }
diff -urN kaffe/libraries/javalib/java/lang/Number.java kaffe-patched/libraries/javalib/java/lang/Number.java
--- kaffe/libraries/javalib/java/lang/Number.java	Wed Aug  5 23:16:18 1998
+++ kaffe-patched/libraries/javalib/java/lang/Number.java	Mon Feb 22 11:57:17 1999
@@ -1,7 +1,3 @@
-package java.lang;
-import java.io.Serializable;
-
-
 /*
  * Java core library component.
  *
@@ -11,7 +7,11 @@
  * See the file "license.terms" for information on usage and redistribution
  * of this file.
  */
-abstract public class Number implements Serializable 
+
+package java.lang;
+
+public abstract class Number
+	implements java.io.Serializable
 {
 	/* This is what Sun's JDK1.1 "serialver java.lang.Number" spits out */
 	private static final long serialVersionUID = -8742448824652078965L;
@@ -19,13 +19,14 @@
 public byte byteValue() {
 	return (byte)intValue();
 }
-abstract public double doubleValue();
 
-abstract public float floatValue();
+public abstract double doubleValue();
+
+public abstract float floatValue();
 
-abstract public int intValue();
+public abstract int intValue();
 
-abstract public long longValue();
+public abstract long longValue();
 
 public short shortValue() {
 	return (short)intValue();
diff -urN kaffe/libraries/javalib/java/lang/Object.java kaffe-patched/libraries/javalib/java/lang/Object.java
--- kaffe/libraries/javalib/java/lang/Object.java	Thu Dec 10 00:20:18 1998
+++ kaffe-patched/libraries/javalib/java/lang/Object.java	Mon Feb 22 11:57:17 1999
@@ -10,37 +10,36 @@
 
 package java.lang;
 
-
 public class Object
 {
-native protected Object clone() throws CloneNotSupportedException;
+protected native Object clone() throws CloneNotSupportedException;
 
 public boolean equals(Object obj) {
-	return (this==obj);  /* Well either its equal or it aint! */
+	return (this == obj);  /* Well either its equal or it aint! */
 }
 
 protected void finalize() throws Throwable {
 	/* Does nothing for Object class */
 }
 
-final native public Class  getClass();
+public final native Class getClass();
 
-native public int    hashCode();
+public native int hashCode();
 
-final native public void   notify();
+public final native void notify();
 
-final native public void   notifyAll();
+public final native void notifyAll();
 
 public String toString() {
-	return getClass().getName()+'@'+Integer.toHexString(hashCode());
+	return getClass().getName() + '@' + Integer.toHexString(hashCode());
 }
 
-final public void wait() throws InterruptedException {
+public final void wait() throws InterruptedException {
 	/* Just wait forever */
 	wait(0);
 }
 
-final public void wait(long timeout) throws InterruptedException {
+public final void wait(long timeout) throws InterruptedException {
 	if (Thread.interrupted()) {
 		throw new InterruptedException();
 	}
@@ -50,7 +49,7 @@
 	}
 }
 
-final public void wait(long timeout, int nanos) throws InterruptedException {
+public final void wait(long timeout, int nanos) throws InterruptedException {
 	/* Ignore nanos, except avoid clipping a non-zero quantity to zero */
 	if (timeout == 0 && nanos > 0)
 		timeout++;
@@ -58,5 +57,5 @@
 	wait(timeout);    
 }
 
-final native private void wait0(long timeout);
+private final native void wait0(long timeout);
 }
diff -urN kaffe/libraries/javalib/java/lang/Process.java kaffe-patched/libraries/javalib/java/lang/Process.java
--- kaffe/libraries/javalib/java/lang/Process.java	Tue Jul 28 17:41:52 1998
+++ kaffe-patched/libraries/javalib/java/lang/Process.java	Mon Feb 22 11:57:17 1999
@@ -1,8 +1,3 @@
-package java.lang;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-
 /*
  * Java core library component.
  *
@@ -12,20 +7,23 @@
  * See the file "license.terms" for information on usage and redistribution
  * of this file.
  */
-abstract public class Process
-  extends Object
-{
-public Process() {}
 
-abstract public void destroy();
+package java.lang;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public abstract class Process
+{
+public abstract void destroy();
 
-abstract public int exitValue();
+public abstract int exitValue();
 
-abstract public InputStream getErrorStream();
+public abstract InputStream getErrorStream();
 
-abstract public InputStream getInputStream();
+public abstract InputStream getInputStream();
 
-abstract public OutputStream getOutputStream();
+public abstract OutputStream getOutputStream();
 
-abstract public int waitFor() throws InterruptedException;
+public abstract int waitFor() throws InterruptedException;
 }
diff -urN kaffe/libraries/javalib/java/lang/ProcessInputStream.java kaffe-patched/libraries/javalib/java/lang/ProcessInputStream.java
--- kaffe/libraries/javalib/java/lang/ProcessInputStream.java	Tue Aug 25 23:01:45 1998
+++ kaffe-patched/libraries/javalib/java/lang/ProcessInputStream.java	Mon Feb 22 11:57:17 1999
@@ -24,19 +24,19 @@
 	super(in);
 }
 
-final public int read(byte b[]) throws IOException {
+public final int read(byte b[]) throws IOException {
 	return read(b, 0, b.length);
 }
 
-final public int read(byte b[], int off, int len) throws IOException {
+public final int read(byte b[], int off, int len) throws IOException {
 	return super.read(b, off, len);
 }
 
-final public boolean readBoolean() throws IOException {
+public final boolean readBoolean() throws IOException {
 	return (readByte()!=0);
 }
 
-final public byte readByte() throws IOException {
+public final byte readByte() throws IOException {
 	int value=super.read();
 
 	if (value==-1) throw new EOFException();
@@ -44,26 +44,26 @@
 	return (byte )value;
 }
 
-final public char readChar() throws IOException {
+public final char readChar() throws IOException {
 	int b1=readUnsignedByte();
 	int b2=readUnsignedByte();
 
 	return (char )((b1 << 8) | b2);
 }
 
-final public double readDouble() throws IOException {
+public final double readDouble() throws IOException {
 	return Double.longBitsToDouble(readLong());
 }
 
-final public float readFloat() throws IOException {
+public final float readFloat() throws IOException {
 	return Float.intBitsToFloat(readInt());
 }
 
-final public void readFully(byte b[]) throws IOException {
+public final void readFully(byte b[]) throws IOException {
 	readFully(b, 0, b.length);    
 }
 
-final public void readFully(byte b[], int off, int len) throws IOException {
+public final void readFully(byte b[], int off, int len) throws IOException {
 	int total = 0;
 	while (total < len) {
 		int got = read(b, off + total, len + total);
@@ -74,7 +74,7 @@
 	}
 }
 
-final public int readInt() throws IOException {
+public final int readInt() throws IOException {
 	int b1=readUnsignedByte();
 	int b2=readUnsignedByte();
 	int b3=readUnsignedByte();
@@ -85,7 +85,7 @@
 	return temp;
 }
 
-final public String readLine() throws IOException {
+public final String readLine() throws IOException {
 	boolean EOL=false;
 	StringBuffer buffer=new StringBuffer();
 
@@ -119,25 +119,25 @@
 	return buffer.toString();
 }
 
-final public long readLong() throws IOException {
+public final long readLong() throws IOException {
 	int i1=readInt(); /* b1-4 */
 	int i2=readInt(); /* b5-8 */
 
 	return (((long)i1) << 32) | (((long)i2) & 0xFFFFFFFF);
 }
 
-final public short readShort() throws IOException {
+public final short readShort() throws IOException {
 	int b1=readUnsignedByte();
 	int b2=readUnsignedByte();
 
 	return (short)((b1 << 8)|b2);		
 }
 
-final public String readUTF() throws IOException {
+public final String readUTF() throws IOException {
 	return readUTF(this);
 }
 
-final public static synchronized String readUTF(DataInput in) throws IOException {
+public static final synchronized String readUTF(DataInput in) throws IOException {
 	int length=in.readUnsignedShort();
 	StringBuffer buffer=new StringBuffer();
 
@@ -189,21 +189,21 @@
 	return buffer.toString();
 }
 
-final public int readUnsignedByte() throws IOException {
+public final int readUnsignedByte() throws IOException {
 	int value=super.read();
 
 	if (value==-1) throw new EOFException();
 	return (value & 0xFF);
 }
 
-final public int readUnsignedShort() throws IOException {
+public final int readUnsignedShort() throws IOException {
 	int b1=readUnsignedByte();
 	int b2=readUnsignedByte();
 
 	return (int )(b1 << 8) | b2;
 }
 
-final public int skipBytes(int n) throws IOException {
+public final int skipBytes(int n) throws IOException {
 	long temp = super.skip((long)n);
 	int skipped = (int)temp;
 
diff -urN kaffe/libraries/javalib/java/lang/Runtime.java kaffe-patched/libraries/javalib/java/lang/Runtime.java
--- kaffe/libraries/javalib/java/lang/Runtime.java	Wed Feb 10 22:34:45 1999
+++ kaffe-patched/libraries/javalib/java/lang/Runtime.java	Mon Feb 22 11:57:17 1999
@@ -32,11 +32,11 @@
 private String[] paths = null;
 private static kaffe.lang.MemoryAdvice advice = kaffe.lang.MemoryAdvice.getInstance();
 
-private Runtime () {
+private void initPaths() {
 	String pathSpec = initializeLinkerInternal();
 
-	if ( pathSpec != null ) {
-		StringTokenizer tk = new StringTokenizer( pathSpec, System.getProperty("path.separator"));
+	if (pathSpec != null) {
+		StringTokenizer tk = new StringTokenizer(pathSpec, System.getProperty("path.separator"));
 		paths = new String[tk.countTokens()];
 
 		for (int pos = 0; tk.hasMoreTokens(); pos++) {
@@ -45,20 +45,24 @@
 	}
 }
 
-native private String  buildLibName(String path, String name);
+private Runtime () {
+	initPaths();
+}
+
+private native String buildLibName(String path, String name);
 
 public Process exec(String command) throws IOException {
 	return exec(command, null);
 }
 
 public Process exec(String command, String envp[]) throws IOException {
-	StringTokenizer tokenizer=new StringTokenizer(command);
+	StringTokenizer tokenizer = new StringTokenizer(command);
 
-	int count=tokenizer.countTokens();
-	String cmdarray[]=new String[count];
+	int count = tokenizer.countTokens();
+	String cmdarray[] = new String[count];
 
-	for (int pos=0; pos<count; pos++) {
-		cmdarray[pos]=tokenizer.nextToken();
+	for (int pos = 0; pos < count; pos++) {
+		cmdarray[pos] = tokenizer.nextToken();
 	}
 
 	return exec(cmdarray, envp);
@@ -73,18 +77,19 @@
 	return execInternal(cmdarray, envp);
 }
 
-native private Process execInternal(String cmdarray[], String envp[]) throws IOException;
+private native Process execInternal(String cmdarray[], String envp[])
+	throws IOException;
 
 public void exit(int status) {
 	System.getSecurityManager().checkExit(status);
 	exitInternal(status);
 }
 
-native private void exitInternal(int status);
+private native void exitInternal(int status);
 
-native public long freeMemory();
+public native long freeMemory();
 
-native public void gc();
+public native void gc();
 
 /**
  * @deprecated
@@ -104,17 +109,7 @@
 	return currentRuntime;		
 }
 
-private void initPaths() {
-	StringTokenizer tk = new StringTokenizer(initializeLinkerInternal(), System.getProperty("path.separator"));
-
-	paths = new String[tk.countTokens()];
-
-	for (int pos = 0; tk.hasMoreTokens(); pos++) {
-		paths[pos] = tk.nextToken();
-	}
-}
-
-native private String  initializeLinkerInternal();
+private native String initializeLinkerInternal();
 
 public synchronized void load(String filename) {
 	if (loadInternal(filename) == false) {
@@ -122,7 +117,7 @@
 	}
 }
 
-native private boolean loadFileInternal(String filename);
+private native boolean loadFileInternal(String filename);
 
 private boolean loadInternal(String filename) {
 	System.getSecurityManager().checkLink(filename);
@@ -145,20 +140,20 @@
 }
 
 public int getMemoryAdvice() {
-	return (advice.getColor());
+       return (advice.getColor());
 }
 
 public int waitForMemoryAdvice(int level) throws InterruptedException {
-	return (advice.waitForOtherColor(level));
+       return (advice.waitForOtherColor(level));
 }
 
-native public void runFinalization();
+public native void runFinalization();
 
-native public void runFinalizersOnExit(boolean value);
+public static native void runFinalizersOnExit(boolean value);
 
-native public long totalMemory();
+public native long totalMemory();
 
-native public void traceInstructions(boolean on);
+public native void traceInstructions(boolean on);
 
-native public void traceMethodCalls(boolean on);
+public native void traceMethodCalls(boolean on);
 }
diff -urN kaffe/libraries/javalib/java/lang/SecurityManager.java kaffe-patched/libraries/javalib/java/lang/SecurityManager.java
--- kaffe/libraries/javalib/java/lang/SecurityManager.java	Wed Feb 10 22:34:46 1999
+++ kaffe-patched/libraries/javalib/java/lang/SecurityManager.java	Mon Feb 22 11:57:17 1999
@@ -15,7 +15,7 @@
 import java.lang.Class;
 import java.net.InetAddress;
 
-abstract public class SecurityManager {
+public abstract class SecurityManager {
 
 protected SecurityManager() {
 }
@@ -200,24 +200,14 @@
  * @deprecated, Deprecated in 1.2
  */
 protected boolean inClass(String name) {
-	if (classDepth(name) == -1) {
-		return (false);
-	}
-	else {
-		return (true);
-	}
+	return (classDepth(name) != -1);
 }
 
 /**
  * @deprecated, Deprecated in 1.2
  */
 protected boolean inClassLoader() {
-	if (classLoaderDepth() == -1) {
-		return (false);
-	}
-	else {
-		return (true);
-	}
+	return (classLoaderDepth() != -1);
 }
 
 protected Class[] getClassContext() {
diff -urN kaffe/libraries/javalib/java/lang/Short.java kaffe-patched/libraries/javalib/java/lang/Short.java
--- kaffe/libraries/javalib/java/lang/Short.java	Mon Feb  8 05:49:14 1999
+++ kaffe-patched/libraries/javalib/java/lang/Short.java	Mon Feb 22 11:57:17 1999
@@ -1,6 +1,3 @@
-package java.lang;
-
-
 /*
  * Java core library component.
  *
@@ -10,102 +7,112 @@
  * See the file "license.terms" for information on usage and redistribution
  * of this file.
  */
-final public class Short
-  extends Number
+
+package java.lang;
+
+public final class Short extends Number
 {
-	final public static short MIN_VALUE = -0x8000;
-	final public static short MAX_VALUE = 0x7FFF;
-	final public static Class TYPE = Class.getPrimitiveClass("short");
 	private final short value;
 
-public Short(String s) throws NumberFormatException
-{
-	this(parseShort(s));
-}
+	public static final short MIN_VALUE = -0x8000;
+	public static final short MAX_VALUE = 0x7FFF;
+	public static final Class TYPE = Class.getPrimitiveClass("short");
+
+	/* This is what Sun's JDK1.1 "serialver java.lang.Short" spits out */
+	private static final long serialVersionUID = 7515723908773894738L;
 
 public Short(short value)
 {
 	this.value = value;
 }
 
+public Short(String s) throws NumberFormatException
+{
+	value = parseShort(s);
+}
+
 public static Short decode(String nm) throws NumberFormatException
 {
-	short val;
+	short sh;
 
 	if (nm.startsWith("0x")) {
-		val = parseShort(nm.substring(2), 16);
+		sh = parseShort(nm.substring(2), 16);
 	}
 	else if (nm.startsWith("#")) {
-		val = parseShort(nm.substring(1), 16);
+		sh = parseShort(nm.substring(1), 16);
 	}
-	else if (nm.startsWith("0")) {
-		val = parseShort(nm.substring(1), 8);
+	else if (nm.startsWith("0") && nm.length() > 1) {
+		sh = parseShort(nm.substring(1), 8);
 	}
 	else {
-		val = parseShort(nm.substring(1), 10);
+		sh = parseShort(nm, 10);
 	}
 
-	return (new Short(val));
+	return new Short(sh);
 }
 
 public double doubleValue()
-	{
-	return ((double)value);
+{
+	return (double)value;
 }
 
-public boolean equals(Object obj) {
+public boolean equals(Object obj)
+{
 	return (obj != null)
 	    && (obj instanceof Short)
 	    && (((Short) obj).value == this.value);
 }
 
 public float floatValue()
-	{
-	return ((float)value);
+{
+	return (float)value;
 }
 
 public int hashCode()
-	{
-	return (value);	// What should this be do you suppose ???
+{
+	return (int)value;	// What should this be do you suppose ???
 }
 
 public int intValue()
-	{
-	return ((int)value);
+{
+	return (int)value;
 }
 
 public long longValue()
-	{
-	return ((long)value);
+{
+	return (long)value;
 }
 
 public static short parseShort(String s) throws NumberFormatException
 {
-	return ((short)parseShort(s, 10));
+	return parseShort(s, 10);
 }
 
 public static short parseShort(String s, int radix) throws NumberFormatException
 {
-	return ((short)Integer.parseInt(s, radix));
+	int i = Integer.parseInt(s, radix);
+	if (i < MIN_VALUE || MAX_VALUE < i)
+		throw new NumberFormatException();
+	return (short)i;
 }
 
 public String toString()
-	{
-	return (toString(value));
+{
+	return toString(value);
 }
 
 public static String toString(short s)
-	{
+{
 	return Integer.toString((int)s);
 }
 
 public static Short valueOf(String s) throws NumberFormatException
 {
-	return (new Short(parseShort(s)));
+	return new Short(parseShort(s));
 }
 
 public static Short valueOf(String s, int radix) throws NumberFormatException
 {
-	return (new Short(parseShort(s, radix)));
+	return new Short(parseShort(s, radix));
 }
 }
diff -urN kaffe/libraries/javalib/java/lang/String.java kaffe-patched/libraries/javalib/java/lang/String.java
--- kaffe/libraries/javalib/java/lang/String.java	Wed Feb 10 22:34:46 1999
+++ kaffe-patched/libraries/javalib/java/lang/String.java	Mon Feb 22 11:57:17 1999
@@ -20,7 +20,10 @@
 import kaffe.io.ByteToCharConverter;
 import kaffe.io.CharToByteConverter;
 
-final public class String implements Serializable {
+public final class String implements Serializable
+{
+	// value, offset, and count are not private:
+	// StringBuffer uses them for faster access
 	char[] value;
 	int offset;
 	int count;
@@ -35,10 +38,10 @@
 }
 
 public String( String other) {
-	this( other.toCharArray());
+	this( other.value, other.offset, other.count);
 }
 
-public String (StringBuffer sb) {
+public String( StringBuffer sb) {
 	synchronized (sb) {
 		count = sb.length();
 		value = new char[count];
@@ -69,7 +72,8 @@
 	initString( bytes, offset, length, ByteToCharConverter.getDefault());
 }
 
-public String( byte[] bytes, int offset, int length, String enc) throws UnsupportedEncodingException
+public String( byte[] bytes, int offset, int length, String enc)
+	throws UnsupportedEncodingException
 {
 	initString( bytes, offset, length, ByteToCharConverter.getConverter(enc));
 }
@@ -78,12 +82,21 @@
  * @deprecated
  */
 public String( byte ascii[], int hibyte, int offset, int count) {
-	value = new char[count];
-	this.count = count;
-
-	for (int pos=0; pos<count; pos++) {
-		value[pos]=(char )(((hibyte & 0xFF) << 8) | (ascii[pos+offset] & 0xFF));	
+	if ( offset < 0)
+		throw new StringIndexOutOfBoundsException( offset);
+	if ( count < 0)
+		throw new StringIndexOutOfBoundsException( count);
+	if (ascii.length - count < offset)
+		throw new StringIndexOutOfBoundsException( offset + count);
+
+	char value[] = new char[count];
+	hibyte = (hibyte & 0xFF) << 8;
+	for (int pos = 0; pos < count; pos++) {
+		value[pos] = (char )(hibyte | (ascii[offset + pos] & 0xFF));
 	}
+
+	this.value = value;
+	this.count = count;
 }
 
 public String( char other[]) {
@@ -91,6 +104,13 @@
 }
 
 public String( char other[], int offset, int count) {
+	if ( offset < 0)
+		throw new StringIndexOutOfBoundsException( offset);
+	if ( count < 0)
+		throw new StringIndexOutOfBoundsException( count);
+	if ( other.length - count < offset)
+		throw new StringIndexOutOfBoundsException( offset + count);
+
 	value = new char[count];
 	this.count = count;    
 
@@ -104,33 +124,38 @@
 	count  = eIdx - sIdx;
 }
 
-public char charAt ( int index ) {
+public char charAt( int index) {
 	if (( index < 0) || ( index >= count))
-		throw new StringIndexOutOfBoundsException();
+		throw new StringIndexOutOfBoundsException( index);
 
-	return value[offset+index];
+	return value[offset + index];
 }
 
 public int compareTo( String s1) {
-	/* lexicographical comparison, assume they mean English lexiographical, since Character has no ordering */
-
+	/* lexicographical comparison, assume they mean English lexiographical,
+	 * since Character has no ordering
+	 */
 	int minLen = Math.min( count, s1.count);
 	char c, c1;
 
-	for ( int pos=0; pos<minLen; pos++) {
-		/* Can we guarantee that the Unicode '<' relation means also numerically '<'.. Probably, but just incase */
-		c = value[offset+pos]; c1 = s1.value[s1.offset+pos];
-		if ( c != c1) return ( c-c1);
+	for ( int pos = 0; pos < minLen; pos++) {
+		/* Can we guarantee that the Unicode '<' relation means also
+		 * numerically '<'.. Probably, but just incase
+		 */
+		c = value[offset + pos]; c1 = s1.value[s1.offset + pos];
+		if ( c != c1) return ( c - c1);
 	}
 
-	/* Both equal up to min length, therefore check lengths for lexiographical ordering */
+	/* Both equal up to min length,
+	 * therefore check lengths for lexiographical ordering
+	 */
 	return ( count - s1.count);
 }
 
 public String concat(String str) {
 	if ( (str == null) || (str.count == 0) )
 		return this; 
-	char buf[]=new char[count+str.count];
+	char buf[] = new char[count + str.count];
 	getChars(0, count, buf, 0);
 	str.getChars(0, str.count, buf, count);
 	return new String(0, buf.length, buf); 
@@ -141,7 +166,7 @@
 }
 
 public static String copyValueOf(char data[], int offset, int count) {
-	char buf[]=new char[count];
+	char buf[] = new char[count];
 	if ( count > 0)
 		System.arraycopy( data, offset, buf, 0, count);
 
@@ -152,9 +177,9 @@
 	return regionMatches( false, count-suffix.count, suffix, 0, suffix.count);
 }
 
-public boolean equals ( Object anObject) {
-	// this is one of the most frequently called methods, it has to be as
-	// efficient as possible
+public boolean equals( Object anObject) {
+	// this is one of the most frequently called methods,
+	// it has to be as efficient as possible
 
 	if (!(anObject instanceof String)) {
 		return (false);
@@ -165,28 +190,32 @@
 		return (false);
 	}
 
+	char[] value = this.value, other_value = other.value;
+
 	int i = offset;
 	int j = other.offset;
 	int n = offset + count;
 	for (; i < n; i++, j++) {
-		if (value[i] != other.value[j] ) {
+		if (value[i] != other_value[j] ) {
 			return (false);
 		}
 	}
 	return (true);
 }
 
-public boolean equalsIgnoreCase (String other) {
+public boolean equalsIgnoreCase( String other) {
 	if (other == null || count != other.count) {
 		return (false);
 	}
 
+	char[] value = this.value, other_value = other.value;
+
 	int i = offset;
 	int j = other.offset;
 	int n = offset + count;
 
 	for (; i < n; i++, j++ ) {
-		if (value[i] != other.value[j] && Character.toUpperCase(value[i]) != Character.toUpperCase(other.value[j])) {
+		if (value[i] != other_value[j] && Character.toUpperCase(value[i]) != Character.toUpperCase(other_value[j])) {
 			return (false);
 		}
 	}
@@ -219,19 +248,34 @@
  * @deprecated
  */
 public void getBytes( int srcBegin, int srcEnd, byte dst[], int dstBegin) {
-	int len = srcEnd-srcBegin;
+	if ( srcBegin < 0)
+		throw new StringIndexOutOfBoundsException( srcBegin);
+	if ( srcEnd > count)
+		throw new StringIndexOutOfBoundsException( srcEnd);
+	if ( srcBegin > srcEnd)
+		throw new StringIndexOutOfBoundsException( srcEnd - srcBegin);
+
+	final int len = srcEnd - srcBegin;
 	for (int pos = 0; pos < len; pos++) {
-		dst[dstBegin+pos] = (byte)value[offset+srcBegin+pos];
+		dst[dstBegin + pos] = (byte)value[offset + srcBegin + pos];
 	}
 }
 
-public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin) {
-	System.arraycopy( value, offset+srcBegin, dst, dstBegin, srcEnd-srcBegin);
+public void getChars( int srcBegin, int srcEnd, char dst[], int dstBegin) {
+	if ( srcBegin < 0)
+		throw new StringIndexOutOfBoundsException( srcBegin);
+	if ( srcEnd > count)
+		throw new StringIndexOutOfBoundsException( srcEnd);
+	if ( srcBegin > srcEnd)
+		throw new StringIndexOutOfBoundsException( srcEnd - srcBegin);
+
+	System.arraycopy( value, offset + srcBegin, dst, dstBegin, srcEnd - srcBegin);
 }
 
 public int hashCode() {
 	if (hash == 0 && count > 0) {
 		final int stop = offset + count;
+		char[] value = this.value;
 		for (int index = offset; index < stop; index++) {
 			hash = (31 * hash) + value[index];
 		}
@@ -244,17 +288,17 @@
 }
 
 public int indexOf( String str, int sIdx) {
-	int it  = offset+sIdx;
+	int it  = offset + sIdx;
 	int ic  = str.offset;
 	int ma  = 0;
 
-	if ( str.count > count-sIdx )
+	if ( str.count > count - sIdx)
 		return -1;
 
-	for ( ; it<value.length; it++){
-		if ( value[it] == str.value[ic] ){
+	for ( ; it < value.length; it++){
+		if ( value[it] == str.value[ic]) {
 			if (++ma == str.count)
-				return ( it-ma-offset+1);
+				return ( it - ma - offset + 1);
 			ic++;
 		}
 		else if ( ma > 0) {
@@ -274,11 +318,13 @@
 
 public int indexOf( int ch, int sIdx) {
 	char c = (char)ch;
-	if (sIdx < 0) { // calling indexOf with sIdx < 0 is apparently okay
+	if ( sIdx < 0) { // calling indexOf with sIdx < 0 is apparently okay
 		sIdx = 0;
 	}
-	for (int pos=sIdx; pos<count; pos++) {
-		if ( value[offset+pos] == c )
+
+	char[] value = this.value;
+	for ( int pos = sIdx; pos < count; pos++) {
+		if ( value[offset + pos] == c)
 			return pos;
 	}
 
@@ -297,7 +343,7 @@
 	String str = sbuf.toString();
 
 	value = str.value;
-	offset = str.offset;
+	this.offset = str.offset;
 	count  = str.count;
 }
 
@@ -306,41 +352,41 @@
 }
 
 public int lastIndexOf( String str, int eIdx) {
-	int ic = str.offset+str.count-1;
-	int it = offset+eIdx+ic;
+	int ic = str.offset + str.count - 1;
+	int it = offset + eIdx + ic;
 	int ma = 0;
 
-	if (it >= offset+count) {       // clip index
-		it = offset+count-1;
+	if (it >= offset + count) {	// clip index
+		it = offset + count - 1;
 	}
 
-	for ( ; it>=offset; it--) {
+	for ( ; it >= offset; it--) {
 		if ( value[it] == str.value[ic] ) {
 			ic--;
 			if ( ++ma == str.count) {
-				return (it-offset);
+				return (it - offset);
 			}
 		}
 		else if (ma > 0) {
 			it++;
 			ma = 0;
-			ic = str.offset+str.count-1;
+			ic = str.offset + str.count - 1;
 		}
 	}
 	return -1;
 }
 
 public int lastIndexOf( int ch) {
-	return lastIndexOf( ch, count-1);
+	return lastIndexOf( ch, count - 1);
 }
 
 public int lastIndexOf( int ch, int eIdx) {
 	char c = (char)ch;
 	if ( eIdx >= count) {
-		eIdx = count-1;
+		eIdx = count - 1;
 	}
-	for (int pos=eIdx; pos>=0; pos--) {
-		if ( value[offset+pos] == c)
+	for (int pos = eIdx; pos >= 0; pos--) {
+		if ( value[offset + pos] == c)
 			return pos;
 	}
 
@@ -355,13 +401,13 @@
 	if (toffset < 0 || ooffset < 0) {
 		return false;
 	}
-	if ( (toffset+len > count) || (ooffset+len > other.count) )
+	if ( (toffset + len > count) || (ooffset + len > other.count) )
 		return false;
 
 	char c, c1;
-	for (int pos=0; pos<len; pos++) {
-		c  = value[offset+toffset+pos];
-		c1 = other.value[other.offset+ooffset+pos];
+	for (int pos = 0; pos < len; pos++) {
+		c  = value[offset + toffset + pos];
+		c1 = other.value[other.offset + ooffset + pos];
 		if ( (c != c1) && ignoreCase) {
 			c  = Character.toLowerCase( c);
 			c1 = Character.toLowerCase( c1);
@@ -380,12 +426,10 @@
 public String replace(char oldChar, char newChar) {
 	char buf[] = new char[count];
 
-	for (int pos=0; pos<count; pos++) {
-		char cc = value[offset+pos];
-		if ( cc == oldChar)
-			buf[pos] = newChar;
-		else
-			buf[pos] = cc;
+	char[] value = this.value;
+	for (int pos = 0; pos < count; pos++) {
+		char cc = value[offset + pos];
+		buf[pos] = ( cc == oldChar) ? newChar : cc;
 	}
 
 	return new String( 0, count, buf);
@@ -407,22 +451,24 @@
  * shared data
  */
 public String substring( int sIdx, int eIdx) {
-	if ( sIdx < 0)     throw new StringIndexOutOfBoundsException( sIdx);
-	if ( eIdx > count) throw new StringIndexOutOfBoundsException( eIdx);
-	if ( sIdx > eIdx)  throw new StringIndexOutOfBoundsException( eIdx-sIdx);
+	if ( sIdx < 0)
+		throw new StringIndexOutOfBoundsException( sIdx);
+	if ( eIdx > count)
+		throw new StringIndexOutOfBoundsException( eIdx);
+	if ( sIdx > eIdx)
+		throw new StringIndexOutOfBoundsException( eIdx - sIdx);
 
-	if ( ( sIdx == 0) && ( eIdx  == count ) )
+	if (( sIdx == 0) && ( eIdx == count))
 		return this;
 
-	return new String( offset+sIdx, offset+eIdx, value);
-
+	return new String( offset + sIdx, offset + eIdx, value);
 }
 
 public char[] toCharArray() {
 	char buf[] = new char[count];
-	if ( count > 0)
+	if ( count > 0) {
 		getChars( 0, count, buf, 0);
-
+	}
 	return buf;
 }
 
@@ -433,7 +479,7 @@
 public String toLowerCase( Locale lcl) {
 	char buf[] = new char[count];
 	for (int pos = 0; pos < count; pos++)
-		buf[pos] = Character.toLowerCase( value[offset+pos]);
+		buf[pos] = Character.toLowerCase( value[offset + pos]);
 
 	return new String( 0, count, buf);
 }
@@ -448,42 +494,38 @@
 
 public String toUpperCase( Locale lcl) {
 	char buf[] = new char[count];
-	for (int pos=0; pos < count; pos++)
-		buf[pos] = Character.toUpperCase( value[offset+pos]);
+	for (int pos = 0; pos < count; pos++)
+		buf[pos] = Character.toUpperCase( value[offset + pos]);
 
 	return new String( 0, count, buf);
 }
 
 public String trim() {
 	int i0 = offset;
-	int i1 = offset+count-1;
+	int i1 = offset + count - 1;
 
-	for ( ;(i0 <= i1) && (value[i0] <= ' '); i0++ );
+	for ( ;(i0 <= i1) && (value[i0] <= ' '); i0++ ) ;
 	if ( i0 > i1 ) return "";
-	for ( ;(i1 > i0) && (value[i1] <= ' '); i1-- );
+	for ( ;(i1 > i0) && (value[i1] <= ' '); i1-- ) ;
 
-	return substring( i0-offset, i1+1-offset);
+	return substring( i0 - offset, i1 + 1 - offset);
 }
 
 public static String valueOf( Object obj) {
-	if (obj==null) {
-		return "null";
-	}
-	return obj.toString();
+	return (obj == null) ? "null" : obj.toString();
 }
 
 public static String valueOf( boolean b) {
-	return ( new Boolean(b)).toString();
+	return b ? "true" : "false";
 }
 
 public static String valueOf( char c) {
-	char ca[] = new char[1];
-	ca[0] = c;
-	return new String( ca);
+	char data[] = { c };
+	return new String( data);
 }
 
-public static String valueOf(char data[]) {
-	return new String(data);
+public static String valueOf( char data[]) {
+	return new String( data);
 }
 
 public static String valueOf( char data[], int offset, int count) {
@@ -491,30 +533,25 @@
 }
 
 public static String valueOf( double d) {
-	return ( new Double(d)).toString();
+	return Double.toString(d);
 }
 
 public static String valueOf( float f) {
-	return ( new Float(f)).toString();
+	return Float.toString(f);
 }
 
 public static String valueOf( int i) {
-	return ( new Integer(i)).toString();
+	return Integer.toString(i);
 }
 
 public static String valueOf( long l) {
-	return ( new Long(l)).toString();
+	return Long.toString(l);
 }
 
-final public String intern() {
-	if (interned == false) {
-		return (intern0(this));
-	}
-	else {
-		return (this);
-	}
+public final String intern() {
+	return (interned) ? this : intern0(this);
 }
 
-final native static public synchronized String intern0(String str);
+public static final synchronized native String intern0(String str);
 
 }
diff -urN kaffe/libraries/javalib/java/lang/StringBuffer.java kaffe-patched/libraries/javalib/java/lang/StringBuffer.java
--- kaffe/libraries/javalib/java/lang/StringBuffer.java	Wed Feb 10 22:34:46 1999
+++ kaffe-patched/libraries/javalib/java/lang/StringBuffer.java	Mon Feb 22 11:57:17 1999
@@ -1,6 +1,3 @@
-package java.lang;
-
-
 /*
  * Java core library component.
  *
@@ -10,202 +7,220 @@
  * See the file "license.terms" for information on usage and redistribution
  * of this file.
  */
-final public class StringBuffer
+
+package java.lang;
+
+public final class StringBuffer
+	implements java.io.Serializable
 {
 	private char[] buffer;
 	private int used;
-	final private int SPARECAPACITY = 16;
+	private final int SPARECAPACITY = 16;
+
+	// This is what Sun's JDK1.1 "serialver java.lang.StringBuffer" spits out
+	private static final long serialVersionUID = 3388685877147921107L;
 
 public StringBuffer()
-	{
-	buffer=new char[SPARECAPACITY];
+{
+	buffer = new char[SPARECAPACITY];
 }
 
 public StringBuffer(String str)
-	{
-	if ( str == null)
-		str = String.valueOf( str);
-	used   = str.length();
-	buffer = new char[used+SPARECAPACITY];
-	System.arraycopy(str.toCharArray(), 0, buffer, 0, used);
+{
+	if (str == null)
+		str = String.valueOf(str);
+	used = str.count;
+	buffer = new char[used + SPARECAPACITY];
+	System.arraycopy(str.value, str.offset, buffer, 0, used);
 }
 
 public StringBuffer(int length)
-	{
-	if (length<0) throw new NegativeArraySizeException();
-	buffer=new char[length];
+{
+	if (length < 0)
+		throw new NegativeArraySizeException();
+	buffer = new char[length];
 }
 
-public synchronized StringBuffer append(Object obj) {
+public /* synchronized */ StringBuffer append(Object obj)
+{
 	return append(String.valueOf(obj));
 }
 
-public synchronized StringBuffer append ( String str ) {
-	if (str == null) {
-		str = String.valueOf( str);
-	}
-	return (append( str.value, str.offset, str.count));
+public /* synchronized */ StringBuffer append(String str)
+{
+	if (str == null)
+		str = String.valueOf(str);
+
+	return append(str.value, str.offset, str.count);
 }
 
 public StringBuffer append(boolean b)
-	{
+{
 	return append(String.valueOf(b));
 }
 
 public synchronized StringBuffer append(char c)
 {
-	if ( used + 1 > buffer.length ) {
-		ensureCapacity(used+1);
-	}
-	buffer[used] = c;
-	used++;
+	if (used + 1 > buffer.length)
+		ensureCapacity(used + 1);
+
+	buffer[used++] = c;
 
 	return (this);
 }
 
-public synchronized StringBuffer append(char str[])
+public /* synchronized */ StringBuffer append(char str[])
 {
 	return append(str, 0, str.length);
 }
 
-public synchronized StringBuffer append ( char str[], int offset, int len ) {
-
-	if ( used + len > buffer.length )
-		ensureCapacity(used+len);
+public synchronized StringBuffer append(char str[], int offset, int len)
+{
+	if (used + len > buffer.length)
+		ensureCapacity(used + len);
 
-	System.arraycopy( str, offset, buffer, used, len);
+	System.arraycopy(str, offset, buffer, used, len);
 	used += len;
 
 	return this;
 }
 
 public StringBuffer append(double d)
-	{
+{
 	return append(String.valueOf(d));
 }
 
 public StringBuffer append(float f)
-	{
+{
 	return append(String.valueOf(f));
 }
 
 public StringBuffer append(int i)
-	{
+{
 	return append(String.valueOf(i));
 }
 
 public StringBuffer append(long l)
-	{
+{
 	return append(String.valueOf(l));
 }
 
 public int capacity()
-	{
+{
 	return buffer.length;
 }
 
 public synchronized char charAt(int index)
-	{
+{
 	checkIndex(index);
 	return buffer[index];
 }
 
-private synchronized void checkIndex(int index) throws StringIndexOutOfBoundsException
+private synchronized void checkIndex(int index)
+	throws StringIndexOutOfBoundsException
 {
 	if (index < 0 || index >= used)
 		throw new StringIndexOutOfBoundsException("index = " + index + ", used = " + used);
 }
 
-public synchronized void ensureCapacity ( int minimumCapacity ) {
-	int    n;
-	char[] oldBuffer;
-
-	if ( (minimumCapacity < 0) || (buffer.length > minimumCapacity) ) return; 
+public synchronized void ensureCapacity(int minimumCapacity)
+{
+	if ((minimumCapacity < 0) || (buffer.length > minimumCapacity))
+		return;
 
-	n = buffer.length*2;
-	if ( minimumCapacity > n ) n = minimumCapacity;
+	int n = buffer.length * 2;
+	if (minimumCapacity > n)
+		n = minimumCapacity;
 
-	oldBuffer = buffer;
+	char[] oldBuffer = buffer;
 	buffer = new char[n];
 
-	System.arraycopy( oldBuffer, 0, buffer, 0, used);
+	System.arraycopy(oldBuffer, 0, buffer, 0, used);
 }
 
 public synchronized void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin)
-	{
+{
 	checkIndex(srcBegin);
-	checkIndex(srcEnd-1);
-	System.arraycopy(buffer, srcBegin, dst, dstBegin, srcEnd-srcBegin);
+	checkIndex(srcEnd - 1);
+	System.arraycopy(buffer, srcBegin, dst, dstBegin, srcEnd - srcBegin);
 }
 
-public synchronized StringBuffer insert(int offset, Object obj)
-	{
+public /* synchronized */ StringBuffer insert(int offset, Object obj)
+{
 	return insert(offset, String.valueOf(obj));
 }
 
-public synchronized StringBuffer insert(int offset, String str)
-	{
-	if ( str == null)
-		str = String.valueOf( str);
-	return insert(offset, str.toCharArray());
+public /* synchronized */ StringBuffer insert(int offset, String str)
+{
+	if (str == null)
+		str = String.valueOf(str);
+
+	return insert(offset, str.value, str.offset, str.count);
 }
 
 public StringBuffer insert(int offset, boolean b)
-	{
+{
 	return insert(offset, String.valueOf(b));
 }
 
-public synchronized StringBuffer insert(int offset, char c)
-	{
-	return insert(offset, String.valueOf(c));
+public /* synchronized */ StringBuffer insert(int offset, char c)
+{
+	char str[] = { c };
+	return insert(offset, str, 0, 1);
+}
+
+public /* synchronized */ StringBuffer insert(int offset, char str[])
+{
+	return insert(offset, str, 0, str.length);
 }
 
-public synchronized StringBuffer insert(int offset, char str[])
-	{
+synchronized StringBuffer insert(int offset, char str[], int from, int len)
+{
 	if ((offset < 0) || (offset > used))
-		throw new StringIndexOutOfBoundsException();
+		throw new StringIndexOutOfBoundsException(offset);
 
-	ensureCapacity(used + str.length);
+	ensureCapacity(used + len);
 
 	// Copy buffer up to make space.
-	System.arraycopy(buffer, offset, buffer, offset+str.length, used-offset);
+	System.arraycopy(buffer, offset, buffer, offset + len, used - offset);
 
 	/* Now, copy insert into place */
-	System.arraycopy(str, 0, buffer, offset, str.length);
+	System.arraycopy(str, from, buffer, offset, len);
 
 	/* Update used count */
-	used += str.length;
+	used += len;
 
 	return (this);
 }
 
 public StringBuffer insert(int offset, double d)
-	{
+{
 	return insert(offset, String.valueOf(d));
 }
 
 public StringBuffer insert(int offset, float f)
-	{
+{
 	return insert(offset, String.valueOf(f));
 }
 
 public StringBuffer insert(int offset, int i)
-	{
+{
 	return insert(offset, String.valueOf(i));
 }
 
 public StringBuffer insert(int offset, long l)
-	{
+{
 	return insert(offset, String.valueOf(l));
 }
 
 public int length()
-	{
+{
 	return used;
 }
 
 public synchronized StringBuffer reverse()
-	{
+{
+	char[] buffer = this.buffer;
 	for (int pos = used/2 - 1; pos >= 0; pos--) {
 		char ch = buffer[pos];
 		buffer[pos] = buffer[used-pos-1];
@@ -215,15 +230,16 @@
 }
 
 public synchronized void setCharAt(int index, char ch)
-	{
+{
 	checkIndex(index);
-	buffer[index]=ch;
+	buffer[index] = ch;
 }
 
-public synchronized void setLength(int newLength) {
-	if (newLength < 0) {
-		throw new StringIndexOutOfBoundsException();
-	}
+public synchronized void setLength(int newLength)
+{
+	if (newLength < 0)
+		throw new StringIndexOutOfBoundsException(newLength);
+
 	if (newLength > used) {
 		/* buffer expands */
 		if (newLength > buffer.length) {
@@ -235,7 +251,7 @@
 		else {
 			/* Pad buffer */
 			for (int pos = used; pos < newLength; pos++) {
-				buffer[pos]='\u0000';
+				buffer[pos] = '\u0000';
 			}
 		}
 	}
diff -urN kaffe/libraries/javalib/java/lang/System.java kaffe-patched/libraries/javalib/java/lang/System.java
--- kaffe/libraries/javalib/java/lang/System.java	Wed Feb 10 22:34:46 1999
+++ kaffe-patched/libraries/javalib/java/lang/System.java	Mon Feb 22 11:57:17 1999
@@ -21,9 +21,9 @@
 import java.util.SimpleTimeZone;
 import java.util.Properties;
 
-final public class System {
+public final class System {
 
-final static SecurityManager defaultSecurityManager = new NullSecurityManager();
+static final SecurityManager defaultSecurityManager = new NullSecurityManager();
 
 public static InputStream in;
 public static PrintStream out;
@@ -45,16 +45,18 @@
 	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);
-        // in = new BufferedInputStream(new kaffe.io.StdInputStream(), 128);
-        // out = new PrintStream(new BufferedOutputStream(new kaffe.io.StdOutputStream(), 128), true);
-        // err = new PrintStream(new BufferedOutputStream(new kaffe.io.StdErrorStream(), 128), true);	
+	// in = new BufferedInputStream(new kaffe.io.StdInputStream(), 128);
+	// out = new PrintStream(new BufferedOutputStream(new kaffe.io.StdOutputStream(), 128), true);
+	// err = new PrintStream(new BufferedOutputStream(new kaffe.io.StdErrorStream(), 128), true);
 }
 
+private System() { }
+
 private static void checkPropertyAccess() {
 	getSecurityManager().checkPropertiesAccess();
 }
 
-public static void exit (int status) {
+public static void exit(int status) {
 	Runtime.getRuntime().exit(status);
 }
 
@@ -69,7 +71,9 @@
 }
 
 public static String getProperty(String key) {
-	return getProperty(key, null);
+	checkPropertyAccess();
+
+	return props.getProperty(key);
 }
 
 public static String getProperty(String key, String def) {
@@ -114,10 +118,10 @@
 	System.out = out;
 }
 
-public static void setProperties(Properties prps) {
+public static void setProperties(Properties props) {
 	checkPropertyAccess();
 
-	props = prps;
+	System.props = props;
 }
 
 public static void setSecurityManager(SecurityManager s) {
@@ -129,9 +133,9 @@
 	}
 }
 
-native public static long currentTimeMillis();
-native public static void arraycopy(Object src, int src_position, Object dst, int dst_position, int length);
-native public static int identityHashCode(Object x);
-native private static Properties initProperties(Properties props);
+public static native long currentTimeMillis();
+public static native void arraycopy(Object src, int src_position, Object dst, int dst_position, int length);
+public static native int identityHashCode(Object x);
+private static native Properties initProperties(Properties props);
 
 }
diff -urN kaffe/libraries/javalib/java/lang/Thread.java kaffe-patched/libraries/javalib/java/lang/Thread.java
--- kaffe/libraries/javalib/java/lang/Thread.java	Sun Dec 13 01:32:30 1998
+++ kaffe-patched/libraries/javalib/java/lang/Thread.java	Mon Feb 22 11:57:17 1999
@@ -14,12 +14,12 @@
 import java.util.Hashtable;
 import java.lang.Throwable;
 
-public class Thread
-  implements Runnable {
+public class Thread implements Runnable
+{
+	public static final int MIN_PRIORITY = 1;
+	public static final int NORM_PRIORITY = 5;
+	public static final int MAX_PRIORITY = 10;
 
-	final public static int MIN_PRIORITY = 1;
-	final public static int NORM_PRIORITY = 5;
-	final public static int MAX_PRIORITY = 10;
 	private static int threadCount;
 	private char[] name;
 	private int priority;
@@ -89,12 +89,7 @@
 
 	int tprio = parent.getPriority();
 	int gprio = this.group.getMaxPriority();
-	if (tprio < gprio) {
-		setPriority0(tprio);
-	}
-	else {
-		setPriority0(gprio);
-	}
+	setPriority0(tprio < gprio ? tprio : gprio);
 
 	setDaemon(parent.isDaemon());
 }
@@ -111,9 +106,9 @@
 	System.getSecurityManager().checkAccess(this);
 }
 
-native public int countStackFrames();
+public native int countStackFrames();
 
-native public static Thread currentThread();
+public static native Thread currentThread();
 
 /**
  * Kill a thread immediately and don't try any kind of cleanup except removing it
@@ -126,18 +121,17 @@
 	destroy0();
 }
 
-native private void destroy0();
+private native void destroy0();
 
 public static void dumpStack() {
-	Throwable t = new Throwable();
-	t.printStackTrace();
+	new Throwable().printStackTrace();
 }
 
 public static int enumerate(Thread tarray[]) {
 	return (Thread.currentThread().getThreadGroup().enumerate(tarray));
 }
 
-final native private void finalize0();
+private final native void finalize0();
 
 private Object finalizeHelper = new Object() {
     protected void finalize() throws Throwable {
@@ -155,19 +149,19 @@
 }
 
 private static String generateName() {
-	return new String("Thread-"+threadCount++);
+	return new String("Thread-" + threadCount++);
 }
 
-final public String getName() {
-	return (new String(name));
+public final String getName() {
+	return new String(name);
 }
 
-final public int getPriority() {
+public final int getPriority() {
 	return priority;
 }
 
-final public ThreadGroup getThreadGroup() {
-	return (group);
+public final ThreadGroup getThreadGroup() {
+	return group;
 }
 
 /*
@@ -182,11 +176,12 @@
 }
 
 public void interrupt() {
+	checkAccess();
 	interrupting = true;
 	interrupt0();
 }
 
-native private void interrupt0();
+private native void interrupt0();
 
 public static boolean interrupted() {
 	boolean i = Thread.currentThread().interrupting;
@@ -194,9 +189,9 @@
 	return (i);
 }
 
-final native public boolean isAlive();
+public final native boolean isAlive();
 
-final public boolean isDaemon() {
+public final boolean isDaemon() {
 	return daemon;
 }
 
@@ -204,26 +199,26 @@
 	return (interrupting);
 }
 
-final public void join() throws InterruptedException
+public final void join() throws InterruptedException
 {
 	join(0);
 }
 
-final public synchronized void join(long millis) throws InterruptedException
+public final /* synchronized */ void join(long millis) throws InterruptedException
 {
 	join(millis, 0);
 }
 
-final public synchronized void join(long millis, int nanos) throws InterruptedException
+public final synchronized void join(long millis, int nanos) throws InterruptedException
 {
 	/* Wait while time remains and alive */
-	if ((millis==0) && (nanos==0)) {
+	if ((millis == 0) && (nanos == 0)) {
 		while (isAlive()) wait(0);
 	}
 	else {
 		long start = System.currentTimeMillis();
-		while (isAlive() && (System.currentTimeMillis()<millis+start)) {
-			long toWait = millis+start-System.currentTimeMillis();
+		while (isAlive() && (System.currentTimeMillis() < millis+start)) {
+			long toWait = millis + start - System.currentTimeMillis();
 			wait(toWait);
 		}
 	}
@@ -232,7 +227,9 @@
 /**
  * @deprecated
  */
-final public void resume() {
+public final void resume() {
+	checkAccess();
+
 	if (suspendResume != null) {
 		synchronized (suspendResume) {
 			suspendResume.notifyAll();
@@ -246,15 +243,17 @@
 	}
 }
 
-final public void setDaemon(boolean on) {
+public final void setDaemon(boolean on) {
+	checkAccess();
 	daemon = on;
 }
 
-final public void setName(String name) {
+public final void setName(String name) {
+	checkAccess();
 	this.name = name.toCharArray();
 }
 
-final public void setPriority(int newPriority) {
+public final void setPriority(int newPriority) {
 	checkAccess();
 
 	if (newPriority < MIN_PRIORITY || newPriority > group.getMaxPriority()) {
@@ -263,7 +262,7 @@
 	setPriority0(newPriority);
 }
 
-native private void setPriority0(int prio);
+private native void setPriority0(int prio);
 
 public static void sleep(long millis) throws InterruptedException
 {
@@ -281,30 +280,33 @@
 	sleep(millis);
 }
 
-native private static void sleep0(long millis);
+private static native void sleep0(long millis);
 
-native public synchronized void start();
+public synchronized native void start();
 
 /**
  * @deprecated
  */
-final public void stop() {
+public final void stop() {
 	stop(new ThreadDeath());
 }
 
 /**
  * @deprecated
  */
-final public synchronized void stop(Throwable o) {
+public final synchronized void stop(Throwable o) {
+	checkAccess();
 	stop0(o);
 }
 
-native private void stop0(Object o);
+private native void stop0(Object o);
 
 /**
  * @deprecated
  */
-final public void suspend() {
+public final void suspend() {
+	checkAccess();
+
 	if (suspendResume == null) {
 		suspendResume = new Object();
 	}
@@ -321,5 +323,5 @@
 	return getName();
 }
 
-native public static void yield();
+public static native void yield();
 }
diff -urN kaffe/libraries/javalib/java/lang/ThreadGroup.java kaffe-patched/libraries/javalib/java/lang/ThreadGroup.java
--- kaffe/libraries/javalib/java/lang/ThreadGroup.java	Fri Dec 11 08:40:39 1998
+++ kaffe-patched/libraries/javalib/java/lang/ThreadGroup.java	Mon Feb 22 11:57:17 1999
@@ -25,7 +25,7 @@
 	private ThreadGroup[] groups = new ThreadGroup[0];
 
 public ThreadGroup() {
-	this(Thread.currentThread().getThreadGroup(), "main");
+	this (Thread.currentThread().getThreadGroup(), "main");
 }
 
 public ThreadGroup(String name) {
@@ -43,9 +43,10 @@
 
 public synchronized int activeCount() {
 	int result = nthreads;
+
 	for (int i = 0; i < groups.length; i++) {
 		if (groups[i] != null) {
-			result = result + groups[i].activeCount();
+			result += groups[i].activeCount();
 		}
 	}
 
@@ -53,12 +54,11 @@
 }
 
 public synchronized int activeGroupCount() {
-	int i;
 	int result = ngroups;
 
-	for (i = 0; i < groups.length; i++) {
+	for (int i = 0; i < groups.length; i++) {
 		if (groups[i] != null) {
-			result = result + groups[i].activeGroupCount();
+			result += groups[i].activeGroupCount();
 		}
 	}
 
@@ -66,15 +66,13 @@
 }
 
 public synchronized void add(Thread thread) {
-	int i;
-
 	nthreads++;
 
 	if (threads == null) {
 		threads = new Thread[1];
 	}
 
-	for (i = 0; i < threads.length; i++) {
+	for (int i = 0; i < threads.length; i++) {
 		if (threads[i] == null) {
 			threads[i] = thread;
 			return;
@@ -107,7 +105,7 @@
 	return (false);
 }
 
-final public void checkAccess() {
+public final void checkAccess() {
 	System.getSecurityManager().checkAccess(this);
 }
 
@@ -115,14 +113,13 @@
 
 	for (int i = 0; i < srcArray.length; i++) {
 		if (srcArray[i] != null && destIndex < destArray.length) {
-			destArray[destIndex] = srcArray[i];
-			destIndex++;
+			destArray[destIndex++] = srcArray[i];
 		}
 	}
 	return (destIndex);
 }
 
-final public synchronized void destroy() {
+public final synchronized void destroy() {
 	checkAccess();
 
 	if (destroyed || activeCount() > 0) {
@@ -191,24 +188,24 @@
 	return pos;
 }
 
-final public int getMaxPriority() {
+public final int getMaxPriority() {
 	return maxPriority;
 }
 
-final public String getName() {
+public final String getName() {
 	return name;
 }
 
-final public ThreadGroup getParent() {
+public final ThreadGroup getParent() {
 	return parent;
 }
 
-final public boolean isDaemon() {
-	return this.daemon;
+public final boolean isDaemon() {
+	return daemon;
 }
 
 public synchronized boolean isDestroyed() {
-	return (destroyed);
+	return destroyed;
 }
 
 public synchronized void list() {
@@ -217,12 +214,12 @@
 
 private void list(int tabulation) {
 	printLine(this.toString(), tabulation);
-	printThreads(tabulation+1);
-	printGroups(tabulation+1);
+	printThreads(tabulation + 1);
+	printGroups(tabulation + 1);
 }
 
-final public boolean parentOf(ThreadGroup g) {
-	return ((parent == g) || (parentOf(g.getParent())));
+public final boolean parentOf(ThreadGroup g) {
+	return ((parent == g) || parentOf(g.getParent()));
 }
 
 private void printGroups(int tabulation) {
@@ -233,7 +230,7 @@
 }
 
 private void printLine(String str, int tabulation) {
-	for (int tabs=0; tabs<tabulation; tabs++) {
+	for (int tabs = 0; tabs<tabulation; tabs++) {
 		System.out.print("    ");
 	}
 
@@ -248,9 +245,7 @@
 }
 
 public synchronized void remove(Thread thread) {
-	int i;
-
-	for (i = 0; i < threads.length; i++) {
+	for (int i = 0; i < threads.length; i++) {
 		if (threads[i] == thread) {
 			threads[i] = null;
 			nthreads--;
@@ -260,9 +255,7 @@
 }
 
 public synchronized void remove(ThreadGroup group) {
-	int i;
-
-	for (i = 0; i < groups.length; i++) {
+	for (int i = 0; i < groups.length; i++) {
 		if (groups[i] == group) {
 			groups[i] = null;
 			ngroups--;
@@ -274,7 +267,9 @@
 /**
  * @deprecated
  */
-final public synchronized void resume() {
+public final synchronized void resume() {
+	checkAccess();
+
 	for (int i = 0; i < threads.length; i++) {
 		if (threads[i] != null) {
 			threads[i].resume();
@@ -287,13 +282,13 @@
 	}
 }
 
-final public void setDaemon(boolean d) {
+public final void setDaemon(boolean d) {
 	checkAccess();
 
 	daemon = d;
 }
 
-final public synchronized void setMaxPriority(int pri) {
+public final /* synchronized */ void setMaxPriority(int pri) {
 	checkAccess();
 
 	maxPriority = pri;
@@ -302,7 +297,9 @@
 /**
  * @deprecated
  */
-final public synchronized void stop() {
+public final synchronized void stop() {
+	checkAccess();
+
 	for (int i = 0; i < threads.length; i++) {
 		if (threads[i] != null) {
 			threads[i].stop();
@@ -318,7 +315,9 @@
 /**
  * @deprecated
  */
-final public synchronized void suspend() {
+public final synchronized void suspend() {
+	checkAccess();
+
 	for (int i = 0; i < threads.length; i++) {
 		if (threads[i] != null) {
 			threads[i].suspend();
@@ -332,7 +331,7 @@
 }
 
 public String toString() {
-	return "java.lang.ThreadGroup[name="+name+",maxpri="+maxPriority+"]";
+	return "java.lang.ThreadGroup[name=" + name + ",maxpri=" + maxPriority + "]";
 }
 
 public void uncaughtException(Thread t, Throwable e) {
diff -urN kaffe/libraries/javalib/java/lang/Throwable.java kaffe-patched/libraries/javalib/java/lang/Throwable.java
--- kaffe/libraries/javalib/java/lang/Throwable.java	Tue Oct 20 04:59:19 1998
+++ kaffe-patched/libraries/javalib/java/lang/Throwable.java	Mon Feb 22 11:57:17 1999
@@ -14,7 +14,7 @@
 import java.io.PrintWriter;
 import java.io.Serializable;
 
-public class Throwable extends Object implements Serializable
+public class Throwable implements Serializable
 {
 	/*
 	 * NB: this is a place where native code stores private
@@ -25,56 +25,58 @@
 	private transient Object backtrace = null;
 	private String message = null;
 
+	/* This is what Sun's JDK1.1 "serialver java.lang.Throwable" spits out */
+	private static final long serialVersionUID = -3042686055658047285L;
+
 public Throwable()
-	{
-	message = null;
+{
 	fillInStackTrace();
 }
 
 public Throwable(String mess)
-	{
+{
 	message = mess;
 	fillInStackTrace();
 }
 
-native public Throwable fillInStackTrace();
+public native Throwable fillInStackTrace();
 
 public String getLocalizedMessage()
-	{
-	return (getMessage());
+{
+	return getMessage();
 }
 
 public String getMessage()
-	{
-	return (message);
+{
+	return message;
 }
 
 public void printStackTrace()
-	{
+{
 	printStackTrace(System.err);
 }
 
 public void printStackTrace(PrintStream s)
-	{
-	s.println(this.toString());
+{
+	s.println(this);
 	printStackTrace0(s);
 }
 
 public void printStackTrace(PrintWriter s)
-	{
-	s.println(this.toString());
+{
+	s.println(this);
 	printStackTrace0(s);
 }
 
-native private void printStackTrace0(Object s);
+private native void printStackTrace0(Object s);
 
 public String toString()
-	{
+{
 	if (message != null) {
-		return (this.getClass().getName() + ": " + message);
+		return getClass().getName() + ": " + message;
 	}
 	else {
-		return (this.getClass().getName());
+		return getClass().getName();
 	}
 }
 }
diff -urN kaffe/libraries/javalib/java/lang/Void.java kaffe-patched/libraries/javalib/java/lang/Void.java
--- kaffe/libraries/javalib/java/lang/Void.java	Tue Jul 14 16:20:03 1998
+++ kaffe-patched/libraries/javalib/java/lang/Void.java	Mon Feb 22 11:57:17 1999
@@ -14,4 +14,6 @@
 
   public static final Class TYPE = Class.getPrimitiveClass("void");
 
-};
+private Void() { }
+
+}


More information about the kaffe mailing list