patch for java.lang

Aaron Place beavis at ihug.co.nz
Tue Mar 2 19:01:25 PST 1999


This is a patch to make the current classes in java.lang conform to the
1.2 spec (or 1.1 where appropriate).

Most of the changes are making public methods and classes to be private
or default access (local to the package).


* libraries/javalib/java/lang: Class, ClassLoader, Long,
NullSecurityManager, ProcessInputStream, Runtime,  SecurityManager,
String, ThreadGroup: changed various methods and classes to be
non-public, non-final etc

* libraries/javalib/java/lang/reflect: Array, Compiler,
Constructor.java, Field.java, Method.java, Package: provide  private
constructor and make final

* libraries/javalib/java/lang/reflect/InvocationTargetException.java:
changed public InvocationTargetException() to protected, changed
InvocationTargetException(String) to
InvocationTargetException(Throwable,String)  

* libraries/javalib/kaffe/net/www/protocol/system/
SystemURLConnection.java: changed to use
ClassLoader.getSystemResourceAsStream as getSystemResourceAsBytes0 is no
longer public


The only thing which i didn't change is the public interface
MemoryAdvice in Runtime.java because i am not sure how it interacts with
kaffe.lang.MemoryAdvice.

Aaron.
-------------- next part --------------
diff -urN kaffe/libraries/javalib/java/lang/Class.java kaffe-new/libraries/javalib/java/lang/Class.java
--- kaffe/libraries/javalib/java/lang/Class.java	Wed Feb 24 23:24:10 1999
+++ kaffe-new/libraries/javalib/java/lang/Class.java	Tue Mar  2 15:15:10 1999
@@ -166,7 +166,7 @@
 
 native public String getName();
 
-native public static Class getPrimitiveClass(String name);
+native static Class getPrimitiveClass(String name);
 
 /**
  * Finds a resource with the specified name.  
diff -urN kaffe/libraries/javalib/java/lang/ClassLoader.java kaffe-new/libraries/javalib/java/lang/ClassLoader.java
--- kaffe/libraries/javalib/java/lang/ClassLoader.java	Wed Feb 24 23:24:11 1999
+++ kaffe-new/libraries/javalib/java/lang/ClassLoader.java	Tue Mar  2 22:03:45 1999
@@ -109,7 +109,7 @@
 	return (cls);
 }
 
-protected void checkPackageAccess(String name) throws SecurityException {
+void checkPackageAccess(String name) throws SecurityException {
 }
 
 protected Class findLocalClass(String name) throws ClassNotFoundException {
@@ -124,7 +124,7 @@
 	// Signer's are not currently supported.
 }
 
-public ClassLoader getParent() {
+public final ClassLoader getParent() {
 	return (parent);
 }
 
@@ -133,19 +133,19 @@
 }
 
 
-public Enumeration getLocalResources(String name) throws IOException {
+Enumeration getLocalResources(String name) throws IOException {
 	return (null);
 }
 
-public URL getLocalResource(String name) {
+URL getLocalResource(String name) {
 	return (null);
 }
 
-public Enumeration getSystemResources(String name) throws IOException {
+public static Enumeration getSystemResources(String name) throws IOException {
 	throw new kaffe.util.NotImplemented();
 }
 
-public static ClassLoader getBaseClassLoader() {
+static ClassLoader getBaseClassLoader() {
 	return (null);
 }
 
@@ -165,10 +165,8 @@
 native private Class findSystemClass0(String name);
 native private Class findLoadedClass0(String name);
 native private void resolveClass0(Class cls);
-/**
- *  This is not part of the public interface.
- */
-native public static byte[] getSystemResourceAsBytes0(String name);
+
+native static byte[] getSystemResourceAsBytes0(String name);
 
 final native private void finalize0();
 
diff -urN kaffe/libraries/javalib/java/lang/Compiler.java kaffe-new/libraries/javalib/java/lang/Compiler.java
--- kaffe/libraries/javalib/java/lang/Compiler.java	Tue Dec  8 15:05:07 1998
+++ kaffe-new/libraries/javalib/java/lang/Compiler.java	Mon Mar  1 11:18:54 1999
@@ -12,6 +12,9 @@
 
 public final class Compiler {
 
+private Compiler() {
+}
+    
 public static boolean compileClass(Class aClass) {
 	return (false);
 }
diff -urN kaffe/libraries/javalib/java/lang/Long.java kaffe-new/libraries/javalib/java/lang/Long.java
--- kaffe/libraries/javalib/java/lang/Long.java	Wed Feb 24 23:24:11 1999
+++ kaffe-new/libraries/javalib/java/lang/Long.java	Tue Mar  2 15:00:41 1999
@@ -111,7 +111,7 @@
 	return parseLong(s, 10);
 }
 
-public static long parseLong(String s, int radix) {
+public static long parseLong(String s, int radix) throws NumberFormatException {
 	if (s.length()<=0) throw new NumberFormatException();
 
 	/* Check for negativity */
diff -urN kaffe/libraries/javalib/java/lang/NullSecurityManager.java kaffe-new/libraries/javalib/java/lang/NullSecurityManager.java
--- kaffe/libraries/javalib/java/lang/NullSecurityManager.java	Tue Dec  8 15:05:07 1998
+++ kaffe-new/libraries/javalib/java/lang/NullSecurityManager.java	Tue Mar  2 15:08:10 1999
@@ -16,7 +16,7 @@
 import java.lang.SecurityManager;
 import java.net.InetAddress;
 
-public class NullSecurityManager 
+class NullSecurityManager 
   extends SecurityManager {
 
 NullSecurityManager() {
@@ -82,8 +82,8 @@
 public void checkPropertyAccess(String key) {
 }
 
-public void checkPropertyAccess(String key, String def) {
-}
+/* public void checkPropertyAccess(String key, String def) {
+}*/
 
 public void checkRead(FileDescriptor fd) {
 }
diff -urN kaffe/libraries/javalib/java/lang/Package.java kaffe-new/libraries/javalib/java/lang/Package.java
--- kaffe/libraries/javalib/java/lang/Package.java	Tue Dec  8 15:05:08 1998
+++ kaffe-new/libraries/javalib/java/lang/Package.java	Mon Mar  1 11:22:09 1999
@@ -13,4 +13,8 @@
 // NOT IMPLEMENTED
 
 public class Package {
+
+    private Package() {
+    }
+    
 }
diff -urN kaffe/libraries/javalib/java/lang/ProcessInputStream.java kaffe-new/libraries/javalib/java/lang/ProcessInputStream.java
--- kaffe/libraries/javalib/java/lang/ProcessInputStream.java	Wed Aug 26 09:01:45 1998
+++ kaffe-new/libraries/javalib/java/lang/ProcessInputStream.java	Mon Mar  1 11:22:19 1999
@@ -16,7 +16,7 @@
  * See the file "license.terms" for information on usage and redistribution
  * of this file.
  */
-public class ProcessInputStream
+class ProcessInputStream
   extends FilterInputStream
   implements DataInput
 {
diff -urN kaffe/libraries/javalib/java/lang/Runtime.java kaffe-new/libraries/javalib/java/lang/Runtime.java
--- kaffe/libraries/javalib/java/lang/Runtime.java	Wed Feb 24 23:24:11 1999
+++ kaffe-new/libraries/javalib/java/lang/Runtime.java	Tue Mar  2 22:04:06 1999
@@ -17,7 +17,9 @@
 
 public class Runtime
 {
-
+/**
+ *  This is not part of the public interface.
+ */
 public static interface MemoryAdvice {
 
 // These should match those in kaffe.lang.MemoryAdvice
@@ -144,11 +146,11 @@
 	// otherwise we don't have external libraries at all
 }
 
-public int getMemoryAdvice() {
+int getMemoryAdvice() {
 	return (advice.getColor());
 }
 
-public int waitForMemoryAdvice(int level) throws InterruptedException {
+int waitForMemoryAdvice(int level) throws InterruptedException {
 	return (advice.waitForOtherColor(level));
 }
 
diff -urN kaffe/libraries/javalib/java/lang/SecurityManager.java kaffe-new/libraries/javalib/java/lang/SecurityManager.java
--- kaffe/libraries/javalib/java/lang/SecurityManager.java	Wed Feb 24 23:24:11 1999
+++ kaffe-new/libraries/javalib/java/lang/SecurityManager.java	Wed Mar  3 13:02:19 1999
@@ -100,7 +100,7 @@
 	throw new SecurityException();
 }
 
-public void checkPropertyAccess(String key, String def) {
+void checkPropertyAccess(String key, String def) {
 	throw new SecurityException();
 }
 
diff -urN kaffe/libraries/javalib/java/lang/String.java kaffe-new/libraries/javalib/java/lang/String.java
--- kaffe/libraries/javalib/java/lang/String.java	Wed Feb 24 23:24:11 1999
+++ kaffe-new/libraries/javalib/java/lang/String.java	Mon Mar  1 12:17:08 1999
@@ -503,10 +503,10 @@
 	return Long.toString(l);
 }
 
-final public String intern() {
+public String intern() {
 	return interned ? this : intern0(this);
 }
 
-final native static public synchronized String intern0(String str);
+private native static synchronized String intern0(String str);
 
 }
diff -urN kaffe/libraries/javalib/java/lang/ThreadGroup.java kaffe-new/libraries/javalib/java/lang/ThreadGroup.java
--- kaffe/libraries/javalib/java/lang/ThreadGroup.java	Wed Feb 24 23:24:11 1999
+++ kaffe-new/libraries/javalib/java/lang/ThreadGroup.java	Wed Mar  3 14:00:25 1999
@@ -24,7 +24,7 @@
 	private int ngroups = 0;
 	private ThreadGroup[] groups = new ThreadGroup[0];
 
-public ThreadGroup() {
+private ThreadGroup() {
 	this(Thread.currentThread().getThreadGroup(), "main");
 }
 
@@ -65,7 +65,7 @@
 	return result;
 }
 
-public synchronized void add(Thread thread) {
+synchronized void add(Thread thread) {
 	int i;
 
 	nthreads++;
@@ -88,7 +88,7 @@
 	threads[threads.length - 1] = thread;
 }
 
-public synchronized void add(ThreadGroup group) {
+synchronized void add(ThreadGroup group) {
 	ngroups++;
 
 	for (int i = 0; i < groups.length; i++) {
@@ -176,7 +176,7 @@
 	return enumerate(list, recurse, 0);
 }
 
-public int enumerate(Thread list[], boolean recurse, int pos) {
+private int enumerate(Thread list[], boolean recurse, int pos) {
 
 	/* First do the local threads */
 	pos = copyArray(threads, list, pos);
@@ -247,7 +247,7 @@
 	}
 }
 
-public synchronized void remove(Thread thread) {
+synchronized void remove(Thread thread) {
 	int i;
 
 	for (i = 0; i < threads.length; i++) {
@@ -259,7 +259,7 @@
 	}
 }
 
-public synchronized void remove(ThreadGroup group) {
+synchronized void remove(ThreadGroup group) {
 	int i;
 
 	for (i = 0; i < groups.length; i++) {
diff -urN kaffe/libraries/javalib/java/lang/reflect/Array.java kaffe-new/libraries/javalib/java/lang/reflect/Array.java
--- kaffe/libraries/javalib/java/lang/reflect/Array.java	Wed Jul 15 05:02:06 1998
+++ kaffe-new/libraries/javalib/java/lang/reflect/Array.java	Mon Mar  1 11:26:48 1999
@@ -10,8 +10,11 @@
  * See the file "license.terms" for information on usage and redistribution
  * of this file.
  */
-public class Array
+public final class Array
 {
+private Array() {
+}
+    
 native public static Object get(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException;
 
 native public static boolean getBoolean(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException;
diff -urN kaffe/libraries/javalib/java/lang/reflect/Constructor.java kaffe-new/libraries/javalib/java/lang/reflect/Constructor.java
--- kaffe/libraries/javalib/java/lang/reflect/Constructor.java	Sun Feb 14 16:04:53 1999
+++ kaffe-new/libraries/javalib/java/lang/reflect/Constructor.java	Mon Mar  1 11:27:32 1999
@@ -13,7 +13,7 @@
 import java.lang.Class;
 import java.lang.String;
 
-public class Constructor
+public final class Constructor
   implements Member
 {
 	private Class clazz;
@@ -21,6 +21,9 @@
 	private Class[] parameterTypes;
 	private Class[] exceptionTypes;
 
+private Constructor() {
+}
+    
 public boolean equals(Object obj)
 	{
 	// Catch the simple case where they're really the same
diff -urN kaffe/libraries/javalib/java/lang/reflect/Field.java kaffe-new/libraries/javalib/java/lang/reflect/Field.java
--- kaffe/libraries/javalib/java/lang/reflect/Field.java	Thu Dec 10 12:20:20 1998
+++ kaffe-new/libraries/javalib/java/lang/reflect/Field.java	Wed Mar  3 13:07:51 1999
@@ -13,7 +13,7 @@
 import java.lang.String;
 import java.lang.Class;
 
-public class Field
+public final class Field
   implements Member
 {
 	private Class clazz;
@@ -21,6 +21,9 @@
 	private String name;
 	private Class type;
 
+private Field() {
+}
+    
 public boolean equals(Object obj)
 	{
 	// Quick test for identity
diff -urN kaffe/libraries/javalib/java/lang/reflect/InvocationTargetException.java kaffe-new/libraries/javalib/java/lang/reflect/InvocationTargetException.java
--- kaffe/libraries/javalib/java/lang/reflect/InvocationTargetException.java	Wed Jul 15 05:02:06 1998
+++ kaffe-new/libraries/javalib/java/lang/reflect/InvocationTargetException.java	Mon Mar  1 11:36:54 1999
@@ -15,14 +15,14 @@
 {
 	private Throwable thrown;
 
-public InvocationTargetException () {
+protected InvocationTargetException () {
 	super();
 	thrown = null;
 }
 
-public InvocationTargetException (String s) {
+public InvocationTargetException (Throwable t,String s) {
 	super(s);
-	thrown = null;
+	thrown = t;
 }
 
 public InvocationTargetException (Throwable t) {
diff -urN kaffe/libraries/javalib/java/lang/reflect/Method.java kaffe-new/libraries/javalib/java/lang/reflect/Method.java
--- kaffe/libraries/javalib/java/lang/reflect/Method.java	Sun Feb 14 16:04:53 1999
+++ kaffe-new/libraries/javalib/java/lang/reflect/Method.java	Wed Mar  3 13:11:31 1999
@@ -13,7 +13,7 @@
 import java.lang.Class;
 import java.lang.String;
 
-public class Method
+public final class Method
   implements Member
 {
 	private Class clazz;
@@ -23,6 +23,9 @@
 	private Class[] parameterTypes;
 	private Class[] exceptionTypes;
 
+private Method() {
+}
+    
 public boolean equals(Object obj)
 	{
 	// Catch the simple case where they're really the same
diff -urN kaffe/libraries/javalib/kaffe/net/www/protocol/system/SystemURLConnection.java kaffe-new/libraries/javalib/kaffe/net/www/protocol/system/SystemURLConnection.java
--- kaffe/libraries/javalib/kaffe/net/www/protocol/system/SystemURLConnection.java	Thu Feb 11 11:52:38 1999
+++ kaffe-new/libraries/javalib/kaffe/net/www/protocol/system/SystemURLConnection.java	Tue Mar  2 20:46:37 1999
@@ -23,8 +23,9 @@
 
 public class SystemURLConnection extends BasicURLConnection {
 
-private byte[] data;
-
+/*private byte[] data;*/
+private InputStream data;
+    
 public SystemURLConnection(URL url)
 {
 	super(url);
@@ -33,7 +34,8 @@
 public void connect() throws IOException
 {
 	String filename = url.getFile();
-	data = ClassLoader.getSystemResourceAsBytes0(filename);
+	/*data = ClassLoader.getSystemResourceAsBytes0(filename);*/
+	data = ClassLoader.getSystemResourceAsStream(filename);
 	setContentTypeFromName();
 }
 
@@ -43,7 +45,8 @@
 		return (null);
 	}
 	else {
-		return (new ByteArrayInputStream(data));
+	        /*return (new ByteArrayInputStream(data));*/
+	        return data;
 	}
 }
 


More information about the kaffe mailing list