You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ar...@apache.org on 2006/06/04 22:55:04 UTC

svn commit: r411596 [4/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/...

Added: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/org/apache/harmony/kernel/vm/VM.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/org/apache/harmony/kernel/vm/VM.java?rev=411596&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/org/apache/harmony/kernel/vm/VM.java (added)
+++ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/org/apache/harmony/kernel/vm/VM.java Sun Jun  4 13:55:02 2006
@@ -0,0 +1,319 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.kernel.vm;
+
+/**
+ * This class must be implemented by the vm vendor. Represents the running
+ * virtual machine. All VM specific API are implemented on this class.
+ * <p>
+ * Note that all methods in VM are static. There is no singleton instance which
+ * represents the actively running VM.
+ */
+public final class VM {
+	
+	/*
+	 * kernelVersion has the format: aabbxxyy
+	 * where:
+	 * 	aa - major version of kernel. Must equal that stored in jcl.
+	 * 	bb - minor version of kernel. Must be >= that in jcl.
+	 *	xx - major version of jcl. Must equal that stored in kernel.
+	 *	yy - minor version of jcl. Must be >= that in kernel.
+	 */
+	//private static final int kernelVersion = 0x01000100;
+
+	/**
+	 * This method must be provided by the vm vendor, as it is used by
+	 * org.apache.harmony.kernel.vm.MsgHelp.setLocale() to get the bootstrap ClassLoader.
+	 * MsgHelp uses the bootstrap ClassLoader to find the resource bundle of
+	 * messages packaged with the bootstrap classes. Returns the ClassLoader of
+	 * the method (including natives) at the specified depth on the stack of the
+	 * calling thread. Frames representing the VM implementation of
+	 * java.lang.reflect are not included in the list. This is not a public
+	 * method as it can return the bootstrap class loader, which should not be
+	 * accessed by non-bootstrap classes. Notes:
+	 * <ul>
+	 * <li>This method operates on the defining classes of methods on stack.
+	 * NOT the classes of receivers.</li>
+	 * <li>The item at depth zero is the caller of this method</li>
+	 * </ul>
+	 * 
+	 * @param depth
+	 *            the stack depth of the requested ClassLoader
+	 * @return the ClassLoader at the specified depth
+	 * @see java.lang.ClassLoader#getStackClassLoader
+	 */
+	static final ClassLoader getStackClassLoader(int depth) {
+		throw new RuntimeException("not implemented");
+        //return null;
+	};
+
+	/**
+	 * This method must be provided by the vm vendor, as it is used by other
+	 * provided class implementations. For example,
+	 * java.io.ObjectInputStream.readObject() and
+	 * java.io.ObjectInputStream.resolveProxyClass(). It is also useful for
+	 * other classes, such as java.rmi.server.RMIClassLoader. Walk the stack and
+	 * answer the most recent non-null and non-bootstrap ClassLoader on the
+	 * stack of the calling thread. If no such ClassLoader is found, null is
+	 * returned. Notes: 1) This method operates on the defining classes of
+	 * methods on stack. NOT the classes of receivers.
+	 * 
+	 * @return the first non-bootstrap ClassLoader on the stack
+	 */
+	static public final ClassLoader getNonBootstrapClassLoader() {
+		throw new RuntimeException("not implemented");
+		//return null;
+	};
+
+	/**
+	 * Initialize the classloader.
+	 * 
+	 * @param loader
+	 *            ClassLoader the ClassLoader instance
+	 * @param bootLoader
+	 *            boolean true for the bootstrap class loader
+	 */
+	public final static void initializeClassLoader(ClassLoader loader,
+			boolean bootLoader) {
+		throw new RuntimeException("not implemented");
+		//return;
+	};
+	
+	/**
+	 * This method must be provided by the vm vendor.
+	 *
+	 * Searches an internal table of strings for a string equal to the specified String.
+	 * If the string is not in the table, it is added. Answers the string contained
+	 * in the table which is equal to the specified String. The same string object is always
+	 * answered for strings which are equal.
+	 *
+	 * @param string	the String to intern
+	 *
+	 * @return		the interned string equal to the specified String
+	 */
+	public static final String intern(String string) {
+		return string.intern();
+	}
+
+	/**
+	 * Native used to find and load a class using the VM
+	 * 
+	 * @return java.lang.Class the class or null.
+	 * @param className
+	 *            String the name of the class to search for.
+	 * @param classLoader
+	 *            the classloader to do the work
+	 */
+	static Class findClassOrNull(String className, ClassLoader classLoader) {
+		throw new RuntimeException("not implemented");
+		//return null;
+	};
+
+	/**
+	 * This method must be included, as it is used by
+	 * ResourceBundle.getBundle(), and other places as well. The reference
+	 * implementation of this method uses the getStackClassLoader() method.
+	 * Returns the ClassLoader of the method that called the caller. i.e. A.x()
+	 * calls B.y() calls callerClassLoader(), A's ClassLoader will be returned.
+	 * Returns null for the bootstrap ClassLoader.
+	 * 
+	 * @return a ClassLoader or null for the bootstrap ClassLoader
+	 * @throws SecurityException
+	 *             when called from a non-bootstrap Class
+	 */
+	public static ClassLoader callerClassLoader() {
+        Class[] classes = gnu.classpath.VMStackWalker.getClassContext();
+        return classes[2].getClassLoader();
+	}
+	
+	/**
+	 * This method must be provided by the vm vendor, as it is used
+	 * by org.apache.harmony.luni.util.MsgHelp.setLocale() to get the bootstrap
+	 * ClassLoader. MsgHelp uses the bootstrap ClassLoader to find the
+	 * resource bundle of messages packaged with the bootstrap classes.
+	 * The reference implementation of this method uses the getStackClassLoader()
+	 * method.
+	 *
+	 * Returns the ClassLoader of the method that called the caller.
+	 * i.e. A.x() calls B.y() calls callerClassLoader(),
+	 * A's ClassLoader will be returned. Returns null for the
+	 * bootstrap ClassLoader.
+	 *
+	 * @return 		a ClassLoader
+	 *
+	 * @throws SecurityException when called from a non-bootstrap Class
+	 */
+	public static ClassLoader bootCallerClassLoader() {
+        return BootstrapClassLoader.getBootstrapClassLoader();
+	}
+
+	/**
+	 * Native used to dump a string to the system console for debugging.
+	 * 
+	 * @param str
+	 *            String the String to display
+	 */
+	public static void dumpString(String str) {
+		return;
+	};
+
+	/**
+	 * Get the classpath entry that was used to load the class that is the arg.
+	 * <p>
+	 * This method is for internal use only.
+	 * 
+	 * @param targetClass
+	 *            Class the class to set the classpath of.
+	 * @see java.lang.Class
+	 */
+	static int getCPIndexImpl(Class targetClass) {
+		throw new RuntimeException("not implemented");
+		//return 0;
+	};
+
+	/**
+	 * Does internal initializaion required by VM.
+	 * 
+	 */
+	static void initializeVM() {
+		throw new RuntimeException("not implemented");
+	}
+
+	/**
+	 * Registers a new virtual-machine shutdown hook. This is equivalent to the
+	 * 1.3 API of the same name.
+	 * 
+	 * @param hook
+	 *            the hook (a Thread) to register
+	 */
+	public static void addShutdownHook(Thread hook) {
+		throw new RuntimeException("not implemented");
+		//return;
+	}
+
+	/**
+	 * De-registers a previously-registered virtual-machine shutdown hook. This
+	 * is equivalent to the 1.3 API of the same name.
+	 * 
+	 * @param hook
+	 *            the hook (a Thread) to de-register
+	 * @return true if the hook could be de-registered
+	 */
+	public static boolean removeShutdownHook(Thread hook) {
+		throw new RuntimeException("not implemented");
+		//return false;
+	}
+
+	/**
+	 * This method must be provided by the vm vendor. Called to signal that the
+	 * org.apache.harmony.luni.internal.net.www.protocol.jar.JarURLConnection class has been loaded
+	 * and JarURLConnection.closeCachedFiles() should be called on VM shutdown.
+	 */
+	public static void closeJars() {
+        // FIXME: not implemented
+		//throw new RuntimeException("not implemented");
+	}
+
+	/**
+	 * This method must be provided by the vm vendor. Called to signal that the
+	 * org.apache.harmony.luni.util.DeleteOnExit class has been loaded and
+	 * DeleteOnExit.deleteOnExit() should be called on VM shutdown.
+	 */
+	public static void deleteOnExit() {
+        System.err.println("VM.deleteOnExit - not implemented");
+	}
+
+	//Constants used by getClassPathEntryType to indicate the class path entry type
+	static final int CPE_TYPE_UNKNOWN = 0;
+
+	static final int CPE_TYPE_DIRECTORY = 1;
+
+	static final int CPE_TYPE_JAR = 2;
+
+	static final int CPE_TYPE_TCP = 3;
+
+	static final int CPE_TYPE_UNUSABLE = 5;
+
+	/**
+	 * Return the type of the specified entry on the class path for a ClassLoader.
+	 * Valid tyes are:
+	 * 		CPE_TYPE_UNKNOWN
+	 *		CPE_TYPE_DIRECTORY
+	 * 		CPE_TYPE_JAR
+	 *		CPE_TYPE_TCP - this is obsolete
+	 *		CPE_TYPE_UNUSABLE
+	 * 
+	 * @param classLoader the ClassLoader
+	 * @param cpIndex the index on the class path
+	 * 
+	 * @return a int which specifies the class path entry type
+	 */
+	static final int getClassPathEntryType(Object classLoader, int cpIndex) {
+		throw new RuntimeException("not implemented");
+		//return 0;
+	};
+
+	/**
+	 * Returns command line arguments passed to the VM. Internally these are
+	 * broken into optionString and extraInfo. This only returns the
+	 * optionString part.
+	 * <p>
+	 * 
+	 * @return a String array containing the optionString part of command line
+	 *         arguments
+	 */
+	public static String[] getVMArgs() {
+		throw new RuntimeException("not implemented");
+		//return null;
+	};
+
+	/**
+	 * Return the number of entries on the bootclasspath.
+	 * 
+	 * @return an int which is the number of entries on the bootclasspath
+	 */
+	static int getClassPathCount() {
+		throw new RuntimeException("not implemented");
+		//return 0;
+	};
+
+	/**
+	 * Return the specified bootclasspath entry.
+	 * 
+	 * @param index the index of the bootclasspath entry 
+	 * 
+	 * @return a byte array containing the bootclasspath entry
+	 * 			specified in the vm options
+	 */
+	static byte[] getPathFromClassPath(int index) {
+		throw new RuntimeException("not implemented");
+		//return null;
+	};
+	
+	/**
+	 * This method must be provided by the vm vendor.
+	 *
+	 * Returns an int containing the version number of the kernel. Used to check for kernel
+	 * compatibility.
+	 *
+	 * @return an int containing the kernel version number
+	 */
+	public static int getKernelVersion() {
+		throw new RuntimeException("not implemented");
+		//return kernelVersion;
+	}
+
+}

Added: incubator/harmony/enhanced/classlibadapter/trunk/vmi/java_lang_reflect_Array.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlibadapter/trunk/vmi/java_lang_reflect_Array.cpp?rev=411596&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/vmi/java_lang_reflect_Array.cpp (added)
+++ incubator/harmony/enhanced/classlibadapter/trunk/vmi/java_lang_reflect_Array.cpp Sun Jun  4 13:55:02 2006
@@ -0,0 +1,182 @@
+#include <jni.h>
+
+extern "C" {
+
+/*
+ * Class:     java_lang_reflect_Array
+ * Method:    newInstance
+ * Signature: (Ljava/lang/Class;I)Ljava/lang/Object;
+ */
+JNIEXPORT jobject JNICALL Java_java_lang_reflect_Array_newInstance__Ljava_lang_Class_2I
+  (JNIEnv *env, jclass, jclass cls, jint len) {
+    return env->NewObjectArray(len, cls, NULL);
+}
+
+/*
+ * Class:     java_lang_reflect_Array
+ * Method:    getLength
+ * Signature: (Ljava/lang/Object;)I
+ */
+JNIEXPORT jint JNICALL Java_java_lang_reflect_Array_getLength
+  (JNIEnv *env, jclass, jobject obj) {
+    return env->GetArrayLength((jarray) obj);
+}
+
+#if 0
+/*
+ * Class:     java_lang_reflect_Array
+ * Method:    get
+ * Signature: (Ljava/lang/Object;I)Ljava/lang/Object;
+ */
+JNIEXPORT jobject JNICALL Java_java_lang_reflect_Array_get
+  (JNIEnv *, jclass, jobject, jint);
+
+/*
+ * Class:     java_lang_reflect_Array
+ * Method:    getBoolean
+ * Signature: (Ljava/lang/Object;I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_lang_reflect_Array_getBoolean
+  (JNIEnv *, jclass, jobject, jint);
+
+/*
+ * Class:     java_lang_reflect_Array
+ * Method:    getByte
+ * Signature: (Ljava/lang/Object;I)B
+ */
+JNIEXPORT jbyte JNICALL Java_java_lang_reflect_Array_getByte
+  (JNIEnv *, jclass, jobject, jint);
+
+/*
+ * Class:     java_lang_reflect_Array
+ * Method:    getChar
+ * Signature: (Ljava/lang/Object;I)C
+ */
+JNIEXPORT jchar JNICALL Java_java_lang_reflect_Array_getChar
+  (JNIEnv *, jclass, jobject, jint);
+
+/*
+ * Class:     java_lang_reflect_Array
+ * Method:    getDouble
+ * Signature: (Ljava/lang/Object;I)D
+ */
+JNIEXPORT jdouble JNICALL Java_java_lang_reflect_Array_getDouble
+  (JNIEnv *, jclass, jobject, jint);
+
+/*
+ * Class:     java_lang_reflect_Array
+ * Method:    getFloat
+ * Signature: (Ljava/lang/Object;I)F
+ */
+JNIEXPORT jfloat JNICALL Java_java_lang_reflect_Array_getFloat
+  (JNIEnv *, jclass, jobject, jint);
+
+/*
+ * Class:     java_lang_reflect_Array
+ * Method:    getInt
+ * Signature: (Ljava/lang/Object;I)I
+ */
+JNIEXPORT jint JNICALL Java_java_lang_reflect_Array_getInt
+  (JNIEnv *, jclass, jobject, jint);
+
+
+/*
+ * Class:     java_lang_reflect_Array
+ * Method:    getLong
+ * Signature: (Ljava/lang/Object;I)J
+ */
+JNIEXPORT jlong JNICALL Java_java_lang_reflect_Array_getLong
+  (JNIEnv *, jclass, jobject, jint);
+
+/*
+ * Class:     java_lang_reflect_Array
+ * Method:    getShort
+ * Signature: (Ljava/lang/Object;I)S
+ */
+JNIEXPORT jshort JNICALL Java_java_lang_reflect_Array_getShort
+  (JNIEnv *, jclass, jobject, jint);
+
+/*
+ * Class:     java_lang_reflect_Array
+ * Method:    newInstance
+ * Signature: (Ljava/lang/Class;[I)Ljava/lang/Object;
+ */
+JNIEXPORT jobject JNICALL Java_java_lang_reflect_Array_newInstance__Ljava_lang_Class_2_3I
+  (JNIEnv *, jclass, jclass, jintArray);
+
+
+/*
+ * Class:     java_lang_reflect_Array
+ * Method:    set
+ * Signature: (Ljava/lang/Object;ILjava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_set
+  (JNIEnv *, jclass, jobject, jint, jobject);
+
+/*
+ * Class:     java_lang_reflect_Array
+ * Method:    setBoolean
+ * Signature: (Ljava/lang/Object;IZ)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_setBoolean
+  (JNIEnv *, jclass, jobject, jint, jboolean);
+
+/*
+ * Class:     java_lang_reflect_Array
+ * Method:    setByte
+ * Signature: (Ljava/lang/Object;IB)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_setByte
+  (JNIEnv *, jclass, jobject, jint, jbyte);
+
+/*
+ * Class:     java_lang_reflect_Array
+ * Method:    setChar
+ * Signature: (Ljava/lang/Object;IC)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_setChar
+  (JNIEnv *, jclass, jobject, jint, jchar);
+
+/*
+ * Class:     java_lang_reflect_Array
+ * Method:    setDouble
+ * Signature: (Ljava/lang/Object;ID)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_setDouble
+  (JNIEnv *, jclass, jobject, jint, jdouble);
+
+/*
+ * Class:     java_lang_reflect_Array
+ * Method:    setFloat
+ * Signature: (Ljava/lang/Object;IF)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_setFloat
+  (JNIEnv *, jclass, jobject, jint, jfloat);
+
+/*
+ * Class:     java_lang_reflect_Array
+ * Method:    setInt
+ * Signature: (Ljava/lang/Object;II)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_setInt
+  (JNIEnv *, jclass, jobject, jint, jint);
+
+/*
+ * Class:     java_lang_reflect_Array
+ * Method:    setLong
+ * Signature: (Ljava/lang/Object;IJ)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_setLong
+  (JNIEnv *, jclass, jobject, jint, jlong);
+
+/*
+ * Class:     java_lang_reflect_Array
+ * Method:    setShort
+ * Signature: (Ljava/lang/Object;IS)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_setShort
+  (JNIEnv *, jclass, jobject, jint, jshort);
+#endif
+
+}
+

Added: incubator/harmony/enhanced/classlibadapter/trunk/vmi/libvmi.exp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlibadapter/trunk/vmi/libvmi.exp?rev=411596&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/vmi/libvmi.exp (added)
+++ incubator/harmony/enhanced/classlibadapter/trunk/vmi/libvmi.exp Sun Jun  4 13:55:02 2006
@@ -0,0 +1,6 @@
+VMI_0.1 {
+	global :
+		VMI_GetVMIFromJavaVM;
+		VMI_GetVMIFromJNIEnv;
+	local : *;
+};

Added: incubator/harmony/enhanced/classlibadapter/trunk/vmi/vmi.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlibadapter/trunk/vmi/vmi.cpp?rev=411596&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/vmi/vmi.cpp (added)
+++ incubator/harmony/enhanced/classlibadapter/trunk/vmi/vmi.cpp Sun Jun  4 13:55:02 2006
@@ -0,0 +1,297 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Euguene Ostrovsky
+ * @version $Revision: 1.1.2.1.4.5 $
+ */  
+#include <assert.h>
+
+#include "vmi.h"
+#include <stdarg.h>
+#include <malloc.h>
+#include <string.h>
+#include <sys/time.h>
+
+extern VMInterfaceFunctions_ vmi_impl;
+
+VMInterface vmi = &vmi_impl;
+
+struct VM {
+    VMInterface vmi;
+    JNIEnv *jni_env;
+    JavaVM *vm;
+} vm_info;
+
+HyPortLibrary portLib;
+HyPortLibrary* portLibPointer = NULL;
+HyZipCachePool* zipCachePool = NULL;
+
+VMInterface* JNICALL 
+VMI_GetVMIFromJNIEnv(JNIEnv *env) 
+{
+    vm_info.vmi = &vmi_impl;
+    vm_info.jni_env = env;
+    return (VMInterface*)&vm_info;
+}
+
+VMInterface* JNICALL 
+VMI_GetVMIFromJavaVM(JavaVM *vm) 
+{
+    vm_info.vmi = &vmi_impl;
+    vm_info.vm = vm;
+    return (VMInterface*)&vm_info;
+}
+
+//////////////////////////////////////
+//  VMI structure member functions  //
+//////////////////////////////////////
+
+vmiError JNICALL CheckVersion(VMInterface *vmi, vmiVersion *version)
+{
+    assert(/* vmi.dll:  unimplemented. */0);
+    return VMI_ERROR_UNIMPLEMENTED;
+}
+
+JavaVM *JNICALL GetJavaVM(VMInterface *vmi)
+{
+    assert(/* vmi.dll:  unimplemented. */0);
+    return NULL;
+}
+
+//#ifdef __cplusplus
+//extern "C" {
+//#endif
+//JNIEXPORT int j9port_allocate_library(void *version, J9PortLibrary **portLibrary);
+//#ifdef __cplusplus
+//}
+//#endif
+ 
+HyPortLibrary *JNICALL GetPortLibrary(VMInterface *vmi)
+{
+    static int initialized = 0;
+
+    if (! initialized)
+    {
+        int rc;
+        HyPortLibraryVersion portLibraryVersion;
+        HYPORT_SET_VERSION(&portLibraryVersion, HYPORT_CAPABILITY_MASK);
+
+        rc = hyport_init_library(&portLib, &portLibraryVersion, 
+                sizeof(HyPortLibrary));
+
+        if (0 != rc) return NULL;
+
+        initialized = 1;
+
+    // FIXME: portlib is used in VMI_zipCachePool - we need to
+    //        know there is portLib is initialized there already.
+    portLibPointer = &portLib;
+    }
+    return &portLib;
+}
+
+
+
+
+UDATA JNICALL HYVMLSAllocKeys(JNIEnv *env, UDATA *pInitCount,...) {
+    //fprintf(stderr, "HYVMLSAllocKeys\n");
+    return 0;
+}
+
+void JNICALL HYVMLSFreeKeys(JNIEnv *env, UDATA *pInitCount,...) {
+    //fprintf(stderr, "HYVMLSFreeKeys - not implemented\n");
+}
+
+char somedata[1024];
+
+void* JNICALL HYVMLSGet(JNIEnv *env, void *key) {
+    //fprintf(stderr, "HYVMLSGet[%p] =", key);
+    //fprintf(stderr, " %p\n", res);
+    return key;
+}
+void* JNICALL HYVMLSSet(JNIEnv *env, void **pKey, void *value) {
+    //fprintf(stderr, "HYVMLSSet[%p] %p\n", pKey, value);
+    *pKey = value;
+    return 0;
+}
+
+
+HyVMLSFunctionTable vmls_inst = {
+    &HYVMLSAllocKeys,
+    &HYVMLSFreeKeys,
+    &HYVMLSGet,
+    &HYVMLSSet
+};
+
+/*
+ * Returns a pointer to Local Storage Function Table. 
+ */
+HyVMLSFunctionTable* JNICALL 
+GetVMLSFunctions(VMInterface *vmi)
+{
+    //fprintf(stderr, "GetVMLSFunctions\n");
+    HyVMLSFunctionTable *pl = &vmls_inst;
+    return pl;
+}
+
+HyZipCachePool* JNICALL GetZipCachePool(VMInterface *vmi)
+{
+    // FIXME: thread unsafe implementation...
+    if (zipCachePool != NULL)
+    {
+        return zipCachePool;
+    }
+    assert(portLibPointer);
+    zipCachePool = zipCachePool_new(&portLib);
+    assert(zipCachePool);
+    return zipCachePool;
+}
+
+JavaVMInitArgs* JNICALL GetInitArgs(VMInterface *vmi)
+{
+    JavaVMInitArgs *args = (JavaVMInitArgs*) malloc(sizeof(JavaVMInitArgs));
+    args->version = JNI_VERSION_1_2;
+	args->nOptions = 0;
+	args->options = 0;
+	args->ignoreUnrecognized = TRUE;
+    fprintf(stderr, "GetInitArgs\n");
+    return args;
+}
+
+vmiError JNICALL 
+GetSystemProperty(VMInterface *vmi, char *key, char **valuePtr)
+{
+    fprintf(stderr, "GetSystemProperty: %s\n", key);
+    VM *vm = (VM*)vmi;
+    JNIEnv *e = vm->jni_env;
+    *valuePtr = NULL;
+
+    if (key == NULL) return VMI_ERROR_NONE;
+
+    jstring str = e->NewStringUTF(key);
+    if (!str) return VMI_ERROR_OUT_OF_MEMORY;
+
+    jclass system = e->FindClass("java/lang/System");
+    if (!system) {
+        fprintf(stderr, "VMI Failed to find class java/lang/System\n");
+        e->ExceptionDescribe();
+        return VMI_ERROR_UNKNOWN;
+    }
+
+    jmethodID getProperty = e->GetStaticMethodID(system, "getProperty",
+            "(Ljava/lang/String;)Ljava/lang/String;");
+    if (!getProperty) return VMI_ERROR_UNKNOWN;
+
+    jstring prop = (jstring) e->CallStaticObjectMethod(system, getProperty, str);
+    if (e->ExceptionOccurred()) return VMI_ERROR_UNKNOWN;
+    if (!prop) return VMI_ERROR_NONE;
+
+    int len = e->GetStringUTFLength(prop);
+    char *res = (char*) malloc(len + 1);
+    if (!res) return VMI_ERROR_OUT_OF_MEMORY;
+
+    jboolean copy;
+    const char *chars = e->GetStringUTFChars(prop, &copy);
+    if (!chars) return VMI_ERROR_OUT_OF_MEMORY;
+    memcpy(res, chars, len);
+    res[len] = 0;
+    e->ReleaseStringUTFChars(prop, chars);
+
+    fprintf(stderr, "%s = %s\n", key, res);
+    *valuePtr = res;
+    return VMI_ERROR_NONE;
+}
+
+vmiError JNICALL
+SetSystemProperty(VMInterface *vmi, char *key, char *value)
+{
+    fprintf(stderr, "SetSystemProperty: %s = %s\n", key, value);
+    return VMI_ERROR_NONE;
+}
+
+vmiError JNICALL CountSystemProperties(VMInterface *vmi, int *countPtr)
+{
+    *countPtr = 0;
+    fprintf(stderr, "CountSystemProperties\n");
+    return VMI_ERROR_NONE;
+}
+
+vmiError JNICALL IterateSystemProperties(VMInterface *vmi,
+        vmiSystemPropertyIterator iterator, void *userData)
+{
+    fprintf(stderr, "IterateSystemProperties\n");
+    return VMI_ERROR_NONE;
+}
+
+VMInterfaceFunctions_ vmi_impl = {
+    &CheckVersion,
+    &GetJavaVM,
+    &GetPortLibrary,
+    &GetVMLSFunctions,
+    &GetZipCachePool,
+    &GetInitArgs,
+    &GetSystemProperty,
+    &SetSystemProperty,
+    &CountSystemProperties,
+    &IterateSystemProperties,
+};
+
+
+extern "C" {
+    /*
+     * Class:     java_lang_System
+     * Method:    getcwd
+     * Signature: ()Ljava/lang/String;
+     */
+    JNIEXPORT jstring JNICALL Java_java_lang_System_getcwd
+        (JNIEnv *env, jclass)
+    {
+        int len = 128;
+        while (true) {
+            char *buf = (char*) malloc(len);
+            if (getcwd(buf, len) != NULL) {
+                jstring str = env->NewStringUTF(buf);
+                free(buf);
+                return str;
+            }
+            free(buf);
+            len *= 2;
+        }
+    }
+
+    /*
+     *  * Class:     java_lang_System
+     *   * Method:    currentTimeMillis
+     *    * Signature: ()J
+     *     */
+    JNIEXPORT jlong JNICALL Java_java_lang_System_currentTimeMillis
+        (JNIEnv *, jclass)
+    {
+        struct timeval tv;
+        gettimeofday(&tv, NULL);
+        return tv.tv_sec * (jlong)1000 + tv.tv_usec / 1000;
+    }
+
+    JNIEXPORT void JNICALL Java_java_lang_VMThread_attach
+        (JNIEnv *env, jobject) {
+        hythread_attach(NULL);
+    }
+
+    JNIEXPORT void JNICALL Java_java_lang_VMThread_destroy
+        (JNIEnv *env, jobject) {
+        hythread_detach(NULL);
+    }
+}