harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arc...@apache.org
Subject svn commit: r411596 [1/4] - in /incubator/harmony/enhanced/classlibadapter/trunk: ./ modules/kernel/src/main/java/gnu/classpath/ modules/kernel/src/main/java/java/lang/ modules/kernel/src/main/java/java/lang/ref/ modules/kernel/src/main/java/java/lang/...
Date Sun, 04 Jun 2006 20:55:04 GMT
Author: archie
Date: Sun Jun  4 13:55:02 2006
New Revision: 411596

URL: http://svn.apache.org/viewvc?rev=411596&view=rev
Log:
Applied these patches from HARMONY-483:
    patch -p1 < /home/archie/classlibadapter-update-20060522.diff
    patch -p1 < /home/archie/classlibadapter-incremental-update-20060522-20060528.diff
    patch -p1 < /home/archie/classlibadapter-incremental-update-20060528-20060528v2.diff
    patch -p1 < /home/archie/classlibadapter-incremental-update-20060528v2-20060528v3.diff
    patch -p1 < /home/archie/classlibadapter-incremental-update-20060528v3-20060528v4.diff
    patch -p1 < /home/archie/classlibadapter-incremental-update-20060528v4-20060528v4.diff
    patch -p1 < /home/archie/classlibadapter-incremental-update-20060528v4-20060529.diff
    patch -p1 < /home/archie/classlibadapter-incremental-update-20060529-20060529v2.diff
    patch -p1 < /home/archie/classlibadapter-incremental-update-20060529v2-20060529v3.diff
    patch -p1 < /home/archie/classlibadapter-incremental-update-20060529v3-20060601.diff

Added:
    incubator/harmony/enhanced/classlibadapter/trunk/build.sh
    incubator/harmony/enhanced/classlibadapter/trunk/jc_run.sh
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/VMSystemProperties.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/BootstrapClassLoader.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/SystemClassLoader.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/reflect/AccessibleObject.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/reflect/Array.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/org/
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/org/apache/
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/org/apache/harmony/
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/org/apache/harmony/kernel/
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/org/apache/harmony/kernel/vm/
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/org/apache/harmony/kernel/vm/VM.java
    incubator/harmony/enhanced/classlibadapter/trunk/vmi/
    incubator/harmony/enhanced/classlibadapter/trunk/vmi/java_lang_reflect_Array.cpp
    incubator/harmony/enhanced/classlibadapter/trunk/vmi/libvmi.exp
    incubator/harmony/enhanced/classlibadapter/trunk/vmi/vmi.cpp
Removed:
    incubator/harmony/enhanced/classlibadapter/trunk/modules/luni/src/main/java/java/io/FileDescriptor.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/nio/src/main/java/com/ibm/platform/OSFileSystem.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/nio/src/main/java/com/ibm/platform/OSMemory.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/nio/src/main/java/java/nio/ByteBuffer.java
    incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/com_ibm_platform_OSFileSystem.h
    incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/doit.sh
    incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/emptystub.c
    incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/file.c
    incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/fileos.c
    incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/helpers.c
    incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/iohelp.c
    incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/java_io_File.h
Modified:
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/VMStackWalker.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Class.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/ClassLoader.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Object.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Package.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Runtime.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/StackTraceElement.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/String.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/System.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Thread.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/ThreadGroup.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Throwable.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/VMRuntime.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/VMSystem.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/VMThread.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/VMThrowable.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/ref/Reference.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/reflect/Constructor.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/reflect/Field.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/reflect/Method.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/nio/DirectByteBufferImpl.java
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/security/AccessController.java

Added: incubator/harmony/enhanced/classlibadapter/trunk/build.sh
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlibadapter/trunk/build.sh?rev=411596&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/build.sh (added)
+++ incubator/harmony/enhanced/classlibadapter/trunk/build.sh Sun Jun  4 13:55:02 2006
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+DIR=$PWD
+BASEDIR=$(dirname $PWD)
+PATH=$JAVA_HOME/bin:$PATH
+
+die() {
+   echo "$@"
+   exit
+}
+
+check_classlib() {
+	somefile=$(ls $1/make/build-java.xml 2>/dev/null)
+	[ -f "$somefile" ] || return 1
+	export CLASSLIB_HOME=$(dirname "$(dirname "$somefile")")
+}
+
+detect_classlib() {
+        check_classlib $CLASSLIB_HOME && return
+	echo "No valid CLASSLIB_HOME set, trying to guess..."
+        check_classlib $BASEDIR/CLASSLIB && return
+	check_classlib $BASEDIR/classlib && return
+	check_classlib $BASEDIR/'*' && return
+	die "No CLASSLIB_HOME detected"
+}
+
+detect_classlib
+echo Using CLASSLIB_HOME = $CLASSLIB_HOME
+
+
+KERNEL=$DIR/modules/kernel/src/main/java
+LUNI=$DIR/modules/luni/src/main/java
+NIO=$DIR/modules/nio/src/main/java
+
+BOOT=$CLASSLIB_HOME/deploy/jdk/jre/lib/boot
+CP=$BOOT/nio.jar:$BOOT/luni.jar:$BOOT/annotation.jar:$KERNEL
+JAVAC="java -jar $CLASSLIB_HOME/depends/jars/ecj_3.2RC5/ecj_3.2RC5.jar -source 1.5 -target jsr14"
+
+(cd $KERNEL; $JAVAC -classpath $CP $(find . -name *.java)) || die
+(cd $NIO; $JAVAC -classpath $CP $(find . -name *.java)) || die
+
+
+g++ -Wall -shared -o libvmi.so vmi/*.cpp -I$CLASSLIB_HOME/deploy/include -I$CLASSLIB_HOME/native-src/linux.IA32/include -I$CLASSLIB_HOME/native-src/shared/include -DLINUX -L$CLASSLIB_HOME/deploy/jdk/jre/bin -lhyprt -lhythr -lhysig -L$CLASSLIB_HOME/native-src/linux.IA32/lib -lhyzip -lhypool 

Added: incubator/harmony/enhanced/classlibadapter/trunk/jc_run.sh
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlibadapter/trunk/jc_run.sh?rev=411596&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/jc_run.sh (added)
+++ incubator/harmony/enhanced/classlibadapter/trunk/jc_run.sh Sun Jun  4 13:55:02 2006
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+export JCHEVM_HOME=/home/ivan/experiments/harmony/jchevm/inst
+export CLASSLIB_HOME=/home/ivan/experiments/harmony/CLASSLIB/deploy/jdk/jre
+ADAPTER=$(dirname $0)
+
+JC=$JCHEVM_HOME/bin/jc
+JCZIP=$JCHEVM_HOME/share/jc/jc.zip
+KERNEL=$ADAPTER/modules/kernel/src/main/java
+NIO=$ADAPTER/modules/nio/src/main/java
+LUNI=$ADAPTER/modules/luni/src/main/java
+ADAPTER_JARS=$KERNEL:$NIO
+CLASSLIB_JARS=$(ls $CLASSLIB_HOME/lib/boot/*.jar $CLASSLIB_HOME/lib/boot/*/*.jar | tr '\n' ':')
+
+BOOT=$JCZIP:$ADAPTER_JARS:$CLASSLIB_JARS:$HOME/experiments/harmony/gnuclasspathadapter/ivan_classes
+
+ADAPTER_LIBS=$ADAPTER
+CLASSLIB_LIBS=$CLASSLIB_HOME/bin
+LIB_PATH=$ADAPTER_LIBS:$CLASSLIB_LIBS
+
+export LD_LIBRARY_PATH=$ADAPTER_LIBS:$CLASSLIB_LIBS:$LD_LIBRARY_PATH
+
+#gdb --args \
+$JC -Djava.library.path=$LIB_PATH -Djava.boot.class.path=$BOOT "$@"

Modified: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/VMStackWalker.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/VMStackWalker.java?rev=411596&r1=411595&r2=411596&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/VMStackWalker.java (original)
+++ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/VMStackWalker.java Sun Jun  4 13:55:02 2006
@@ -5,4 +5,17 @@
     //during bootup, jchevm specifically loads this class
     //this empty stub is all that is required for simple "hello world"
     //see jchevm/libjc/bootstrap.c
+    //
+    //_jc_object * _JC_JCNI_ATTR
+    // JCNI_gnu_classpath_VMStackWalker_getCallingClassLoader(_jc_env *env)
+    // _jc_object * _JC_JCNI_ATTR
+    // JCNI_gnu_classpath_VMStackWalker_getCallingClass(_jc_env *env)
+    // _jc_object_array * _JC_JCNI_ATTR
+    // JCNI_gnu_classpath_VMStackWalker_getClassContext(_jc_env *env)
+    // _jc_object * _JC_JCNI_ATTR
+    // JCNI_gnu_classpath_VMStackWalker_getClassLoader(_jc_env *env, _jc_object
+    // *clobj)
+    //
+    public static final native Class[] getClassContext();
+    public static final native ClassLoader getClassLoader(Class clazz);
 }

Added: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/VMSystemProperties.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/VMSystemProperties.java?rev=411596&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/VMSystemProperties.java (added)
+++ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/VMSystemProperties.java Sun Jun  4 13:55:02 2006
@@ -0,0 +1,66 @@
+package gnu.classpath;
+
+import java.util.Properties;
+
+public class VMSystemProperties
+{
+    // jchevm system properties exported specifically to this class
+    // Following native method defined:
+    //   void JCNI_gnu_classpath_VMSystemProperties_preInit(
+    //        _jc_env *env, _jc_object *props)
+    //
+    // Properties set:
+    // { "java.version",			"1.4.2" },
+    // { "java.vendor",			"JC virtual machine project" },
+    // { "java.vendor.url",			"http://jcvm.sourceforge.net/" },
+    // { "java.home",				_AC_DATADIR "/jc" },
+    // { "java.vm.name",			"JC virtual machine" },
+    // { "java.vm.vendor",			"JC virtual machine project" },
+    // { "java.vm.version",			PACKAGE_VERSION },
+    // { "java.vm.specification.name",		"Java Virtual Machine Specification" },
+    // { "java.vm.specification.vendor",	"Sun Microsystems Inc." },
+    // { "java.vm.specification.version",	"1.0" },
+    // { "java.specification.name",		"Java Platform API Specification" },
+    // { "java.specification.vendor",		"Sun Microsystems Inc." },
+    // { "java.specification.version",		"1.4" },
+    // { "java.class.version",			"46.0" },
+    // { "java.io.tmpdir",			_JC_TEMP_DIR },
+    // { "file.separator",			_JC_FILE_SEPARATOR },
+    // { "line.separator",			_JC_LINE_SEPARATOR },
+    // { "path.separator",			_JC_PATH_SEPARATOR },
+    // { "java.library.path",			_JC_LIBRARY_PATH },
+    // { "java.boot.class.path",		_JC_BOOT_CLASS_PATH },
+    // #if _JC_BIG_ENDIAN
+    // { "gnu.cpu.endian",			"big" },
+    // #else
+    // { "gnu.cpu.endian",			"little" },
+    // #endif
+    // #if _JC_THREAD_LOCAL_SUPPORT
+    // { "jc.thread.local",			"true" },
+    // #else
+    // { "jc.thread.local",			"false" },
+    // #endif
+    // { "jc.stack.minimum",			_JC_STACK_MINIMUM },
+    // { "jc.stack.maximum",			_JC_STACK_MAXIMUM },
+    // { "jc.stack.default",			_JC_STACK_DEFAULT },
+    // { "jc.java.stack.size",			_JC_JAVA_STACK_DEFAULT },
+    // { "jc.heap.size",			_JC_DEFAULT_HEAP_SIZE },
+    // { "jc.loader.size",			_JC_DEFAULT_LOADER_SIZE },
+    // { "jc.heap.granularity",		_JC_DEFAULT_HEAP_GRANULARITY },
+
+    private static native void preInit(Properties props);
+
+    static {
+        Properties props = new Properties();
+        preInit(props);
+        systemProperties = props;
+    }
+
+    private static Properties systemProperties;
+    private VMSystemProperties() {}
+
+    // FIXME: security checks needed
+    public static Properties getSystemProperties() {
+        return systemProperties;
+    }
+}

Added: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/BootstrapClassLoader.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/BootstrapClassLoader.java?rev=411596&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/BootstrapClassLoader.java (added)
+++ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/BootstrapClassLoader.java Sun Jun  4 13:55:02 2006
@@ -0,0 +1,67 @@
+package java.lang;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.io.File;
+import java.util.StringTokenizer;
+
+
+// The class is needed to support
+// org.apache.harmony.kernel.vm.VM.bootCallerClassLoader()
+// which is required for support of ResourceBundles in system classes. 
+// FIXME: permissions
+public final class BootstrapClassLoader extends URLClassLoader {
+
+    //private Object[] path;
+    private String sep;
+    private static ClassLoader cl;
+
+    BootstrapClassLoader() {
+        super(new URL[0]);
+    }
+
+    public static synchronized ClassLoader getBootstrapClassLoader() {
+        if (cl == null) cl = new BootstrapClassLoader();
+        return cl;
+    }
+
+
+    private void setup() {
+        String classpath = System.getProperty("java.boot.class.path");
+        sep = System.getProperty("file.separator");
+        String pathSep = System.getProperty("path.separator");
+        StringTokenizer tokens = new StringTokenizer(classpath, pathSep);
+
+        while (tokens.hasMoreElements()) {
+            String filename = tokens.nextToken();
+
+            //System.err.println("user.dir = " + System.getProperty("user.dir"));
+
+            try {
+                File f = new File(filename);
+                if (f.isDirectory()) {
+                    String u = "file://" + f.getAbsolutePath() + "/";
+                    //System.err.println("url = " + u);
+                    addURL(new URL(u));
+                } else {
+                    String u = "file://" + f.getAbsolutePath();
+                    //System.err.println("url(jar) = " + u);
+                    addURL(new URL(u));
+                }
+            } catch (Throwable t) {
+                t.printStackTrace();
+            }
+        }
+    }
+
+
+	protected Class findClass(String className) throws ClassNotFoundException {
+        if (sep == null) setup();
+        return super.findClass(className);
+    }
+
+	public URL getResource(String resName) {
+        if (sep == null) setup();
+        return findResource(resName);
+	}
+}

Modified: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Class.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Class.java?rev=411596&r1=411595&r2=411596&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Class.java (original)
+++ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Class.java Sun Jun  4 13:55:02 2006
@@ -19,6 +19,7 @@
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
 import java.net.URL;
 import java.security.ProtectionDomain;
 
@@ -66,7 +67,7 @@
  * </dl>
  * 
  */
-public final class Class implements java.io.Serializable {
+public final class Class<T> implements java.io.Serializable {
 	private static final long serialVersionUID = 3206093459760846163L;
 
     Object vmdata;
@@ -86,7 +87,7 @@
 	 */
 	public static Class forName(String className) throws ClassNotFoundException {
         boolean initializeBoolean = true; // a guess that somehow allows "hello world" to work on jchevm
-        ClassLoader classloader = null;  // a guess that somehow allows "hello world" to work on jchevm
+        ClassLoader classloader = ClassLoader.callerClassLoader();
 		return VMClass.forName(className, initializeBoolean, classloader);
 	}
 
@@ -206,26 +207,40 @@
 	 *             if member access is not allowed
 	 * @see #getConstructors
 	 */
-	public Constructor getConstructor(Class parameterTypes[])
+	public Constructor getConstructor(Class[] parameterTypes)
 			throws NoSuchMethodException, SecurityException {
- 
-        boolean publicOnly = true;  //fixit -- find out what publicOnly should be set to
+        return getDeclaredConstructor(parameterTypes, true);
+	}
+
+    private Constructor getDeclaredConstructor(Class[] parameterTypes, boolean publicOnly)
+        throws NoSuchMethodException, SecurityException {
         Constructor[] conArray = VMClass.getDeclaredConstructors(this, publicOnly);
+
+outer:
         for (int ii = 0; ii < conArray.length; ii++)
         {
-            Class [] ca = conArray[ii].getParameterTypes();
-            int jj;
-            for (jj = 0; jj < ca.length; jj++) 
-            {
-                if (parameterTypes[jj] != ca[jj])
-                    break;
+            Constructor c = (Constructor) conArray[ii];
+
+            Class [] ca = c.getParameterTypes();
+
+            if (parameterTypes == null) {
+                if (ca == null || ca.length != 0) return c;
+            } else if (ca == null) {
+                if (parameterTypes.length == 0) return c;
+            } else {
+                if (ca.length != parameterTypes.length) continue;
+
+                for (int i = 0; i < ca.length; i++) 
+                {
+                    if (!ca[i].equals(parameterTypes[i]))
+                        continue outer;
+                }
             }
-            if (jj == parameterTypes.length)  // its an exact match
-                return conArray[jj];
+            return c;
         }
         NoSuchMethodException nsme = new NoSuchMethodException();
         throw nsme;
-	}
+    }
 
 	/**
 	 * Answers an array containing Constructor objects describing all
@@ -237,8 +252,7 @@
 	 * @see #getMethods
 	 */
 	public Constructor[] getConstructors() throws SecurityException {
-        boolean publicOnly = false;  // fixit -- find out what publicOnly should be set to
-		return VMClass.getDeclaredConstructors(this, publicOnly);
+		return VMClass.getDeclaredConstructors(this, true);
 	}
 
 	/**
@@ -269,25 +283,11 @@
 	 *             if member access is not allowed
 	 * @see #getConstructors
 	 */
-	public Constructor getDeclaredConstructor(Class parameterTypes[])
+	public Constructor getDeclaredConstructor(Class[] parameterTypes)
 			throws NoSuchMethodException, SecurityException {
-        boolean publicOnly = true;  //fixit -- find out what publicOnly should be set to
-        Constructor[] conArray = VMClass.getDeclaredConstructors(this, publicOnly);
-
-        for (int ii = 0; ii < conArray.length; ii++)
-        {
-            Class [] ca = conArray[ii].getParameterTypes();
-            int jj;
-            for (jj = 0; jj < ca.length; jj++) 
-            {
-                if (parameterTypes[jj] != ca[jj])
-                    break;
-            }
-            if (jj == parameterTypes.length)  // its an exact match
-                return conArray[jj];
-        }
-        NoSuchMethodException nsme = new NoSuchMethodException();
-        throw nsme;
+        // FIXME security
+        
+        return getDeclaredConstructor(parameterTypes, false);
 	}
 
 	/**
@@ -302,8 +302,7 @@
 	 * @see #getMethods
 	 */
 	public Constructor[] getDeclaredConstructors() throws SecurityException {
-        boolean publicOnly = false;  // fixit -- find out what publicOnly should be set to
-        return VMClass.getDeclaredConstructors(this, publicOnly);
+        return VMClass.getDeclaredConstructors(this, false);
 	}
 
 	/**
@@ -322,14 +321,17 @@
 	 */
 	public Field getDeclaredField(String name) throws NoSuchFieldException,
 			SecurityException {
-        boolean publicOnly = false;  //fixit -- find out what public only should be set to
+        // FIXME: security
+        return getDeclaredField(name, false);
+	}
+
+	private Field getDeclaredField(String name, boolean publicOnly)
+        throws NoSuchFieldException {
         Field [] fields = VMClass.getDeclaredFields(this, publicOnly);
-        for (int ii = 0; ii < fields.length; ii++) 
-        {
-            if (fields[ii].toString() == name) return fields[ii];
+        for (int ii = 0; ii < fields.length; ii++) {
+            if (fields[ii].getName().equals(name)) return fields[ii];
         }
-		NoSuchFieldException nsfe = new NoSuchFieldException();
-        throw nsfe;
+		throw new NoSuchFieldException(name);
 	}
 
 	/**
@@ -343,8 +345,7 @@
 	 * @see #getFields
 	 */
 	public Field[] getDeclaredFields() throws SecurityException {
-        boolean publicOnly = false;  // fixit -- find out what publicOnly should be set to
-        return VMClass.getDeclaredFields(this, publicOnly);
+        return VMClass.getDeclaredFields(this, false);
 	}
 
 	/**
@@ -363,17 +364,9 @@
 	 *             If member access is not allowed
 	 * @see #getMethods
 	 */
-	public Method getDeclaredMethod(String name, Class parameterTypes[])
+	public Method getDeclaredMethod(String name, Class[] parameterTypes)
 			throws NoSuchMethodException, SecurityException {
-        boolean publicOnly = false;  //fixit -- find out what publicOnly should be set to
-        Method [] methods = VMClass.getDeclaredMethods(this, publicOnly);
-        for (int ii = 0; ii < methods.length; ii++) 
-        {
-            //fixit ---- oops, need to match on parameterTypes also
-            if (methods[ii].toString() == name) return methods[ii];
-        }
-        NoSuchMethodException nsme = new NoSuchMethodException();
-        throw nsme;
+        return getDeclaredMethod(name, parameterTypes, false);
 	}
 
 	/**
@@ -387,8 +380,7 @@
 	 * @see #getMethods
 	 */
 	public Method[] getDeclaredMethods() throws SecurityException {
-        boolean publicOnly = false;  //fixit -- find out what publicOnly should be set to
-        return VMClass.getDeclaredMethods(this, publicOnly);
+        return VMClass.getDeclaredMethods(this, false);
 	}
 
 	/**
@@ -416,14 +408,7 @@
 	 */
 	public Field getField(String name) throws NoSuchFieldException,
 			SecurityException {
-        boolean publicOnly = true;  //fixit -- find out what publicOnly should be set to
-        Field [] fields = VMClass.getDeclaredFields(this, publicOnly);
-        for (int ii = 0; ii < fields.length; ii++) 
-        {
-            if (fields[ii].toString() == name) return fields[ii];
-        }
-		NoSuchFieldException nsfe = new NoSuchFieldException();
-        throw nsfe;
+        return getDeclaredField(name, true);
 	}
 
 	/**
@@ -436,8 +421,7 @@
 	 * @see #getDeclaredFields
 	 */
 	public Field[] getFields() throws SecurityException {
-        boolean publicOnly = true;  //fixit -- find out what publicOnly should be set to
-        Field[] fld = VMClass.getDeclaredFields(this, publicOnly);
+        Field[] fld = VMClass.getDeclaredFields(this, true);
         return fld;
 	}
 
@@ -468,25 +452,32 @@
 	 */
 	public Method getMethod(String name, Class parameterTypes[])
 			throws NoSuchMethodException, SecurityException {
-        boolean publicOnly = false;  //fixit -- find out what publicOnly should be set to
+        return getDeclaredMethod(name, parameterTypes, true);
+	}
+
+    private Method getDeclaredMethod(String name, Class[] parameterTypes, boolean publicOnly)
+           throws NoSuchMethodException {
         Method [] methods = VMClass.getDeclaredMethods(this, publicOnly);
+
+outer:
         for (int ii = 0; ii < methods.length; ii++) 
         {
-            // fixit need to add code that matches on parameterTypes also
-            if (methods[ii].toString() == name) 
-            {
-                Class [] paramArray = methods[ii].getParameterTypes();
-                for (int jj = 0; jj < paramArray.length; jj++) 
-                {
-                   if (paramArray[jj] != parameterTypes[jj])
-                       break;
+            Method m = methods[ii];
+
+            if (!m.getName().equals(name)) continue;
+            Class[] args = m.getParameterTypes();
+            if (parameterTypes == null) {
+                if (args.length != 0) continue;
+            } else {
+                if (args.length != parameterTypes.length) continue;
+                for (int i = 0; i < args.length; i++) {
+                    if (!args[i].equals(parameterTypes[i])) continue outer;
                 }
-                return methods[ii];
             }
+            return m;
         }
-        NoSuchMethodException nsme = new NoSuchMethodException();
-        throw nsme;
-	}
+        throw new NoSuchMethodException();
+    }
 
 	/**
 	 * Answers an array containing Method objects describing all methods which
@@ -498,8 +489,7 @@
 	 * @see #getDeclaredMethods
 	 */
 	public Method[] getMethods() throws SecurityException {
-        boolean publicOnly = false;  //fixit -- find out what publicOnly should be set to
-        return VMClass.getDeclaredMethods(this, publicOnly);
+        return VMClass.getDeclaredMethods(this, true);
 	}
 
 	/**
@@ -557,6 +547,11 @@
 		return null;
 	};
 
+    private String getResourceName(String path) {
+        if (path.charAt(0) == '/') return path.substring(1, path.length());
+        return getPackageName().replace('.', '/') + "/" + path;
+    }
+
 	/**
 	 * Answers a read-only stream on the contents of the resource specified by
 	 * resName. The mapping between the resource name and the stream is managed
@@ -568,9 +563,13 @@
 	 * @see java.lang.ClassLoader
 	 */
 	public URL getResource(String resName) {
-        // fixit -- need to find an expert on getResource()
-        // for "hello world", returning null works OK
-		return null;
+        ClassLoader cl = getClassLoader();
+        String name = getResourceName(resName);
+        if (cl != null) {
+            return cl.getResource(name);
+        } else {
+            return ClassLoader.getSystemResource(name);
+        }
 	}
 
 	/**
@@ -584,9 +583,13 @@
 	 * @see java.lang.ClassLoader
 	 */
 	public InputStream getResourceAsStream(String resName) {
-        // fixit -- need to find an expert on getResource()
-        // for "hello world", returning null works OK
-		return null;
+        ClassLoader cl = getClassLoader();
+        String name = getResourceName(resName);
+        if (cl != null) {
+            return cl.getResourceAsStream(name);
+        } else {
+            return ClassLoader.getSystemResourceAsStream(name);
+        }
 	}
 
 	/**
@@ -690,11 +693,22 @@
 	 * @throws InstantiationException
 	 *             if the instance could not be created.
 	 */
+    static int num = 0;
 	public Object newInstance() throws IllegalAccessException,
-			InstantiationException {
-        // fixit -- returning null works OK for simple "hello world"
-		return null;
-	}
+               InstantiationException {
+            try {
+                Constructor c = getDeclaredConstructor(new Class[0]);
+                return c.newInstance(new Object[0]);
+            } catch (NoSuchMethodException e) {
+                e.printStackTrace();
+            } catch (InvocationTargetException e) {
+                e.printStackTrace();
+            } catch (NullPointerException e) {
+                e.printStackTrace();
+            }
+            throw new InstantiationException();
+        }
+
 
 	/**
 	 * Answers a string containing a concise, human-readable description of the
@@ -703,10 +717,14 @@
 	 * @return a printable representation for the receiver.
 	 */
 	public String toString() {
-        //System.out.println("Class.toString() -- not implemented");
-        return this.toString();  /// is this right???????
+        return "class " + getName();
 	}
 
+    private String getPackageName() {
+        String name = getName();
+        return name.substring(0, name.lastIndexOf('.'));
+    }
+
 	/**
 	 * Returns the Package of which this class is a member. A class has a
 	 * Package iff it was loaded from a SecureClassLoader
@@ -714,8 +732,9 @@
 	 * @return Package the Package of which this class is a member or null
 	 */
 	public Package getPackage() {
-        // fixit -- returning null works OK for simple "hello world" app
-		return null;
+        ClassLoader cl = getClassLoader();
+        if (cl == null) return null;
+        return cl.getPackage(getPackageName());
 	}
 
 	/**
@@ -768,5 +787,9 @@
 		return null;
 	};
 
+    public boolean isSynthetic() {
+        // FIXME: not implemented
+        return false;
+    }
 }
 

Modified: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/ClassLoader.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/ClassLoader.java?rev=411596&r1=411595&r2=411596&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/ClassLoader.java (original)
+++ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/ClassLoader.java Sun Jun  4 13:55:02 2006
@@ -19,8 +19,9 @@
 import java.net.URL;
 import java.security.ProtectionDomain;
 import java.util.Enumeration;
-
-
+import java.util.HashMap;
+import java.util.Collection;
+import gnu.classpath.VMStackWalker;
 
 /**
  * This class must be implemented by the vm vendor. The documented methods and
@@ -31,9 +32,8 @@
  */
 public /*abstract*/ class ClassLoader {
 
-	static ClassLoader systemClassLoader;
-
-    ClassLoader parent; // jchevm/libcj/bootstrap.c requires the presence of this particular field
+    ClassLoader parent;
+    static ClassLoader systemClassLoader;
     Object vmdata; // jchevm/libcj/bootstrap.c requires the presence of this particular field
 
 	static final void initializeClassLoaders() {
@@ -42,6 +42,10 @@
 		return;
 	}
 
+    static {
+        setupSystemClassLoader();
+    }
+
 	/**
 	 * Constructs a new instance of this class with the system class loader as
 	 * its parent.
@@ -51,7 +55,7 @@
 	 *                creation of new ClassLoaders.
 	 */
 	protected ClassLoader() {
-        super();
+        parent = getSystemClassLoader();
 	}
 
 	/**
@@ -68,8 +72,9 @@
 	 *                if the parent is null.
 	 */
 	protected ClassLoader(ClassLoader parentLoader) {
-        // fixit -- need to verify this is correct code
-		super();
+        if (parentLoader == null)
+            parentLoader = systemClassLoader;
+        parent = parentLoader;
 	}
 
 	/**
@@ -86,9 +91,7 @@
 	 */
 	protected final Class defineClass(byte[] classRep, int offset, int length)
 			throws ClassFormatError {
-        // fixit -- need to add the correct code
-        // returning null works OK for simple "hello world" demo
-		return null;
+		return defineClass(null, classRep, offset, length);
 	}
 
 	/**
@@ -147,7 +150,7 @@
 	 */
 	protected Class findClass(String className) throws ClassNotFoundException {
         // fixit -- returning null allows "hello world" to work but is incorrect
-		return null;
+		throw new ClassNotFoundException(className);
 	}
 
 	/**
@@ -160,7 +163,6 @@
 	 *            String the name of the class to search for.
 	 */
 	protected final Class findLoadedClass(String className) {
-        //System.out.println("ClassLoader.findLoadedClass(String) -- is not implemented");
 		return VMClassLoader.findLoadedClass(this, className);
 	};
 
@@ -177,7 +179,8 @@
 	protected final Class findSystemClass(String className)
 			throws ClassNotFoundException {
         // fixit -- confirm that only the system class loader is being used
-		return VMClassLoader.findLoadedClass(this, className);
+		return VMClassLoader.findLoadedClass(
+                systemClassLoader, className);
 	}
 
 	/**
@@ -189,8 +192,7 @@
 	 *                parent loader to be retrieved.
 	 */
 	public final ClassLoader getParent() {
-        //fixit ----   probably need a security expert to help out here
-		return null;
+		return parent;
 	}
 
 	/**
@@ -204,9 +206,9 @@
 	 * @see Class#getResource
 	 */
 	public URL getResource(String resName) {
-        //fixit -- the above says default behavior is to just return null
-        // is returning null good enough for all cases?
-		return null;
+        URL resource = parent.getResource(resName);
+        if (resource != null) return resource;
+        return findResource(resName);
 	}
 
 	/**
@@ -219,9 +221,7 @@
 	 *            String the name of the resource to find.
 	 */
 	public final Enumeration getResources(String resName) throws IOException {
-        //fixit -- apparently Resources are not needed for simple "hello world"
-        //maybe find someone who knows resources to figure this one out?
-		return null;
+        throw new RuntimeException("not implemented");
 	}
 
 	/**
@@ -235,9 +235,13 @@
 	 * @see Class#getResourceAsStream
 	 */
 	public InputStream getResourceAsStream(String resName) {
-        //fixit -- apparently Resources are not needed for simple "hello world"
-        //maybe find someone who knows resources to figure this one out?
-		return null;
+        try {
+            URL url = getResource(resName);
+            if (url == null) return null;
+            return url.openStream();
+        } catch (IOException ioe) {
+            return null;
+        }
 	}
 
 	/**
@@ -257,17 +261,25 @@
 	 *                to the system class loader.
 	 */
 	public static ClassLoader getSystemClassLoader() {
-        try 
-        {
-            if (systemClassLoader == null) 
-            {
-                systemClassLoader = new ClassLoader();
-            }
-        } 
-        catch (Exception e) { return null;}
         return systemClassLoader;
 	}
 
+    static void setupSystemClassLoader() {
+        String name = null;
+        try {
+            name = System.getProperty("java.system.class.loader",
+                    "java.lang.SystemClassLoader");
+            Class clzz = VMClassLoader.loadClass(name, true);
+            ClassLoader cl = (ClassLoader) clzz.newInstance();
+            // FIXME: security checks and so on
+            systemClassLoader = cl;
+        } catch (Throwable t) {
+            System.err.println("error instantiating system classloader: " + name);
+            t.printStackTrace();
+            throw new RuntimeException(t);
+        }
+    }
+
 	/**
 	 * Answers an URL specifing a resource which can be found by looking up
 	 * resName using the system class loader's resource lookup algorithm.
@@ -278,9 +290,7 @@
 	 * @see Class#getResource
 	 */
 	public static URL getSystemResource(String resName) {
-        //fixit -- apparently Resources are not needed for simple "hello world"
-        //maybe find someone who knows resources to figure this one out?
-		return null;
+        return BootstrapClassLoader.getBootstrapClassLoader().getResource(resName);
 	}
 
 	/**
@@ -296,7 +306,8 @@
 			throws IOException {
         //fixit -- apparently Resources are not needed for simple "hello world"
         //maybe find someone who knows resources to figure this one out?
-		return null;
+        throw new RuntimeException("not implemented");
+		//return null;
 	}
 
 	/**
@@ -311,9 +322,7 @@
 	 * @see Class#getResourceAsStream
 	 */
 	public static InputStream getSystemResourceAsStream(String resName) {
-        //fixit -- apparently Resources are not needed for simple "hello world"
-        //maybe find someone who knows resources to figure this one out?
-		return null;
+        return BootstrapClassLoader.getBootstrapClassLoader().getResourceAsStream(resName);
 	}
 
 	/**
@@ -327,10 +336,7 @@
 	 *                If the class could not be found.
 	 */
 	public Class loadClass(String className) throws ClassNotFoundException {
-        //fixit -- resolveIt should probably be set to true
-        // but for "hello world", it was accidentally set to false
-        boolean resolveIt = true;
-		return VMClassLoader.loadClass(className, resolveIt);
+		return loadClass(className, false);
 	}
 
 	/**
@@ -347,9 +353,27 @@
 	 * @exception ClassNotFoundException
 	 *                If the class could not be found.
 	 */
-	protected Class loadClass(String className, boolean resolveClass)
+	protected Class loadClass(String className, boolean resolve)
 			throws ClassNotFoundException {
-		return VMClassLoader.loadClass(className, resolveClass);
+        Class clazz = findLoadedClass(className);
+        if (clazz != null) {
+            if (resolve) resolveClass(clazz);
+            return clazz;
+        }
+
+        try {
+            if (parent == null) {
+                clazz = VMClassLoader.loadClass(className, resolve);
+            } else {
+                clazz = parent.loadClass(className, false);
+            }
+            if (resolve) resolveClass(clazz);
+            return clazz;
+        } catch (ClassNotFoundException e) {}
+
+        clazz = findClass(className);
+        if (resolve) resolveClass(clazz);
+        return clazz;
 	}
 
 	/**
@@ -382,8 +406,8 @@
 	 * @see Class#getClassLoaderImpl()
 	 */
 	final boolean isSystemClassLoader() {
-        //fixit -- this gets security out of the way for simple "hello world"
-		return true;
+        throw new RuntimeException("what's here?");
+		//return true;
 	}
 
 	/**
@@ -398,8 +422,8 @@
 	 * @return boolean true if the receiver is ancestor of the parameter
 	 */
 	final boolean isAncestorOf(ClassLoader child) {
-        //fixit -- this gets security out of the way for simple "hello world"
-		return false;
+        throw new RuntimeException("what's here?");
+		//return false;
 	}
 
 	/**
@@ -414,8 +438,6 @@
 	 *					the name of the resource to find.
 	 */
 	protected URL findResource(String resName) {
-        //fixit -- apparently Resources are not needed for simple "hello world"
-        //maybe find someone who knows resources to figure this one out?
 		return null;
 	}
 
@@ -452,6 +474,8 @@
 		return null;
 	}
 
+    HashMap packages = new HashMap();
+
 	/**
 	 * Attempt to locate the requested package. If no package information can be
 	 * located, null is returned.
@@ -461,8 +485,10 @@
 	 * @return The package requested, or null
 	 */
 	protected Package getPackage(String name) {
-        //fixit -- returning null allows simple "hello world" to work
-		return null;
+        synchronized (packages) {
+            Package p = (Package) packages.get(name);
+            return p;
+        }
 	}
 
 	/**
@@ -471,8 +497,10 @@
 	 * @return All the packages known to this classloader
 	 */
 	protected Package[] getPackages() {
-        //fixit -- returning null allows simple "hello world" to work
-		return null;
+        synchronized (packages) {
+            Collection col = packages.values();
+            return (Package[]) col.toArray();
+        }
 	}
 
 	/**
@@ -500,8 +528,21 @@
 			String specVersion, String specVendor, String implTitle,
 			String implVersion, String implVendor, URL sealBase)
 			throws IllegalArgumentException {
-        //fixit -- returning null allows simple "hello world" to work
-		return null;
+        // FIXME: not sure
+        // FIXME: race condition adding packages
+        Package p = (Package) packages.get(name);
+        if (p == null) {
+            Package newPackage = 
+                    new Package(name, specTitle, specVersion, specVendor, implTitle,
+                    implVersion, implVendor, sealBase);
+            synchronized (packages) {
+                packages.put(name, newPackage);
+                p = newPackage;
+            }
+        } else {
+            System.err.println("package " + name + " already defined");
+        }
+        return p;
 	}
 
 	/**
@@ -552,8 +593,7 @@
 	 * @return the ClassLoader at the specified depth
 	 */
 	static final ClassLoader getStackClassLoader(int depth) {
-        //fixit -- returning null allows simple "hello world" to work
-		return null;
+        throw new RuntimeException("not implemented");
 	};
 
 	/**
@@ -567,8 +607,8 @@
 	 * @return a ClassLoader or null for the bootstrap ClassLoader
 	 */
 	static ClassLoader callerClassLoader() {
-        //fixit -- returning null allows simple "hello world" to work
-		return null;
+        Class[] classes = VMStackWalker.getClassContext();
+        return classes[2].getClassLoader();
 	}
 
 	/**
@@ -588,12 +628,7 @@
 	 *                if the library was not allowed to be loaded
 	 */
 	static void loadLibraryWithClassLoader(String libName, ClassLoader loader) {
-        try 
-        {
-            VMClassLoader.loadClass(libName, true);
-        } 
-        catch (Exception e) { return;}
-		return;
+        throw new RuntimeException("not implemented");
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Object.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Object.java?rev=411596&r1=411595&r2=411596&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Object.java (original)
+++ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Object.java Sun Jun  4 13:55:02 2006
@@ -156,10 +156,9 @@
 	 * @return String a printable representation for the receiver.
 	 */
 	public String toString() {
-        int hc = VMSystem.identityHashCode(this);
-        Integer ihc = new Integer(hc);
-		String retVal = new String(ihc.toString());
-        return retVal;
+        int hash = hashCode();
+        String className = getClass().getName();
+        return className + "@" + Integer.toHexString(hash);
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Package.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Package.java?rev=411596&r1=411595&r2=411596&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Package.java (original)
+++ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Package.java Sun Jun  4 13:55:02 2006
@@ -34,6 +34,22 @@
  */
 public class Package {
 
+    private final String name, specTitle, specVersion, specVendor, implTitle,
+            implVersion, implVendor;
+    //private final URL sealBase;
+
+    Package(String name, String specTitle, String specVersion, String specVendor,
+            String implTitle, String implVersion, String implVendor, URL sealBase) {
+        this.name = name;
+        this.specTitle = specTitle;
+        this.specVersion = specVersion;
+        this.specVendor = specVendor;
+        this.implTitle = implTitle;
+        this.implVersion = implVersion;
+        this.implVendor = implVendor;
+        //this.sealBase = sealBase;
+    }
+
 	/**
 	 * Return the title of the implementation of this package, or null if this
 	 * is unknown. The format of this string is unspecified.
@@ -41,8 +57,7 @@
 	 * @return The implementation title, or null
 	 */
 	public String getImplementationTitle() {
-        //fixit -- returning "null" is good enough to get simple "hello world" to work
-		return null;
+		return implTitle;
 	}
 
 	/**
@@ -53,8 +68,7 @@
 	 * @return The implementation vendor name, or null
 	 */
 	public String getImplementationVendor() {
-        //fixit -- returning "null" is good enough to get simple "hello world" to work
-		return null;
+		return implVendor;
 	}
 
 	/**
@@ -64,8 +78,7 @@
 	 * @return The implementation version, or null
 	 */
 	public String getImplementationVersion() {
-        //fixit -- returning "null" is good enough to get simple "hello world" to work
-		return null;
+		return implVersion;
 	}
 
 	/**
@@ -75,8 +88,7 @@
 	 * @return The name of this package
 	 */
 	public String getName() {
-        //fixit -- returning "null" is good enough to get simple "hello world" to work
-		return null;
+		return name;
 	}
 
 	/**
@@ -90,8 +102,8 @@
 	 * @see ClassLoader#getPackage
 	 */
 	public static Package getPackage(String packageName) {
-        //fixit -- returning "null" is good enough to get simple "hello world" to work
-		return null;
+        ClassLoader classloader = ClassLoader.callerClassLoader();
+		return classloader.getPackage(packageName);
 	}
 
 	/**
@@ -102,8 +114,8 @@
 	 * @see ClassLoader#getPackages
 	 */
 	public static Package[] getPackages() {
-        //fixit -- returning "null" is good enough to get simple "hello world" to work
-		return null;
+        ClassLoader classloader = ClassLoader.callerClassLoader();
+        return classloader.getPackages();
 	}
 
 	/**
@@ -113,8 +125,7 @@
 	 * @return The specification title, or null
 	 */
 	public String getSpecificationTitle() {
-        //fixit -- returning "null" is good enough to get simple "hello world" to work
-		return null;
+		return specTitle;
 	}
 
 	/**
@@ -124,8 +135,7 @@
 	 * @return The specification vendor name, or null
 	 */
 	public String getSpecificationVendor() {
-        //fixit -- returning "null" is good enough to get simple "hello world" to work
-		return null;
+		return specVendor;
 	}
 
 	/**
@@ -136,8 +146,7 @@
 	 * @return The specification version string, or null
 	 */
 	public String getSpecificationVersion() {
-        //fixit -- returning "null" is good enough to get simple "hello world" to work
-		return null;
+		return specVersion;
 	}
 
 	/**
@@ -148,8 +157,7 @@
 	 * @return the receiver's hash
 	 */
 	public int hashCode() {
-        //fixit -- always returning zero makes for a lousy hash but is good enough to get simple "hello world" to work
-		return 0;
+		return name.hashCode();
 	}
 
 	/**
@@ -168,7 +176,7 @@
 	public boolean isCompatibleWith(String version)
 			throws NumberFormatException {
         //fixit -- always returning "false" is good enough for simple "hello world" application
-		return false;
+		throw new RuntimeException("not implemented");
 	}
 
 	/**
@@ -177,8 +185,7 @@
 	 * @return true if this package is sealed, false otherwise
 	 */
 	public boolean isSealed() {
-        //fixit -- always returning "false" is good enough for simple "hello world" application
-		return false;
+		throw new RuntimeException("not implemented");
 	}
 
 	/**
@@ -191,7 +198,8 @@
 	 */
 	public boolean isSealed(URL url) {
         //fixit -- always returning "false" is good enough for simple "hello world" application
-		return false;
+		//return false;
+		throw new RuntimeException("not implemented");
 	}
 
 	/**
@@ -202,7 +210,8 @@
 	 */
 	public String toString() {
         //fixit -- always returning "false" is good enough for simple "hello world" application
-		return null;
+        // FIXME
+		return "package " + name;
 	}
 }
 

Modified: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Runtime.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Runtime.java?rev=411596&r1=411595&r2=411596&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Runtime.java (original)
+++ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Runtime.java Sun Jun  4 13:55:02 2006
@@ -18,6 +18,7 @@
 import java.io.File;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.util.StringTokenizer;
 
 
 /**
@@ -187,15 +188,74 @@
 		return;
 	};
 
+    private static Runtime runtime;
+
+    static {
+        runtime = new Runtime();
+    }
+
+    private Runtime() {}
+
 	/**
 	 * Return the single Runtime instance
 	 * 
 	 */
 	public static Runtime getRuntime() {
-        //fixit -- always returning "null" is good enough to allow simple "hello world" to work
-		return null;
+        // FIXME: all the security checks
+        return runtime;
 	}
 
+    /**
+     * Implementation of Runtime.load() without security checks.
+     * For java.lang.* classes.
+     * @param ClassLoader the classloader of class who initiated the loading.
+     */
+    void loadInternal(String pathName, ClassLoader classLoader) {
+        VMRuntime.nativeLoad(
+                pathName, classLoader);
+    }
+
+    /**
+     * Implementation of Runtime.loadLibrary() without security checks.
+     * For java.lang.* classes.
+     */
+    void loadLibraryInternal(String libName, ClassLoader classLoader) {
+        String path = null;
+        if (classLoader != null) {
+            path = classLoader.findLibrary(libName);
+        }
+
+        if (path != null) {
+            VMRuntime.nativeLoad(
+                    path, classLoader);
+            return;
+        }
+
+        String fileName = System.mapLibraryName(libName);
+        String libraryPath = System.getProperty("java.library.path");
+        String pathSeparator = System.getProperty("path.separator");
+        String fileSeparator = System.getProperty("file.separator");
+
+        StringTokenizer tokens = new StringTokenizer(libraryPath, pathSeparator);
+
+        // FIXME: too many exceptions thrown here, should be other way
+        UnsatisfiedLinkError ule = null;
+        while (tokens.hasMoreElements()) {
+            String dir = tokens.nextToken();
+            path = dir + fileSeparator + fileName;
+            try {
+                int res = VMRuntime.nativeLoad(
+                        path, classLoader);
+                if (res == 0) continue;
+                return;
+            } catch (UnsatisfiedLinkError e) {
+                ule = e;
+            }
+        }
+        if (ule != null) throw ule;
+        throw new UnsatisfiedLinkError("failed loading " + fileName + " java.library.path=" + libraryPath);
+    }
+
 	/**
 	 * Loads and links the library specified by the argument.
 	 * 
@@ -208,8 +268,9 @@
 	 *                if the library was not allowed to be loaded
 	 */
 	public void load(String pathName) {
-        VMRuntime.nativeLoad(pathName, ClassLoader.systemClassLoader);
-		return;
+        // FIXME: all the security checks
+        ClassLoader classLoader = ClassLoader.callerClassLoader();
+        loadInternal(pathName, classLoader);
 	}
 
 	/**
@@ -223,8 +284,9 @@
 	 *                if the library was not allowed to be loaded
 	 */
 	public void loadLibrary(String libName) {
-        //fixit -- always returning "null" is good enough to allow simple "hello world" to work
-		return;
+        // FIXME: all the security checks
+        ClassLoader classLoader = ClassLoader.callerClassLoader();
+        loadLibraryInternal(libName, classLoader);
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/StackTraceElement.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/StackTraceElement.java?rev=411596&r1=411595&r2=411596&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/StackTraceElement.java (original)
+++ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/StackTraceElement.java Sun Jun  4 13:55:02 2006
@@ -33,7 +33,10 @@
 
     StackTraceElement(String s1, int i1, String s2, String s3, boolean b1)
     {
-        System.out.println("StackTraceElement<init> called, not implemented"); //wjw
+        declaringClass = s2;
+	methodName = s3;
+	fileName = s1;
+	lineNumber = i1;
     }
 	/**
 	 * Create a StackTraceElement from the parameters.
@@ -200,4 +203,3 @@
 		return buf.toString();
 	}
 }
-



Mime
View raw message