harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arc...@apache.org
Subject svn commit: r358818 - in /incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm: include/ libjc/ libjc/arch/ libjc/arch/i386/ libjc/arch/ppc/ libjc/native/
Date Fri, 23 Dec 2005 15:37:34 GMT
Author: archie
Date: Fri Dec 23 07:37:28 2005
New Revision: 358818

URL: http://svn.apache.org/viewcvs?rev=358818&view=rev
Log:
Fix bug on big-endian machines caused by ignoring the fact that Java methods
return boolean, byte, short, and char as ints. On big endian machines they
need to be converted explicitly because _jc_value type punning doesn't work.

Modified:
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/include/jc_defs.h
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/arch_libjc.h
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/i386/arch_functions.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/arch_functions.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/interp.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/invoke.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/jni_native.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_reflect_Constructor.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_reflect_Field.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_reflect_Method.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/reflect.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/structures.h

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/include/jc_defs.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/include/jc_defs.h?rev=358818&r1=358817&r2=358818&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/include/jc_defs.h (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/include/jc_defs.h Fri
Dec 23 07:37:28 2005
@@ -107,6 +107,7 @@
 typedef struct _jc_array		_jc_array;
 typedef struct _jc_object_array		_jc_object_array;
 typedef union _jc_value			_jc_value;
+typedef union _jc_rvalue		_jc_rvalue;
 typedef struct _jc_catch_frame		_jc_catch_frame;
 
 typedef struct _jc_field		_jc_field;
@@ -137,6 +138,19 @@
 	jbyte		b;
 	jchar		c;
 	jshort		s;
+	jint		i;
+	jlong		j;
+	jfloat		f;
+	jdouble		d;
+	_jc_object	*l;
+	_jc_word	_dummy;			/* ensure size/alignment */
+};
+
+/*
+ * Java return value. Like _jc_value but has z, b, c, and s folded
+ * into i, because Java methods return all those types as ints.
+ */
+union _jc_rvalue {
 	jint		i;
 	jlong		j;
 	jfloat		f;

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/arch_libjc.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/arch_libjc.h?rev=358818&r1=358817&r2=358818&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/arch_libjc.h
(original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/arch_libjc.h
Fri Dec 23 07:37:28 2005
@@ -72,7 +72,7 @@
 
     void
     _jc_dynamic_invoke(const void *func, int jcni, int nparams,
-        const u_char *ptypes, int nwords, _jc_word *words, _jc_value *retval)
+        const u_char *ptypes, int nwords, _jc_word *words, _jc_rvalue *retval)
 
 	Dynamically constructed C function call. Should invoke the C function
 	"func" with supplied parameters. Return value should be stored in
@@ -84,6 +84,8 @@
 	Can be ignored if JNCI calling conventions are the same as normal
 	calling conventions for a particular architecture.
 
+	Note types Z, B, C, and S are returned as jints in "retval".
+
     void
     _jc_iflush(const void *mem, size_t len)
 
@@ -116,7 +118,7 @@
 				const void *func);
 extern void		_jc_dynamic_invoke(const void *func, int jcni,
 				int nparams, const u_char *ptypes, int nwords,
-				_jc_word *words, _jc_value *retval);
+				_jc_word *words, _jc_rvalue *retval);
 
 /* Stack pointer functions */
 extern const void	*_jc_mcontext_sp(const mcontext_t *mctx);

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/i386/arch_functions.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/i386/arch_functions.c?rev=358818&r1=358817&r2=358818&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/i386/arch_functions.c
(original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/i386/arch_functions.c
Fri Dec 23 07:37:28 2005
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: arch_functions.c,v 1.4 2005/07/10 21:03:55 archiecobbs Exp $
+ * $Id$
  */
 
 #include "libjc.h"
@@ -290,7 +290,7 @@
 
 void
 _jc_dynamic_invoke(const void *func, int jcni, int nparams,
-	const u_char *ptypes, int nwords, _jc_word *words, _jc_value *retval)
+	const u_char *ptypes, int nwords, _jc_word *words, _jc_rvalue *retval)
 {
 	_jc_word twords[3];
 	u_char push[4];
@@ -355,25 +355,25 @@
 		asm volatile ("movl %0,%%ecx" : : "m" (words[2]) : "sp", "cx");
 		asm volatile ("movl %0,%%edx" : : "m" (words[1]) : "sp", "dx");
 		asm volatile ("movl %0,%%eax" : : "m" (words[0]) : "sp", "ax");
-		retval->z = (*(jboolean (*)())func)();
+		retval->i = (*(jboolean (*)())func)();
 		break;
 	case _JC_TYPE_BYTE:
 		asm volatile ("movl %0,%%ecx" : : "m" (words[2]) : "sp", "cx");
 		asm volatile ("movl %0,%%edx" : : "m" (words[1]) : "sp", "dx");
 		asm volatile ("movl %0,%%eax" : : "m" (words[0]) : "sp", "ax");
-		retval->b = (*(jbyte (*)())func)();
+		retval->i = (*(jbyte (*)())func)();
 		break;
 	case _JC_TYPE_CHAR:
 		asm volatile ("movl %0,%%ecx" : : "m" (words[2]) : "sp", "cx");
 		asm volatile ("movl %0,%%edx" : : "m" (words[1]) : "sp", "dx");
 		asm volatile ("movl %0,%%eax" : : "m" (words[0]) : "sp", "ax");
-		retval->c = (*(jchar (*)())func)();
+		retval->i = (*(jchar (*)())func)();
 		break;
 	case _JC_TYPE_SHORT:
 		asm volatile ("movl %0,%%ecx" : : "m" (words[2]) : "sp", "cx");
 		asm volatile ("movl %0,%%edx" : : "m" (words[1]) : "sp", "dx");
 		asm volatile ("movl %0,%%eax" : : "m" (words[0]) : "sp", "ax");
-		retval->s = (*(jshort (*)())func)();
+		retval->i = (*(jshort (*)())func)();
 		break;
 	case _JC_TYPE_INT:
 		asm volatile ("movl %0,%%ecx" : : "m" (words[2]) : "sp", "cx");
@@ -426,7 +426,7 @@
 
 void
 _jc_dynamic_invoke(const void *func, int jcni, int nparams,
-	const u_char *ptypes, int nwords, _jc_word *words, _jc_value *retval)
+	const u_char *ptypes, int nwords, _jc_word *words, _jc_rvalue *retval)
 {
 	int i;
 
@@ -437,16 +437,16 @@
 	/* Invoke function */
 	switch (ptypes[nparams]) {
 	case _JC_TYPE_BOOLEAN:
-		retval->z = (*(jboolean (*)())func)();
+		retval->i = (*(jboolean (*)())func)();
 		break;
 	case _JC_TYPE_BYTE:
-		retval->b = (*(jbyte (*)())func)();
+		retval->i = (*(jbyte (*)())func)();
 		break;
 	case _JC_TYPE_CHAR:
-		retval->c = (*(jchar (*)())func)();
+		retval->i = (*(jchar (*)())func)();
 		break;
 	case _JC_TYPE_SHORT:
-		retval->s = (*(jshort (*)())func)();
+		retval->i = (*(jshort (*)())func)();
 		break;
 	case _JC_TYPE_INT:
 		retval->i = (*(jint (*)())func)();

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/arch_functions.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/arch_functions.c?rev=358818&r1=358817&r2=358818&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/arch_functions.c
(original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/arch_functions.c
Fri Dec 23 07:37:28 2005
@@ -260,7 +260,7 @@
 
 void
 _jc_dynamic_invoke(const void *func, int jcni, int nparams,
-	const u_char *ptypes, int nwords, _jc_word *words, _jc_value *retval)
+	const u_char *ptypes, int nwords, _jc_word *words, _jc_rvalue *retval)
 {
 	fprintf(stdout, "WARNING: Call to unimplemented function _jc_dynamic_invoke(...).\n");
 	exit(0);

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/interp.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/interp.c?rev=358818&r1=358817&r2=358818&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/interp.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/interp.c Fri Dec
23 07:37:28 2005
@@ -1070,17 +1070,9 @@
 	/* Push return value, if any */
 	switch (imethod->param_ptypes[imethod->num_parameters]) {
 	case _JC_TYPE_BOOLEAN:
-		PUSHI(env->retval.z);
-		break;
 	case _JC_TYPE_BYTE:
-		PUSHI(env->retval.b);
-		break;
 	case _JC_TYPE_CHAR:
-		PUSHI(env->retval.c);
-		break;
 	case _JC_TYPE_SHORT:
-		PUSHI(env->retval.s);
-		break;
 	case _JC_TYPE_INT:
 		PUSHI(env->retval.i);
 		break;
@@ -1575,7 +1567,7 @@
 
 	/* De-synchronize if necessary */
 	if (lock != NULL) {
-		_jc_value retval;
+		_jc_rvalue retval;
 
 		/* Temporarily save return value */
 		retval = env->retval;
@@ -1656,20 +1648,20 @@
 	va_end(args);							\
 	return _rtn;							\
 }
-_JC_INTERP_ENTRY(z, interp, jboolean, env->retval.z)
-_JC_INTERP_ENTRY(b, interp, jbyte, env->retval.b)
-_JC_INTERP_ENTRY(c, interp, jchar, env->retval.c)
-_JC_INTERP_ENTRY(s, interp, jshort, env->retval.s)
+_JC_INTERP_ENTRY(z, interp, jboolean, (jboolean)env->retval.i)
+_JC_INTERP_ENTRY(b, interp, jbyte, (jbyte)env->retval.i)
+_JC_INTERP_ENTRY(c, interp, jchar, (jchar)env->retval.i)
+_JC_INTERP_ENTRY(s, interp, jshort, (jshort)env->retval.i)
 _JC_INTERP_ENTRY(i, interp, jint, env->retval.i)
 _JC_INTERP_ENTRY(j, interp, jlong, env->retval.j)
 _JC_INTERP_ENTRY(f, interp, jfloat, env->retval.f)
 _JC_INTERP_ENTRY(d, interp, jdouble, env->retval.d)
 _JC_INTERP_ENTRY(l, interp, _jc_object *, env->retval.l)
 _JC_INTERP_ENTRY(v, interp, void, )
-_JC_INTERP_ENTRY(z, interp_native, jboolean, env->retval.z)
-_JC_INTERP_ENTRY(b, interp_native, jbyte, env->retval.b)
-_JC_INTERP_ENTRY(c, interp_native, jchar, env->retval.c)
-_JC_INTERP_ENTRY(s, interp_native, jshort, env->retval.s)
+_JC_INTERP_ENTRY(z, interp_native, jboolean, (jboolean)env->retval.i)
+_JC_INTERP_ENTRY(b, interp_native, jbyte, (jbyte)env->retval.i)
+_JC_INTERP_ENTRY(c, interp_native, jchar, (jchar)env->retval.i)
+_JC_INTERP_ENTRY(s, interp_native, jshort, (jshort)env->retval.i)
 _JC_INTERP_ENTRY(i, interp_native, jint, env->retval.i)
 _JC_INTERP_ENTRY(j, interp_native, jlong, env->retval.j)
 _JC_INTERP_ENTRY(f, interp_native, jfloat, env->retval.f)

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/invoke.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/invoke.c?rev=358818&r1=358817&r2=358818&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/invoke.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/invoke.c Fri Dec
23 07:37:28 2005
@@ -701,7 +701,7 @@
 
 	/* Synchronized? */
 	if (got_monitor) {
-		_jc_value retval;
+		_jc_rvalue retval;
 		jint status2;
 
 		retval = env->retval;
@@ -980,7 +980,7 @@
 
 	/* Synchronized? */
 	if (got_monitor) {
-		_jc_value retval;
+		_jc_rvalue retval;
 		jint status2;
 
 		retval = env->retval;

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=358818&r1=358817&r2=358818&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
Dec 23 07:37:28 2005
@@ -412,10 +412,10 @@
 	/* Done */							\
 	return result;							\
 }
-CallNonvirtualMethodA(boolean, Boolean, result = env->retval.z;, NULL)
-CallNonvirtualMethodA(byte, Byte, result = env->retval.b;, NULL)
-CallNonvirtualMethodA(short, Short, result = env->retval.s;, NULL)
-CallNonvirtualMethodA(char, Char, result = env->retval.c;, NULL)
+CallNonvirtualMethodA(boolean, Boolean, result = (jboolean)env->retval.i;, NULL)
+CallNonvirtualMethodA(byte, Byte, result = (jbyte)env->retval.i;, NULL)
+CallNonvirtualMethodA(short, Short, result = (jshort)env->retval.i;, NULL)
+CallNonvirtualMethodA(char, Char, result = (jchar)env->retval.i;, NULL)
 CallNonvirtualMethodA(int, Int, result = env->retval.i;, NULL)
 CallNonvirtualMethodA(long, Long, result = env->retval.j;, NULL)
 CallNonvirtualMethodA(float, Float, result = env->retval.f;, NULL)
@@ -448,10 +448,10 @@
 	/* Done */							\
 	return result;							\
 }
-CallNonvirtualMethodV(boolean, Boolean, result = env->retval.z;, NULL)
-CallNonvirtualMethodV(byte, Byte, result = env->retval.b;, NULL)
-CallNonvirtualMethodV(short, Short, result = env->retval.s;, NULL)
-CallNonvirtualMethodV(char, Char, result = env->retval.c;, NULL)
+CallNonvirtualMethodV(boolean, Boolean, result = (jboolean)env->retval.i;, NULL)
+CallNonvirtualMethodV(byte, Byte, result = (jbyte)env->retval.i;, NULL)
+CallNonvirtualMethodV(short, Short, result = (jshort)env->retval.i;, NULL)
+CallNonvirtualMethodV(char, Char, result = (jchar)env->retval.i;, NULL)
 CallNonvirtualMethodV(int, Int, result = env->retval.i;, NULL)
 CallNonvirtualMethodV(long, Long, result = env->retval.j;, NULL)
 CallNonvirtualMethodV(float, Float, result = env->retval.f;, NULL)
@@ -556,10 +556,10 @@
 	/* Done */							\
 	return result;							\
 }
-CallMethodA(boolean, Boolean, result = env->retval.z;, NULL)
-CallMethodA(byte, Byte, result = env->retval.b;, NULL)
-CallMethodA(short, Short, result = env->retval.s;, NULL)
-CallMethodA(char, Char, result = env->retval.c;, NULL)
+CallMethodA(boolean, Boolean, result = (jboolean)env->retval.i;, NULL)
+CallMethodA(byte, Byte, result = (jbyte)env->retval.i;, NULL)
+CallMethodA(short, Short, result = (jshort)env->retval.i;, NULL)
+CallMethodA(char, Char, result = (jchar)env->retval.i;, NULL)
 CallMethodA(int, Int, result = env->retval.i;, NULL)
 CallMethodA(long, Long, result = env->retval.j;, NULL)
 CallMethodA(float, Float, result = env->retval.f;, NULL)
@@ -592,10 +592,10 @@
 	/* Done */							\
 	return result;							\
 }
-CallMethodV(boolean, Boolean, result = env->retval.z;, NULL)
-CallMethodV(byte, Byte, result = env->retval.b;, NULL)
-CallMethodV(short, Short, result = env->retval.s;, NULL)
-CallMethodV(char, Char, result = env->retval.c;, NULL)
+CallMethodV(boolean, Boolean, result = (jboolean)env->retval.i;, NULL)
+CallMethodV(byte, Byte, result = (jbyte)env->retval.i;, NULL)
+CallMethodV(short, Short, result = (jshort)env->retval.i;, NULL)
+CallMethodV(char, Char, result = (jchar)env->retval.i;, NULL)
 CallMethodV(int, Int, result = env->retval.i;, NULL)
 CallMethodV(long, Long, result = env->retval.j;, NULL)
 CallMethodV(float, Float, result = env->retval.f;, NULL)
@@ -702,10 +702,10 @@
 	/* Done */							\
 	return result;							\
 }
-CallStaticMethodA(boolean, Boolean, result = env->retval.z;, NULL)
-CallStaticMethodA(byte, Byte, result = env->retval.b;, NULL)
-CallStaticMethodA(short, Short, result = env->retval.s;, NULL)
-CallStaticMethodA(char, Char, result = env->retval.c;, NULL)
+CallStaticMethodA(boolean, Boolean, result = (jboolean)env->retval.i;, NULL)
+CallStaticMethodA(byte, Byte, result = (jbyte)env->retval.i;, NULL)
+CallStaticMethodA(short, Short, result = (jshort)env->retval.i;, NULL)
+CallStaticMethodA(char, Char, result = (jchar)env->retval.i;, NULL)
 CallStaticMethodA(int, Int, result = env->retval.i;, NULL)
 CallStaticMethodA(long, Long, result = env->retval.j;, NULL)
 CallStaticMethodA(float, Float, result = env->retval.f;, NULL)
@@ -738,10 +738,10 @@
 	/* Done */							\
 	return result;							\
 }
-CallStaticMethodV(boolean, Boolean, result = env->retval.z;, NULL)
-CallStaticMethodV(byte, Byte, result = env->retval.b;, NULL)
-CallStaticMethodV(short, Short, result = env->retval.s;, NULL)
-CallStaticMethodV(char, Char, result = env->retval.c;, NULL)
+CallStaticMethodV(boolean, Boolean, result = (jboolean)env->retval.i;, NULL)
+CallStaticMethodV(byte, Byte, result = (jbyte)env->retval.i;, NULL)
+CallStaticMethodV(short, Short, result = (jshort)env->retval.i;, NULL)
+CallStaticMethodV(char, Char, result = (jchar)env->retval.i;, NULL)
 CallStaticMethodV(int, Int, result = env->retval.i;, NULL)
 CallStaticMethodV(long, Long, result = env->retval.j;, NULL)
 CallStaticMethodV(float, Float, result = env->retval.f;, NULL)

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_reflect_Constructor.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_reflect_Constructor.c?rev=358818&r1=358817&r2=358818&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_reflect_Constructor.c
(original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_reflect_Constructor.c
Fri Dec 23 07:37:28 2005
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: java_lang_reflect_Constructor.c,v 1.7 2005/05/15 21:41:01 archiecobbs Exp $
+ * $Id$
  */
 
 #include "libjc.h"
@@ -44,7 +44,7 @@
 	if (_jc_invoke_virtual(env,
 	    vm->boot.methods.AccessibleObject.isAccessible, this) != JNI_OK)
 		_jc_throw_exception(env);
-	if (env->retval.z)
+	if (env->retval.i)
 		goto accessible;
 
 	/* Check access */

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_reflect_Field.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_reflect_Field.c?rev=358818&r1=358817&r2=358818&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_reflect_Field.c
(original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_reflect_Field.c
Fri Dec 23 07:37:28 2005
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: java_lang_reflect_Field.c,v 1.13 2005/07/09 19:58:35 archiecobbs Exp $
+ * $Id$
  */
 
 #include "libjc.h"
@@ -622,7 +622,7 @@
 	if (_jc_invoke_virtual(env,
 	    vm->boot.methods.AccessibleObject.isAccessible, this) != JNI_OK)
 		return NULL;
-	if (env->retval.z)
+	if (env->retval.i)
 		goto accessible;
 
 	/* Check access */

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_reflect_Method.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_reflect_Method.c?rev=358818&r1=358817&r2=358818&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_reflect_Method.c
(original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/native/java_lang_reflect_Method.c
Fri Dec 23 07:37:28 2005
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: java_lang_reflect_Method.c,v 1.8 2005/05/15 21:41:01 archiecobbs Exp $
+ * $Id$
  */
 
 #include "libjc.h"
@@ -104,8 +104,8 @@
 {
 	_jc_jvm *const vm = env->vm;
 	_jc_type *calling_class;
-	_jc_object *return_obj;
 	_jc_method *method;
+	_jc_value value;
 	int rtype;
 
 	/* Get method */
@@ -115,7 +115,7 @@
 	if (_jc_invoke_virtual(env,
 	    vm->boot.methods.AccessibleObject.isAccessible, this) != JNI_OK)
 		_jc_throw_exception(env);
-	if (env->retval.z)
+	if (env->retval.i)
 		goto accessible;
 
 	/* Check access */
@@ -137,9 +137,44 @@
 	/* Invoke method */
 	if (_jc_reflect_invoke(env, method, obj, params) != JNI_OK)
 		_jc_throw_exception(env);
+	rtype = (method->return_type->flags & _JC_TYPE_MASK);
+
+	/* Convert Java return type to actual Java type */
+	switch (rtype) {
+	case _JC_TYPE_BOOLEAN:
+		value.z = (jboolean)env->retval.i;
+		break;
+	case _JC_TYPE_BYTE:
+		value.b = (jbyte)env->retval.i;
+		break;
+	case _JC_TYPE_CHAR:
+		value.c = (jchar)env->retval.i;
+		break;
+	case _JC_TYPE_SHORT:
+		value.s = (jshort)env->retval.i;
+		break;
+	case _JC_TYPE_INT:
+		value.i = env->retval.i;
+		break;
+	case _JC_TYPE_LONG:
+		value.j = env->retval.j;
+		break;
+	case _JC_TYPE_FLOAT:
+		value.f = env->retval.f;
+		break;
+	case _JC_TYPE_DOUBLE:
+		value.d = env->retval.d;
+		break;
+	case _JC_TYPE_VOID:			/* silence compiler warning */
+	case _JC_TYPE_REFERENCE:
+		value.l = env->retval.l;
+		break;
+	default:
+		_JC_ASSERT(JNI_FALSE);
+		break;
+	}
 
 	/* Wrap return value */
-	rtype = (method->return_type->flags & _JC_TYPE_MASK);
 	switch (rtype) {
 	case _JC_TYPE_BOOLEAN:
 	case _JC_TYPE_BYTE:
@@ -149,24 +184,22 @@
 	case _JC_TYPE_LONG:
 	case _JC_TYPE_FLOAT:
 	case _JC_TYPE_DOUBLE:
-		if ((return_obj = _jc_wrap_primitive(env,
-		    rtype, &env->retval)) == NULL)
+		if ((obj = _jc_wrap_primitive(env, rtype, &value)) == NULL)
 			_jc_throw_exception(env);
 		break;
 	case _JC_TYPE_VOID:
-		return_obj = NULL;
+		obj = NULL;
 		break;
 	case _JC_TYPE_REFERENCE:
-		return_obj = env->retval.l;
+		obj = value.l;
 		break;
 	default:
 		_JC_ASSERT(JNI_FALSE);
-		return_obj = NULL;		/* silence compiler warning */
 		break;
 	}
 
 	/* Done */
-	return return_obj;
+	return obj;
 }
 
 /*

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=358818&r1=358817&r2=358818&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 Dec
23 07:37:28 2005
@@ -728,7 +728,37 @@
 	if ((status = _jc_invoke_virtual(env,
 	    vm->boot.methods.prim_wrapper[ptype].value, obj)) != JNI_OK)
 		return status;
-	*value = env->retval;
+
+	/* Convert Java return type to actual Java type */
+	switch (ptype) {
+	case _JC_TYPE_BOOLEAN:
+		value->z = (jboolean)env->retval.i;
+		break;
+	case _JC_TYPE_BYTE:
+		value->b = (jbyte)env->retval.i;
+		break;
+	case _JC_TYPE_CHAR:
+		value->c = (jchar)env->retval.i;
+		break;
+	case _JC_TYPE_SHORT:
+		value->s = (jshort)env->retval.i;
+		break;
+	case _JC_TYPE_INT:
+		value->i = env->retval.i;
+		break;
+	case _JC_TYPE_LONG:
+		value->j = env->retval.j;
+		break;
+	case _JC_TYPE_FLOAT:
+		value->f = env->retval.f;
+		break;
+	case _JC_TYPE_DOUBLE:
+		value->d = env->retval.d;
+		break;
+	default:
+		_JC_ASSERT(JNI_FALSE);
+		break;
+	}
 
 	/* Done */
 	return ptype;

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=358818&r1=358817&r2=358818&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
Dec 23 07:37:28 2005
@@ -245,7 +245,7 @@
 	_jc_c_stack			*c_stack;	/* c stack chunks */
 
 	/* Thread info */
-	_jc_value			retval;		/* invoke rtn value */
+	_jc_rvalue			retval;		/* invoke rtn value */
 	volatile _jc_word		status;		/* JC_THRDSTAT_* */
 	jint				thread_id;	/* unique thread id */
 	_jc_object			*instance;	/* java.lang.Thread */



Mime
View raw message