harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arc...@apache.org
Subject svn commit: r332571 - in /incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm: ./ etc/ libjc/ libjc/native/
Date Fri, 11 Nov 2005 14:42:35 GMT
Author: archie
Date: Fri Nov 11 06:42:20 2005
New Revision: 332571

URL: http://svn.apache.org/viewcvs?rev=332571&view=rev
Log:
Synchronize with recent changes to JCVM, aligning with release 1.4.7.
The main change is an update to Classpath 0.19 and elimination of most
(but not all) of the modified versions of Classpath files.

Modified:
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/CHANGES
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/INSTALL
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/configure.in
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/etc/regen.sh
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/bootstrap.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/class_loader.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/gc_scan.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/inline.h
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/jni_native.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/libjc.h
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/load.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/gnu_classpath_VMStackWalker.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_io_VMObjectStreamClass.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_VMClass.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_VMClassLoader.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_VMCompiler.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_VMThread.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/org_dellroad_jc_vm_DebugThread.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/reflect.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/structures.h
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/thread.c

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/CHANGES
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/CHANGES?rev=332571&r1=332570&r2=332571&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/CHANGES (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/CHANGES Fri Nov 11 06:42:20 2005
@@ -1,3 +1,8 @@
+Changes in version 1.4.7:
+
+    - Fixed potential assertion failure in VMStackWalker.getClassContext().
+    - Upgrade to Classpath 0.19.
+
 Changes in version 1.4.6:
 
     - Added new command line flags -Xrnd, -Xnoln, and -Xobj.
@@ -192,4 +197,4 @@
     - Allow Thread.setDaemon() to work setting even if thread is dead.
     - Fix race condition around method lookup table access.
 
-$Id: CHANGES,v 1.61 2005/07/23 15:31:05 archiecobbs Exp $
+$Id: CHANGES,v 1.63 2005/11/09 18:17:14 archiecobbs Exp $

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/INSTALL
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/INSTALL?rev=332571&r1=332570&r2=332571&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/INSTALL (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/INSTALL Fri Nov 11 06:42:20 2005
@@ -24,9 +24,9 @@
     Another "Java 2" compatible JVM installed, such as Sun's JDK,
     kaffe, SableVM, etc. This is needed during installation only.
 
-1. Install classpath-0.17. You can get it from
+1. Install classpath-0.19. You can get it from
 
-	ftp://ftp.gnu.org/pub/gnu/classpath/classpath-0.17.tar.gz
+	ftp://ftp.gnu.org/pub/gnu/classpath/classpath-0.19.tar.gz
 	FreeBSD: java/classpath
 	Debian: classpath
 
@@ -82,7 +82,7 @@
    any Classpath classes that differ will cause the corresponding
    C source files to be invalid, and such files will be automatically
    regenerated during the install process. The pre-generated source
-   files correspond to Classpath 0.17, configured with "--with-jikes
+   files correspond to Classpath 0.19, configured with "--with-jikes
    --prefix=/usr/local", and compiled by jikes 1.22.
 
    If you are using a different version of Classpath, built the
@@ -116,4 +116,4 @@
 2. See http://jcvm.sourceforge.net/share/jc/doc/jc.html#Running%20JC
    for tips on optimizing JC's performance.
 
-$Id: INSTALL,v 1.26 2005/07/23 15:31:05 archiecobbs Exp $
+$Id: INSTALL,v 1.27 2005/11/09 18:14:21 archiecobbs Exp $

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/configure.in
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/configure.in?rev=332571&r1=332570&r2=332571&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/configure.in (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/configure.in Fri Nov 11 06:42:20 2005
@@ -1,11 +1,11 @@
-# $Id: configure.in,v 1.56 2005/07/23 15:31:05 archiecobbs Exp $
+# $Id: configure.in,v 1.58 2005/11/09 18:17:14 archiecobbs Exp $
 
-AC_INIT([JC Virtual Machine], [1.4.6], [http://sourceforge.net/projects/jcvm], [jc])
+AC_INIT([JC Virtual Machine], [1.4.7], [http://sourceforge.net/projects/jcvm], [jc])
 AC_CONFIG_AUX_DIR(scripts)
 AM_INIT_AUTOMAKE
 dnl AM_MAINTAINER_MODE
 AC_PREREQ(2.57)
-AC_REVISION($Id: configure.in,v 1.56 2005/07/23 15:31:05 archiecobbs Exp $)
+AC_REVISION($Id: configure.in,v 1.58 2005/11/09 18:17:14 archiecobbs Exp $)
 AC_PREFIX_DEFAULT(/usr/local)
 AC_CONFIG_SRCDIR(libjc/libjc.h)
 AC_PROG_MAKE_SET
@@ -15,7 +15,7 @@
 AC_SUBST(SOOT_VERSION, [2.1.0])
 AC_SUBST(JASMIN_VERSION, [1.2])
 AC_SUBST(POLYGLOT_VERSION, [1.1.0])
-AC_SUBST(CLASSPATH_VERSION, [0.17])
+AC_SUBST(CLASSPATH_VERSION, [0.19])
 
 [JC_CFLAGS='-g -O3 -pipe -Wall -Waggregate-return -Wcast-align -Wchar-subscripts -Wcomment -Wformat -Wimplicit -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-long-long -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wswitch -Wtrigraphs -Wuninitialized -Wunused -Wwrite-strings']
 AC_SUBST(JC_CFLAGS)

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/etc/regen.sh
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/etc/regen.sh?rev=332571&r1=332570&r2=332571&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/etc/regen.sh (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/etc/regen.sh Fri Nov 11 06:42:20 2005
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $Id: regen.sh,v 1.7 2005/03/26 03:25:44 archiecobbs Exp $
+# $Id: regen.sh,v 1.8 2005/11/09 18:14:21 archiecobbs Exp $
 
 #
 # Script to regenerate all the GNU auto* gunk.
@@ -61,5 +61,5 @@
 	export CPPFLAGS=-I/usr/local/include;
 fi
 
-./configure --enable-werror --enable-assertions
+./configure --enable-werror --enable-assertions --with-classpath=/usr/local/classpath
 

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/bootstrap.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/bootstrap.c?rev=332571&r1=332570&r2=332571&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/bootstrap.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/bootstrap.c Fri Nov 11 06:42:20 2005
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: bootstrap.c,v 1.16 2005/03/26 23:20:19 archiecobbs Exp $
+ * $Id: bootstrap.c,v 1.17 2005/11/09 18:14:22 archiecobbs Exp $
  */
 
 #include "libjc.h"
@@ -165,7 +165,7 @@
 	RESOLVE_FIELD(Throwable, cause, "Ljava/lang/Throwable;", 0);
 	RESOLVE_FIELD(Throwable, detailMessage, "Ljava/lang/String;", 0);
 	RESOLVE_FIELD(Throwable, vmState, "Ljava/lang/VMThrowable;", 0);
-	RESOLVE_FIELD(VMThrowable, vmdata, "[B", 0);
+	RESOLVE_FIELD(VMThrowable, vmdata, "Ljava/lang/Object;", 0);
 	for (i = 0; i < _JC_VMEXCEPTION_MAX; i++)
 		BOOTSTRAP_TYPE(_jc_vmex_names[i], vmex[i]);
 
@@ -178,7 +178,7 @@
 
 	/* Load more special classes */
 	BOOTSTRAP_TYPE(long_ptr ?
-	    "gnu/classpath/RawData64" : "gnu/classpath/RawData32", RawData);
+	    "gnu/classpath/Pointer64" : "gnu/classpath/Pointer32", Pointer);
 	BOOTSTRAP_TYPE("gnu/classpath/VMStackWalker", VMStackWalker);
 	BOOTSTRAP_TYPE("java/lang/Error", Error);
 	BOOTSTRAP_TYPE("java/lang/ClassLoader", ClassLoader);
@@ -196,7 +196,7 @@
 	BOOTSTRAP_TYPE("java/lang/reflect/Field", Field);
 	BOOTSTRAP_TYPE("java/lang/reflect/Method", Method);
 	BOOTSTRAP_TYPE("java/nio/Buffer", Buffer);
-	BOOTSTRAP_TYPE("java/nio/DirectByteBufferImpl", DirectByteBufferImpl);
+	BOOTSTRAP_TYPE("java/nio/DirectByteBufferImpl$ReadWrite", ReadWrite);
 	BOOTSTRAP_TYPE("[Ljava/lang/Class;", Class_array);
 	BOOTSTRAP_TYPE("[Ljava/lang/StackTraceElement;",
 	    StackTraceElement_array);
@@ -212,8 +212,8 @@
 	RESOLVE_CONSTRUCTOR(StackTraceElement,
 	    "(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Z)V");
 	RESOLVE_CONSTRUCTOR(Constructor, "(Ljava/lang/Class;I)V");
-	RESOLVE_CONSTRUCTOR(DirectByteBufferImpl,
-	    "(Ljava/lang/Object;Lgnu/classpath/RawData;III)V");
+	RESOLVE_CONSTRUCTOR(ReadWrite,
+	    "(Ljava/lang/Object;Lgnu/classpath/Pointer;III)V");
 	RESOLVE_CONSTRUCTOR(Field, "(Ljava/lang/Class;Ljava/lang/String;I)V");
 	RESOLVE_CONSTRUCTOR(Method, "(Ljava/lang/Class;Ljava/lang/String;I)V");
 	RESOLVE_CONSTRUCTOR(String, "([C)V");
@@ -281,17 +281,17 @@
 	}
 
 	/* Find special fields */
-	RESOLVE_FIELD(Buffer, address, "Lgnu/classpath/RawData;", 0);
+	RESOLVE_FIELD(Buffer, address, "Lgnu/classpath/Pointer;", 0);
 	RESOLVE_FIELD(Buffer, cap, "I", 0);
 	RESOLVE_FIELD(ClassLoader, parent, "Ljava/lang/ClassLoader;", 0);
-	RESOLVE_FIELD(ClassLoader, vmdata, "J", 0);
+	RESOLVE_FIELD(ClassLoader, vmdata, "Ljava/lang/Object;", 0);
 	RESOLVE_FIELD(Constructor, clazz, "Ljava/lang/Class;", 0);
 	RESOLVE_FIELD(Constructor, slot, "I", 0);
 	RESOLVE_FIELD(Field, declaringClass, "Ljava/lang/Class;", 0);
 	RESOLVE_FIELD(Field, slot, "I", 0);
 	RESOLVE_FIELD(Method, declaringClass, "Ljava/lang/Class;", 0);
 	RESOLVE_FIELD(Method, slot, "I", 0);
-	RESOLVE_FIELD(RawData, data, long_ptr ? "J" : "I", 0);
+	RESOLVE_FIELD(Pointer, data, long_ptr ? "J" : "I", 0);
 	RESOLVE_FIELD(Reference, referent, "Ljava/lang/Object;", 0);
 	RESOLVE_FIELD(Reference, queue, "Ljava/lang/ref/ReferenceQueue;", 0);
 	RESOLVE_FIELD(String, value, "[C", 0);
@@ -307,16 +307,18 @@
 	RESOLVE_FIELD(Thread, vmThread, "Ljava/lang/VMThread;", 0);
 	RESOLVE_FIELD(ThreadGroup, root, "Ljava/lang/ThreadGroup;", 1);
 	RESOLVE_FIELD(VMThread, thread, "Ljava/lang/Thread;", 0);
-	RESOLVE_FIELD(VMThread, vmdata, "J", 0);
+	RESOLVE_FIELD(VMThread, vmdata, "Ljava/lang/Object;", 0);
 
 	/* Load java.lang.Class */
 	BOOTSTRAP_TYPE("java/lang/Class", Class);
-	RESOLVE_FIELD(Class, vmdata, "J", 0);
+	RESOLVE_FIELD(Class, vmdata, "Ljava/lang/Object;", 0);
 	RESOLVE_FIELD(Class, pd, "Ljava/security/ProtectionDomain;", 0);
 
-	/* Set initial lockwords for Object and Class */
+	/* Set initial lockwords for Object, Class, and Pointer */
 	_jc_initialize_lockword(env, vm->boot.types.Object, NULL);
 	_jc_initialize_lockword(env, vm->boot.types.Class,
+	    vm->boot.types.Object);
+	_jc_initialize_lockword(env, vm->boot.types.Pointer,
 	    vm->boot.types.Object);
 
 	/*

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/class_loader.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/class_loader.c?rev=332571&r1=332570&r2=332571&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/class_loader.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/class_loader.c Fri Nov 11 06:42:20 2005
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: class_loader.c,v 1.12 2005/03/16 15:31:11 archiecobbs Exp $
+ * $Id: class_loader.c,v 1.13 2005/11/09 18:14:22 archiecobbs Exp $
  */
 
 #include "libjc.h"
@@ -47,7 +47,7 @@
 	vm_locked = JNI_TRUE;
 
 	/* See if loader structure already exists */
-	if ((loader = _jc_get_vm_pointer(obj,
+	if ((loader = _jc_get_vm_pointer(vm, obj,
 	    vm->boot.fields.ClassLoader.vmdata)) != NULL)
 		goto done;
 
@@ -59,7 +59,11 @@
 	loader->instance = obj;
 
 	/* Set the ClassLoader.vmdata field */
-	_jc_set_vm_pointer(obj, vm->boot.fields.ClassLoader.vmdata, loader);
+	if (_jc_set_vm_pointer(env, obj,
+	    vm->boot.fields.ClassLoader.vmdata, loader) != JNI_OK) {
+	    	_jc_destroy_loader(vm, &loader);
+	    	goto done;
+	}
 
 	/* Unlock VM */
 	_JC_MUTEX_UNLOCK(env, vm->mutex);

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/gc_scan.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/gc_scan.c?rev=332571&r1=332570&r2=332571&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/gc_scan.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/gc_scan.c Fri Nov 11 06:42:20 2005
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: gc_scan.c,v 1.17 2005/03/20 23:06:10 archiecobbs Exp $
+ * $Id: gc_scan.c,v 1.18 2005/11/09 18:14:22 archiecobbs Exp $
  */
 
 #include "libjc.h"
@@ -668,8 +668,7 @@
 			_JC_ASSERT(!_JC_IN_HEAP(&vm->heap, obj));
 
 			/* Get class associated with this Class object */
-			type = _jc_get_vm_pointer(obj,
-			    vm->boot.fields.Class.vmdata);
+			type = *_JC_VMFIELD(vm, obj, Class, vmdata, _jc_type *);
 
 			/* Handle class' class loader */
 			if (!(loader = type->loader)->gc_mark)
@@ -808,8 +807,8 @@
 			_jc_class_loader *cl_loader;
 
 			/* Get ClassLoader loader and normal object loader */
-			cl_loader = _jc_get_vm_pointer(obj,
-			    vm->boot.fields.ClassLoader.vmdata);
+			cl_loader = _jc_get_vm_pointer(vm,
+			    obj, vm->boot.fields.ClassLoader.vmdata);
 			loader = obj->type->loader;
 
 			/* Do both class loaders */
@@ -930,10 +929,15 @@
 {
 	_jc_jvm *const vm = env->vm;
 	int num_class_fields;
+	int vmdata_index;
 	int len = 0;
 	int i;
 	int j;
 
+	/* Get index of Class.vmdata so we can ignore it */
+	vmdata_index = vm->boot.fields.Class.vmdata->offset
+	    / (int)sizeof(_jc_word);
+
 	/* Get number of reference fields in a java.lang.Class object */
 	num_class_fields = vm->boot.types.Class->u.nonarray.num_virtual_refs;
 
@@ -946,8 +950,15 @@
 			_jc_object *const ref
 			    = ((_jc_object **)type->instance)[j];
 
+			/* Ignore null pointers */
 			if (ref == NULL)
 				continue;
+
+			/* Ignore Class.vmdata which is a native pointer! */
+			if (j == vmdata_index)
+				continue;
+
+			/* Add reference to the list */
 			if (list != NULL)
 				list[len] = ref;
 			len++;

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/inline.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/inline.h?rev=332571&r1=332570&r2=332571&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/inline.h (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/inline.h Fri Nov 11 06:42:20 2005
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: inline.h,v 1.6 2005/02/27 04:52:59 archiecobbs Exp $
+ * $Id: inline.h,v 1.7 2005/11/09 18:14:22 archiecobbs Exp $
  */
 
 /*
@@ -179,55 +179,5 @@
 		}
 	}
 	return nrefs;
-}
-
-/*
- * Extract a pointer from an object field of type long.
- * If the field is null then NULL is returned.
- */
-static inline void *
-_jc_get_vm_pointer(_jc_object *obj, _jc_field *field)
-{
-	/* Sanity check */
-	_JC_ASSERT(obj != NULL && field != NULL);
-	_JC_ASSERT(_jc_subclass_of(obj, field->class));
-	_JC_ASSERT(_jc_sig_types[(u_char)*field->signature] == _JC_TYPE_LONG);
-
-	/* Extract pointer from field */
-	return *((void **)((char *)obj + field->offset));
-}
-
-/*
- * Store a pointer into an object field of type long.
- */
-static inline void
-_jc_set_vm_pointer(_jc_object *obj, _jc_field *field, void *ptr)
-{
-	/* Sanity check */
-	_JC_ASSERT(obj != NULL && field != NULL);
-	_JC_ASSERT(_jc_subclass_of(obj, field->class));
-	_JC_ASSERT(_jc_sig_types[(u_char)*field->signature] == _JC_TYPE_LONG);
-
-	/* Copy the pointer into the field */
-	*((void **)((char *)obj + field->offset)) = ptr;
-}
- 
-/*
- * Store a pointer into an object field of type long atomically.
- */
-static inline jboolean
-_jc_vm_pointer_cas(_jc_object *obj, _jc_field *field,
-	void *oldptr, void *newptr)
-{
-	volatile _jc_word *const word
-	    = (_jc_word *)((char *)obj + field->offset);
-
-	/* Sanity check */
-	_JC_ASSERT(obj != NULL && field != NULL);
-	_JC_ASSERT(_jc_subclass_of(obj, field->class));
-	_JC_ASSERT(_jc_sig_types[(u_char)*field->signature] == _JC_TYPE_LONG);
-
-	/* Atomically update field */
-	return _jc_compare_and_swap(word, (_jc_word)oldptr, (_jc_word)newptr);
 }
 

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/jni_native.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/jni_native.c?rev=332571&r1=332570&r2=332571&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/jni_native.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/jni_native.c Fri Nov 11 06:42:20 2005
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: jni_native.c,v 1.15 2005/05/19 22:52:00 archiecobbs Exp $
+ * $Id: jni_native.c,v 1.16 2005/11/09 18:14:22 archiecobbs Exp $
  */
 
 #include "libjc.h"
@@ -181,7 +181,7 @@
 	_JC_ASSERT((*class)->type == vm->boot.types.Class);
 
 	/* Get class type */
-	type = _jc_get_vm_pointer(*class, vm->boot.fields.Class.vmdata);
+	type = *_JC_VMFIELD(vm, *class, Class, vmdata, _jc_type *);
 
 	/* Sanity check */
 	_JC_ASSERT(type == field->class);
@@ -214,7 +214,7 @@
 	_JC_ASSERT((*class)->type == vm->boot.types.Class);		\
 									\
 	/* Get class type */						\
-	type = _jc_get_vm_pointer(*class, vm->boot.fields.Class.vmdata);\
+	type = *_JC_VMFIELD(vm, *class, Class, vmdata, _jc_type *);	\
 									\
 	/* Sanity check */						\
 	_JC_ASSERT(type == field->class);				\
@@ -253,7 +253,7 @@
 	_JC_ASSERT(value == NULL || *value != NULL);
 
 	/* Get class type */
-	type = _jc_get_vm_pointer(*class, vm->boot.fields.Class.vmdata);
+	type = *_JC_VMFIELD(vm, *class, Class, vmdata, _jc_type *);
 
 	/* Sanity check */
 	_JC_ASSERT(type == field->class);
@@ -282,7 +282,7 @@
 	_JC_ASSERT((*class)->type == vm->boot.types.Class);		\
 									\
 	/* Get class type */						\
-	type = _jc_get_vm_pointer(*class, vm->boot.fields.Class.vmdata);\
+	type = *_JC_VMFIELD(vm, *class, Class, vmdata, _jc_type *);	\
 									\
 	/* Sanity check */						\
 	_JC_ASSERT(type == field->class);				\
@@ -743,7 +743,7 @@
 	_jc_push_stack_local_native_frame(env, &frame);
 
 	/* Get class info */
-	type = _jc_get_vm_pointer(*class, vm->boot.fields.Class.vmdata);
+	type = *_JC_VMFIELD(vm, *class, Class, vmdata, _jc_type *);
 
 	/* Initialize class */
 	if (_jc_initialize_type(env, type) != JNI_OK)
@@ -792,7 +792,7 @@
 	_jc_push_stack_local_native_frame(env, &frame);
 
 	/* Get class info */
-	type = _jc_get_vm_pointer(*class, vm->boot.fields.Class.vmdata);
+	type = *_JC_VMFIELD(vm, *class, Class, vmdata, _jc_type *);
 
 	/* Initialize class */
 	if (_jc_initialize_type(env, type) != JNI_OK)
@@ -1531,7 +1531,7 @@
 	_JC_ASSERT(class_obj->type == vm->boot.types.Class);
 
 	/* Get class type */
-	type = _jc_get_vm_pointer(class_obj, vm->boot.fields.Class.vmdata);
+	type = *_JC_VMFIELD(vm, class_obj, Class, vmdata, _jc_type *);
 
 	/* Primitive types have no superclass */
 	if ((type->flags & _JC_TYPE_MASK) != _JC_TYPE_REFERENCE)
@@ -1580,9 +1580,8 @@
 	    && (*to_class)->type == vm->boot.types.Class);
 
 	/* Get class types */
-	from_type = _jc_get_vm_pointer(*from_class,
-	    vm->boot.fields.Class.vmdata);
-	to_type = _jc_get_vm_pointer(*to_class, vm->boot.fields.Class.vmdata);
+	from_type = *_JC_VMFIELD(vm, *from_class, Class, vmdata, _jc_type *);
+	to_type = *_JC_VMFIELD(vm, *to_class, Class, vmdata, _jc_type *);
 
 	/* Check if assignable to */
 	result = _jc_assignable_from(env, from_type, to_type);
@@ -1621,7 +1620,7 @@
 	_JC_ASSERT((*class)->type == vm->boot.types.Class);
 
 	/* Get class type */
-	type = _jc_get_vm_pointer(*class, vm->boot.fields.Class.vmdata);
+	type = *_JC_VMFIELD(vm, *class, Class, vmdata, _jc_type *);
 
 	/* Check if instance of */
 	result = _jc_instance_of(env, obj, type);
@@ -1753,7 +1752,7 @@
 	_jc_push_stack_local_native_frame(env, &frame);
 
 	/* Get class type */
-	type = _jc_get_vm_pointer(class_obj, vm->boot.fields.Class.vmdata);
+	type = *_JC_VMFIELD(vm, class_obj, Class, vmdata, _jc_type *);
 	_JC_ASSERT((type->flags & _JC_TYPE_MASK) == _JC_TYPE_REFERENCE);
 
 	/* Instantiate new object */
@@ -2132,7 +2131,7 @@
 	_JC_ASSERT(class_obj->type == vm->boot.types.Class);
 
 	/* Get class type */
-	type = _jc_get_vm_pointer(class_obj, vm->boot.fields.Class.vmdata);
+	type = *_JC_VMFIELD(vm, class_obj, Class, vmdata, _jc_type *);
 	_JC_ASSERT((type->flags & _JC_TYPE_MASK) == _JC_TYPE_REFERENCE);
 
 	/* Get the name of the array type for this class */
@@ -2260,7 +2259,7 @@
 	_jc_push_stack_local_native_frame(env, &frame);
 
 	/* Get class info */
-	type = _jc_get_vm_pointer(*class, vm->boot.fields.Class.vmdata);
+	type = *_JC_VMFIELD(vm, *class, Class, vmdata, _jc_type *);
 	_JC_ASSERT((type->flags & (_JC_TYPE_ARRAY|_JC_TYPE_REFERENCE))
 	    == _JC_TYPE_REFERENCE);
 
@@ -2318,7 +2317,7 @@
 	_jc_resuming_java(env);
 
 	/* Get class info */
-	type = _jc_get_vm_pointer(*class, vm->boot.fields.Class.vmdata);
+	type = *_JC_VMFIELD(vm, *class, Class, vmdata, _jc_type *);
 	_JC_ASSERT((type->flags & (_JC_TYPE_ARRAY|_JC_TYPE_REFERENCE))
 	    == _JC_TYPE_REFERENCE);
 
@@ -2516,16 +2515,16 @@
 	_jc_resuming_java(env);
 	_jc_push_stack_local_native_frame(env, &frame);
 
-	/* Create RawData object */
+	/* Create Pointer object */
 	if ((data = _jc_new_local_native_ref(env,
-	    _jc_new_object(env, vm->boot.types.RawData))) == NULL)
+	    _jc_new_object(env, vm->boot.types.Pointer))) == NULL)
 		goto done;
 	switch (sizeof(void *)) {
 	case 4:
-		*_JC_VMFIELD(vm, *data, RawData, data, jint) = (_jc_word)addr;
+		*_JC_VMFIELD(vm, *data, Pointer, data, jint) = (_jc_word)addr;
 		break;
 	case 8:
-		*_JC_VMFIELD(vm, *data, RawData, data, jlong) = (_jc_word)addr;
+		*_JC_VMFIELD(vm, *data, Pointer, data, jlong) = (_jc_word)addr;
 		break;
 	default:
 		_JC_ASSERT(0);
@@ -2534,10 +2533,10 @@
 
 	/* Create buffer object */
 	if ((buffer = _jc_new_local_native_ref(env,
-	    _jc_new_object(env, vm->boot.types.DirectByteBufferImpl))) == NULL)
+	    _jc_new_object(env, vm->boot.types.ReadWrite))) == NULL)
 		goto done;
 	if (_jc_invoke_nonvirtual(env,
-	    vm->boot.methods.DirectByteBufferImpl.init, *buffer, NULL,
+	    vm->boot.methods.ReadWrite.init, *buffer, NULL,
 	    *data, (jint)capacity, (jint)capacity, (jint)0) != JNI_OK) {
 		buffer = NULL;
 		goto done;
@@ -2572,22 +2571,22 @@
 	}
 	_JC_ASSERT(*obj != NULL);
 
-	/* Get RawData object */
+	/* Get Pointer object */
 	data = *_JC_VMFIELD(vm, *obj, Buffer, address, _jc_object *);
 	if (data == NULL) {
 		_jc_post_exception(env, _JC_NullPointerException);
 		goto done;
 	}
 
-	/* Extract address from RawData object */
+	/* Extract address from Pointer object */
 	switch (sizeof(void *)) {
 	case 4:
 		addr = (void *)(_jc_word)*_JC_VMFIELD(vm,
-		    data, RawData, data, jint);
+		    data, Pointer, data, jint);
 		break;
 	case 8:
 		addr = (void *)(_jc_word)*_JC_VMFIELD(vm,
-		    data, RawData, data, jlong);
+		    data, Pointer, data, jlong);
 		break;
 	default:
 		_JC_ASSERT(0);

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/libjc.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/libjc.h?rev=332571&r1=332570&r2=332571&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/libjc.h (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/libjc.h Fri Nov 11 06:42:20 2005
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: libjc.h,v 1.33 2005/07/10 21:03:54 archiecobbs Exp $
+ * $Id: libjc.h,v 1.34 2005/11/09 18:14:22 archiecobbs Exp $
  */
 
 #ifndef _LIBJC_H_
@@ -321,6 +321,8 @@
 				const char *name, size_t len);
 extern _jc_type		*_jc_load_primitive_type(_jc_env *env, int ptype);
 extern jint		_jc_create_class_instance(_jc_env *env, _jc_type *type);
+extern _jc_type		*_jc_find_type(_jc_env *env, _jc_class_loader *loader,
+				const char *name);
 
 /* lock.c */
 extern jint		_jc_lock_object(_jc_env *env, _jc_object *obj);
@@ -432,6 +434,10 @@
 extern void		_jc_destroy_properties(_jc_jvm *vm);
 
 /* reflect.c */
+extern void		*_jc_get_vm_pointer(_jc_jvm *vm, _jc_object *obj,
+				_jc_field *field);
+extern jint		_jc_set_vm_pointer(_jc_env *env, _jc_object *obj,
+				_jc_field *field, void *ptr);
 extern _jc_field	*_jc_get_declared_field(_jc_env *env, _jc_type *type,
 				const char *name, const char *sig,
 				int is_static);

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/load.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/load.c?rev=332571&r1=332570&r2=332571&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/load.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/load.c Fri Nov 11 06:42:20 2005
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: load.c,v 1.7 2005/03/18 04:17:48 archiecobbs Exp $
+ * $Id: load.c,v 1.8 2005/11/09 18:14:22 archiecobbs Exp $
  */
 
 #include "libjc.h"
@@ -355,8 +355,8 @@
 		}
 
 		/* Extract pointer from Class.vmdata field */
-		type = _jc_get_vm_pointer(env->retval.l,
-		    vm->boot.fields.Class.vmdata);
+		type = *_JC_VMFIELD(vm, env->retval.l,
+		    Class, vmdata, _jc_type *);
 
 		/* Sanity check */
 		_JC_ASSERT((type->flags & (_JC_TYPE_ARRAY|_JC_TYPE_MASK))
@@ -441,8 +441,9 @@
 	/* Initialize new Class object */
 	type->instance = _jc_initialize_class_object(env, mem);
 
-	/* Set 'vmdata' pointer in Class object */
-	_jc_set_vm_pointer(type->instance, vm->boot.fields.Class.vmdata, type);
+	/* Set Class.vmdata to point to the type */
+	*((_jc_type **)((char *)type->instance
+	    + vm->boot.fields.Class.vmdata->offset)) = type;
 
 	/* Done */
 	return JNI_OK;
@@ -457,5 +458,41 @@
 
 	/* Done */
 	return JNI_ERR;
+}
+
+/*
+ * Find a type in a class loader's initiated types tree.
+ */
+_jc_type *
+_jc_find_type(_jc_env *env, _jc_class_loader *loader, const char *name)
+{
+	_jc_type_node node_key;
+	_jc_type_node *node;
+	_jc_type *type_key;
+
+	/*
+	 * Set up a fake type to use as the key for searching trees.
+	 * This works because 'name' is the only field in _jc_type
+	 * that is accessed when searching the splay trees.
+	 */
+	type_key = (_jc_type *)((char *)&name - _JC_OFFSETOF(_jc_type, name));
+	memset(&node_key, 0, sizeof(node_key));
+	node_key.type = type_key;
+
+	/* Lock loader */
+	_JC_MUTEX_LOCK(env, loader->mutex);
+
+	/* Search for type */
+	node = _jc_splay_find(&loader->initiated_types, &node_key);
+
+	/* Unlock loader */
+	_JC_MUTEX_UNLOCK(env, loader->mutex);
+
+	/* Return result */
+	if (node != NULL) {
+		_JC_ASSERT(node->type != NULL);
+		return node->type;
+	}
+	return NULL;
 }
 

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/gnu_classpath_VMStackWalker.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/gnu_classpath_VMStackWalker.c?rev=332571&r1=332570&r2=332571&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/gnu_classpath_VMStackWalker.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/gnu_classpath_VMStackWalker.c Fri Nov 11 06:42:20 2005
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: gnu_classpath_VMStackWalker.c,v 1.4 2005/05/15 21:41:01 archiecobbs Exp $
+ * $Id: gnu_classpath_VMStackWalker.c,v 1.5 2005/11/09 17:16:36 archiecobbs Exp $
  */
 
 #include "libjc.h"
@@ -141,10 +141,10 @@
 	jboolean top;
 	int num;
 
+again:
 	/* Lock VM */
 	_JC_MUTEX_LOCK(env, vm->mutex);
 
-again:
 	/* Crawl the Java stack and add Class objects for each method */
 	for (num = 0, top = JNI_TRUE, _jc_stack_crawl_first(env, &crawl);
 	    crawl.method != NULL; _jc_stack_crawl_next(vm, &crawl)) {
@@ -164,6 +164,9 @@
 		num++;
 	}
 
+	/* Unlock VM */
+	_JC_MUTEX_UNLOCK(env, vm->mutex);
+
 	/* Create array and loop back */
 	if (array == NULL) {
 		if ((array = (_jc_object_array *)_jc_new_array(env,
@@ -174,9 +177,6 @@
 		goto again;
 	}
 	_JC_ASSERT(num == array->length);
-
-	/* Unlock VM */
-	_JC_MUTEX_UNLOCK(env, vm->mutex);
 
 	/* Done */
 	return array;

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_io_VMObjectStreamClass.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_io_VMObjectStreamClass.c?rev=332571&r1=332570&r2=332571&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_io_VMObjectStreamClass.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_io_VMObjectStreamClass.c Fri Nov 11 06:42:20 2005
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: java_io_VMObjectStreamClass.c,v 1.4 2005/05/15 21:41:01 archiecobbs Exp $
+ * $Id: java_io_VMObjectStreamClass.c,v 1.5 2005/11/09 18:14:22 archiecobbs Exp $
  */
 
 #include "libjc.h"
@@ -36,7 +36,7 @@
 		_jc_post_exception(env, _JC_NullPointerException);
 		_jc_throw_exception(env);
 	}
-	type = _jc_get_vm_pointer(class, vm->boot.fields.Class.vmdata);
+	type = *_JC_VMFIELD(vm, class, Class, vmdata, _jc_type *);
 
 	/* Look for class initializer */
 	return _jc_get_declared_method(env, type, "<clinit>",

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_VMClass.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_VMClass.c?rev=332571&r1=332570&r2=332571&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_VMClass.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_VMClass.c Fri Nov 11 06:42:20 2005
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: java_lang_VMClass.c,v 1.10 2005/05/15 21:41:01 archiecobbs Exp $
+ * $Id: java_lang_VMClass.c,v 1.11 2005/11/09 18:14:22 archiecobbs Exp $
  */
 
 #include "libjc.h"
@@ -26,13 +26,35 @@
 				jboolean resolve);
 
 /*
- * static final native Class forName(String)
+ * static final native Class forName(String, boolean, ClassLoader)
  *	throws java/lang/ClassNotFoundException
  */
 _jc_object * _JC_JCNI_ATTR
-JCNI_java_lang_VMClass_forName(_jc_env *env, _jc_object *name)
+JCNI_java_lang_VMClass_forName(_jc_env *env, _jc_object *name_string,
+	jboolean initialize, _jc_object *loader_obj)
 {
-	return NULL;
+	_jc_jvm *const vm = env->vm;
+	_jc_object *clobj;
+
+	/* Load class */
+	clobj = _jc_internal_load_class(env,
+	    name_string, loader_obj, JNI_FALSE);
+
+	/* Initialize if desired */
+	if (initialize) {
+		_jc_type *type;
+
+		/* Get type */
+		type = *_JC_VMFIELD(vm, clobj, Class, vmdata, _jc_type *);
+		_JC_ASSERT(type != NULL);
+
+		/* Initialize type */
+		if (_jc_initialize_type(env, type) != JNI_OK)
+			_jc_throw_exception(env);
+	}
+
+	/* Done */
+	return clobj;
 }
 
 /*
@@ -446,22 +468,6 @@
 }
 
 /*
- * static final native void initialize(Class)
- */
-void _JC_JCNI_ATTR
-JCNI_java_lang_VMClass_initialize(_jc_env *env, _jc_object *this)
-{
-	_jc_type *type;
-
-	/* Get type */
-	type = _jc_get_type(env, this, JNI_FALSE);
-
-	/* Initialize type */
-	if (_jc_initialize_type(env, type) != JNI_OK)
-		_jc_throw_exception(env);
-}
-
-/*
  * static final native boolean isArray(Class)
  */
 jboolean _JC_JCNI_ATTR
@@ -541,17 +547,6 @@
 }
 
 /*
- * static final native Class loadArrayClass(String, ClassLoader)
- *	throws java/lang/ClassNotFoundException
- */
-_jc_object * _JC_JCNI_ATTR
-JCNI_java_lang_VMClass_loadArrayClass(_jc_env *env,
-	_jc_object *name_string, _jc_object *loader_obj)
-{
-	return _jc_internal_load_class(env, name_string, loader_obj, JNI_FALSE);
-}
-
-/*
  * static final native void throwException(Throwable)
  */
 void _JC_JCNI_ATTR
@@ -584,7 +579,7 @@
 	}
 
 	/* Get type */
-	type = _jc_get_vm_pointer(this, vm->boot.fields.Class.vmdata);
+	type = *_JC_VMFIELD(vm, this, Class, vmdata, _jc_type *);
 
 	/* Resolve type */
 	if (resolve && _jc_resolve_type(env, type) != JNI_OK)

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_VMClassLoader.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_VMClassLoader.c?rev=332571&r1=332570&r2=332571&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_VMClassLoader.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_VMClassLoader.c Fri Nov 11 06:42:20 2005
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: java_lang_VMClassLoader.c,v 1.14 2005/05/15 21:41:01 archiecobbs Exp $
+ * $Id: java_lang_VMClassLoader.c,v 1.15 2005/11/09 18:14:22 archiecobbs Exp $
  */
 
 #include "libjc.h"
@@ -134,6 +134,58 @@
 }
 
 /*
+ * static native Class findLoadedClass(ClassLoader, String)
+ */
+_jc_object * _JC_JCNI_ATTR
+JCNI_java_lang_VMClassLoader_findLoadedClass(_jc_env *env,
+	_jc_object *loader_obj, _jc_object *name_string)
+{
+	_jc_jvm *const vm = env->vm;
+	_jc_class_loader *loader;
+	size_t name_len;
+	_jc_type *type;
+	char *name;
+	char *s;
+
+	/* Get loader */
+	if (loader_obj == NULL)
+		loader = vm->boot.loader;
+	else {
+		_JC_ASSERT(_jc_subclass_of(loader_obj,
+		    env->vm->boot.types.ClassLoader));
+		if ((loader = _jc_get_loader(env, loader_obj)) == NULL)
+			_jc_throw_exception(env);
+	}
+
+	/* Check for null */
+	if (name_string == NULL) {
+		_jc_post_exception(env, _JC_NullPointerException);
+		_jc_throw_exception(env);
+	}
+
+	/* Convert name string to UTF-8 */
+	name_len = _jc_decode_string_utf8(env, name_string, NULL);
+	if ((name = _JC_STACK_ALLOC(env, name_len + 1)) == NULL) {
+		_jc_post_exception_info(env);
+		_jc_throw_exception(env);
+	}
+	_jc_decode_string_utf8(env, name_string, name);
+
+	/* Replace '.' -> '/' */
+	for (s = name; *s != '\0'; s++) {
+		if (*s == '.')
+			*s = '/';
+	}
+
+	/* Find type */
+	if ((type = _jc_find_type(env, loader, name)) == NULL)
+		return NULL;
+
+	/* Return type's Class instance */
+	return type->instance;
+}
+
+/*
  * static final native void resolveClass(Class)
  */
 void _JC_JCNI_ATTR
@@ -148,7 +200,7 @@
 		_jc_throw_exception(env);
 	}
 	_JC_ASSERT(class->type == vm->boot.types.Class);
-	type = _jc_get_vm_pointer(class, vm->boot.fields.Class.vmdata);
+	type = *_JC_VMFIELD(vm, class, Class, vmdata, _jc_type *);
 
 	/* Link type */
 	if (_jc_resolve_type(env, type) != JNI_OK)

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_VMCompiler.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_VMCompiler.c?rev=332571&r1=332570&r2=332571&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_VMCompiler.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_VMCompiler.c Fri Nov 11 06:42:20 2005
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: java_lang_VMCompiler.c,v 1.2 2005/05/15 21:41:01 archiecobbs Exp $
+ * $Id: java_lang_VMCompiler.c,v 1.3 2005/11/09 18:14:22 archiecobbs Exp $
  */
 
 #include "libjc.h"
@@ -37,7 +37,8 @@
 	}
 
 	/* Get type */
-	type = _jc_get_vm_pointer(cl, vm->boot.fields.Class.vmdata);
+	type = *_JC_VMFIELD(vm, cl, Class, vmdata, _jc_type *);
+	_JC_ASSERT(type != NULL);
 
 	/* Generate ELF object */
 	if (_jc_generate_object(env, type->loader, type->name) != JNI_OK)

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_VMThread.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_VMThread.c?rev=332571&r1=332570&r2=332571&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_VMThread.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_VMThread.c Fri Nov 11 06:42:20 2005
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: java_lang_VMThread.c,v 1.6 2005/05/15 21:41:01 archiecobbs Exp $
+ * $Id: java_lang_VMThread.c,v 1.7 2005/11/09 18:14:22 archiecobbs Exp $
  */
 
 #include "libjc.h"
@@ -44,7 +44,7 @@
 	_JC_MUTEX_LOCK(env, vm->mutex);
 
 	/* Get internal thread structure */
-	thread = _jc_get_vm_pointer(this, vm->boot.fields.VMThread.vmdata);
+	thread = _jc_get_vm_pointer(vm, this, vm->boot.fields.VMThread.vmdata);
 	if (thread == NULL)
 		goto done;
 
@@ -122,7 +122,7 @@
 	_JC_MUTEX_LOCK(env, vm->mutex);
 
 	/* Get thread's thread structure */
-	thread = _jc_get_vm_pointer(this, vm->boot.fields.VMThread.vmdata);
+	thread = _jc_get_vm_pointer(vm, this, vm->boot.fields.VMThread.vmdata);
 	if (thread == NULL)
 		goto done;
 
@@ -169,7 +169,7 @@
 	_JC_MUTEX_LOCK(env, vm->mutex);
 
 	/* Get internal thread structure */
-	thread = _jc_get_vm_pointer(this, vm->boot.fields.VMThread.vmdata);
+	thread = _jc_get_vm_pointer(vm, this, vm->boot.fields.VMThread.vmdata);
 	if (thread == NULL)
 		goto done;
 
@@ -204,7 +204,7 @@
 	_JC_MUTEX_LOCK(env, vm->mutex);
 
 	/* Get internal thread structure */
-	thread = _jc_get_vm_pointer(this, vm->boot.fields.VMThread.vmdata);
+	thread = _jc_get_vm_pointer(vm, this, vm->boot.fields.VMThread.vmdata);
 	if (thread == NULL)
 		goto done;
 
@@ -245,7 +245,7 @@
 	_JC_MUTEX_LOCK(env, vm->mutex);
 
 	/* Get internal thread structure */
-	thread = _jc_get_vm_pointer(this, vm->boot.fields.VMThread.vmdata);
+	thread = _jc_get_vm_pointer(vm, this, vm->boot.fields.VMThread.vmdata);
 	if (thread == NULL)
 		goto done;
 
@@ -318,8 +318,8 @@
 	}
 
 	/* Sanity check thread is not already started */
-	_JC_ASSERT(_jc_get_vm_pointer(this,
-	    vm->boot.fields.VMThread.vmdata) == NULL);
+	_JC_ASSERT(_jc_get_vm_pointer(vm,
+	    this, vm->boot.fields.VMThread.vmdata) == NULL);
 
 	/* Get requested stack size; use default if zero */
 	thread->stack_size = stack_size;
@@ -426,7 +426,9 @@
 #endif	/* !_JC_NO_THREAD_ATTRIBUTES */
 
 	/* Set the VMThread's vmdata pointer */
-	_jc_set_vm_pointer(this, vm->boot.fields.VMThread.vmdata, thread);
+	if (_jc_set_vm_pointer(env, this,
+	    vm->boot.fields.VMThread.vmdata, thread) != JNI_OK)
+	    	goto fail;
 
 	/* Hack to pass the VMThread's Thread pointer without setting it */
 	thread->retval.l = this;
@@ -434,7 +436,8 @@
 	/* Spawn new pthread to execute this thread */
 	if ((error = pthread_create(&pthread,
 	    attrp, _jc_thread_start, thread)) != 0) {
-		_jc_set_vm_pointer(this, vm->boot.fields.VMThread.vmdata, NULL);
+		(void)_jc_set_vm_pointer(env, this,
+		    vm->boot.fields.VMThread.vmdata, NULL);
 		_jc_post_exception_msg(env, _JC_InternalError,
 		    "%s: %s", "pthread_create", strerror(error));
 		goto fail;
@@ -475,7 +478,7 @@
 	_JC_MUTEX_LOCK(env, vm->mutex);
 
 	/* Get internal thread structure */
-	thread = _jc_get_vm_pointer(this, vm->boot.fields.VMThread.vmdata);
+	thread = _jc_get_vm_pointer(vm, this, vm->boot.fields.VMThread.vmdata);
 	if (thread == NULL)
 		goto done;
 

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/org_dellroad_jc_vm_DebugThread.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/org_dellroad_jc_vm_DebugThread.c?rev=332571&r1=332570&r2=332571&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/org_dellroad_jc_vm_DebugThread.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/org_dellroad_jc_vm_DebugThread.c Fri Nov 11 06:42:20 2005
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: org_dellroad_jc_vm_DebugThread.c,v 1.7 2005/05/15 21:41:01 archiecobbs Exp $
+ * $Id: org_dellroad_jc_vm_DebugThread.c,v 1.8 2005/11/09 18:14:22 archiecobbs Exp $
  */
 
 #include "libjc.h"
@@ -212,8 +212,8 @@
 		pinstance = *_JC_VMFIELD(vm, loader->instance,
 		    ClassLoader, parent, _jc_object *);
 		if (pinstance != NULL) {
-			parent = _jc_get_vm_pointer(pinstance,
-			    vm->boot.fields.ClassLoader.vmdata);
+			parent = _jc_get_vm_pointer(vm,
+			    pinstance, vm->boot.fields.ClassLoader.vmdata);
 		} else
 			parent = vm->boot.loader;
 	}

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/reflect.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/reflect.c?rev=332571&r1=332570&r2=332571&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/reflect.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/reflect.c Fri Nov 11 06:42:20 2005
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: reflect.c,v 1.25 2005/07/10 21:03:54 archiecobbs Exp $
+ * $Id: reflect.c,v 1.26 2005/11/09 18:14:22 archiecobbs Exp $
  */
 
 #include "libjc.h"
@@ -25,6 +25,68 @@
 				_jc_type *type, const char *name, jint slot);
 
 /*
+ * Extract a pointer from a gnu.classpath.Pointer object which
+ * is referred to by the given field in the given object.
+ *
+ * If the field is null then NULL is returned.
+ */
+void *
+_jc_get_vm_pointer(_jc_jvm *vm, _jc_object *obj, _jc_field *field)
+{
+	_jc_object *pobj;
+
+	/* Sanity check */
+	_JC_ASSERT(obj != NULL && field != NULL);
+	_JC_ASSERT(_jc_subclass_of(obj, field->class));
+
+	/* Get reference to the Pointer object */
+	pobj = *((_jc_object **)((char *)obj + field->offset));
+	if (pobj == NULL)
+		return NULL;
+
+	/* Extract the contained pointer */
+	return *_JC_VMFIELD(vm, pobj, Pointer, data, void *);
+}
+
+/*
+ * Store a pointer into a field of type gnu.classpath.Pointer.
+ *
+ * Posts an exception on failure.
+ */
+jint
+_jc_set_vm_pointer(_jc_env *env, _jc_object *obj, _jc_field *field, void *ptr)
+{
+	_jc_jvm *const vm = env->vm;
+	_jc_object *pobj;
+
+	/* Sanity check */
+	_JC_ASSERT(obj != NULL && field != NULL);
+	_JC_ASSERT(_jc_subclass_of(obj, field->class));
+
+	/* Handle easy case */
+	if (ptr == NULL) {
+		pobj = NULL;
+		goto done;
+	}
+
+	/* Create a new Pointer object (if one doesn't already exist) */
+	pobj = *((_jc_object **)((char *)obj + field->offset));
+	if (pobj == NULL) {
+		if ((pobj = _jc_new_object(env,
+		    vm->boot.types.Pointer)) == NULL)
+			return JNI_ERR;
+	}
+
+	/* Store the pointer in the Pointer object */
+	*_JC_VMFIELD(vm, pobj, Pointer, data, void *) = ptr;
+
+done:
+	/* Set the Pointer in the object (after storing ptr within) */
+	*((_jc_object **)((char *)obj + field->offset)) = pobj;
+	return JNI_OK;
+}
+
+/*
  * Resolve a field declared in a specific class.
  *
  * If unsuccessful a NoSuchFieldError exception is stored.
@@ -239,7 +301,7 @@
 
 	/* Locate declaring class */
 	cl = *_JC_VMFIELD(vm, obj, Method, declaringClass, _jc_object *);
-	type = _jc_get_vm_pointer(cl, vm->boot.fields.Class.vmdata);
+	type = *_JC_VMFIELD(vm, cl, Class, vmdata, _jc_type *);
 	_JC_ASSERT(!_JC_FLG_TEST(type, ARRAY));
 
 	/* Locate method */
@@ -271,7 +333,7 @@
 
 	/* Locate declaring class */
 	cl = *_JC_VMFIELD(vm, obj, Constructor, clazz, _jc_object *);
-	type = _jc_get_vm_pointer(cl, vm->boot.fields.Class.vmdata);
+	type = *_JC_VMFIELD(vm, cl, Class, vmdata, _jc_type *);
 	_JC_ASSERT(!_JC_FLG_TEST(type, ARRAY));
 
 	/* Locate constructor method */
@@ -302,7 +364,7 @@
 
 	/* Locate declaring class */
 	cl = *_JC_VMFIELD(vm, obj, Field, declaringClass, _jc_object *);
-	type = _jc_get_vm_pointer(cl, vm->boot.fields.Class.vmdata);
+	type = *_JC_VMFIELD(vm, cl, Class, vmdata, _jc_type *);
 	_JC_ASSERT(!_JC_FLG_TEST(type, ARRAY));
 
 	/* Locate field */

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/structures.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/structures.h?rev=332571&r1=332570&r2=332571&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/structures.h (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/structures.h Fri Nov 11 06:42:20 2005
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: structures.h,v 1.36 2005/05/24 01:09:38 archiecobbs Exp $
+ * $Id: structures.h,v 1.37 2005/11/09 18:14:22 archiecobbs Exp $
  */
 
 #ifndef _STRUCTURES_H_
@@ -536,14 +536,14 @@
 	_jc_type	*ClassLoader;
 	_jc_type	*Cloneable;
 	_jc_type	*Constructor;
-	_jc_type	*DirectByteBufferImpl;
+	_jc_type	*ReadWrite;
 	_jc_type	*Error;
 	_jc_type	*Field;
 	_jc_type	*Generate;
 	_jc_type	*Method;
 	_jc_type	*Object;
 	_jc_type	*PhantomReference;
-	_jc_type	*RawData;
+	_jc_type	*Pointer;
 	_jc_type	*Reference;
 	_jc_type	*Serializable;
 	_jc_type	*SoftReference;
@@ -594,7 +594,7 @@
 	}			Constructor;
 	struct {
 		_jc_method	*init;
-	}			DirectByteBufferImpl;
+	}			ReadWrite;
 	struct {
 		_jc_method	*init;
 	}			Field;
@@ -674,7 +674,7 @@
 	}			Method;
 	struct {
 		_jc_field	*data;
-	}			RawData;
+	}			Pointer;
 	struct {
 		_jc_field	*queue;
 		_jc_field	*referent;

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/thread.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/thread.c?rev=332571&r1=332570&r2=332571&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/thread.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/thread.c Fri Nov 11 06:42:20 2005
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: thread.c,v 1.14 2005/03/18 04:17:48 archiecobbs Exp $
+ * $Id: thread.c,v 1.15 2005/11/09 18:14:22 archiecobbs Exp $
  */
 
 #include "libjc.h"
@@ -172,7 +172,7 @@
 		goto done;
 
 	/* Get internal thread structure */
-	thread = _jc_get_vm_pointer(vmt, vm->boot.fields.VMThread.vmdata);
+	thread = _jc_get_vm_pointer(vm, vmt, vm->boot.fields.VMThread.vmdata);
 	if (thread == NULL)
 		goto done;
 
@@ -539,7 +539,9 @@
 		goto fail;
 
 	/* Set VMThread private data */
-	_jc_set_vm_pointer(*vtref, vm->boot.fields.VMThread.vmdata, env);
+	if (_jc_set_vm_pointer(env, *vtref,
+	    vm->boot.fields.VMThread.vmdata, env) != JNI_OK)
+	    	goto fail;
 
 	/* Invoke VMThread constructor */
 	if (_jc_invoke_nonvirtual(env, vm->boot.methods.VMThread.init,
@@ -945,7 +947,7 @@
 		vmt = *_JC_VMFIELD(vm, env->instance,
 		    Thread, vmThread, _jc_object *);
 		if (vmt != NULL) {
-			_jc_set_vm_pointer(vmt,
+			(void)_jc_set_vm_pointer(env, vmt,
 			   vm->boot.fields.VMThread.vmdata, NULL);
 		}
 	}



Mime
View raw message