summaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2000-01-06 00:56:21 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2000-01-06 00:56:21 +0000
commit14f3e5c4a4777d57486a5fe6784ab3693b6dd607 (patch)
tree1965e52244bebcbaf8849bb44cebccffca987422 /libjava
parentf87e616157221fd1ac7abc60eac4e4f424d32ab3 (diff)
downloadgcc-14f3e5c4a4777d57486a5fe6784ab3693b6dd607.tar.gz
* java/lang/natClass.cc (getMethod): Compute offset relative to
`klass's methods table, not `this's table. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In unwrapping/widening case, check whether `k' is null, not whether it is primitive. Initialize `num' from `argelts', not `paramelts'. Correct create and pass arguments to ffi_call. Don't let presence of `this' argument affect index used to look in argument arrays. (COPY): Set appropriate element in `values' vector. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@31253 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog11
-rw-r--r--libjava/java/lang/natClass.cc3
-rw-r--r--libjava/java/lang/reflect/natMethod.cc49
3 files changed, 38 insertions, 25 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index e2c2d7143ae..e0ffb0e9ed9 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,5 +1,16 @@
2000-01-05 Tom Tromey <tromey@cygnus.com>
+ * java/lang/natClass.cc (getMethod): Compute offset relative to
+ `klass's methods table, not `this's table.
+
+ * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA):
+ In unwrapping/widening case, check whether `k' is null, not
+ whether it is primitive. Initialize `num' from `argelts', not
+ `paramelts'. Correct create and pass arguments to ffi_call.
+ Don't let presence of `this' argument affect index used to look in
+ argument arrays.
+ (COPY): Set appropriate element in `values' vector.
+
* java/lang/natClass.cc: Include <gcj/method.h>.
* java/lang/Class.h (_getMethods): Correctly declare as private,
diff --git a/libjava/java/lang/natClass.cc b/libjava/java/lang/natClass.cc
index 68905f542f8..533f7abf102 100644
--- a/libjava/java/lang/natClass.cc
+++ b/libjava/java/lang/natClass.cc
@@ -477,7 +477,8 @@ java::lang::Class::getMethod (jstring name, JArray<jclass> *param_types)
break;
Method *rmethod = new Method ();
- rmethod->offset = (char*) (&klass->methods[i]) - (char*) methods;
+ rmethod->offset = ((char *) (&klass->methods[i])
+ - (char *) klass->methods);
rmethod->declaringClass = klass;
return rmethod;
}
diff --git a/libjava/java/lang/reflect/natMethod.cc b/libjava/java/lang/reflect/natMethod.cc
index 62f0ab9f22d..14708d13468 100644
--- a/libjava/java/lang/reflect/natMethod.cc
+++ b/libjava/java/lang/reflect/natMethod.cc
@@ -374,21 +374,21 @@ _Jv_CallNonvirtualMethodA (jobject obj,
size += sizeof (jobject);
}
- for (; i < param_count; ++i)
+ for (int arg = 0; i < param_count; ++i, ++arg)
{
- jclass k = argelts[i] ? argelts[i]->getClass() : NULL;
+ jclass k = argelts[arg] ? argelts[arg]->getClass() : NULL;
argtypes[i] = get_ffi_type (k);
- if (paramelts[i]->isPrimitive())
+ if (paramelts[arg]->isPrimitive())
{
- if (! argelts[i]
- || ! k->isPrimitive ()
- || ! can_widen (k, paramelts[i]))
+ if (! argelts[arg]
+ || ! k
+ || ! can_widen (k, paramelts[arg]))
JvThrow (new java::lang::IllegalArgumentException);
- size += paramelts[i]->size();
+ size += paramelts[arg]->size();
}
else
{
- if (argelts[i] && ! paramelts[i]->isAssignableFrom (k))
+ if (argelts[arg] && ! paramelts[arg]->isAssignableFrom (k))
JvThrow (new java::lang::IllegalArgumentException);
size += sizeof (jobject);
}
@@ -401,13 +401,14 @@ _Jv_CallNonvirtualMethodA (jobject obj,
// FIXME: throw some kind of VirtualMachineError here.
}
- char *values = (char *) alloca (size);
- char *p = values;
+ char *p = (char *) alloca (size);
+ void **values = (void **) alloca (param_count * sizeof (void *));
#define COPY(Where, What, Type) \
do { \
Type val = (What); \
memcpy ((Where), &val, sizeof (Type)); \
+ values[i] = (Where); \
Where += sizeof (Type); \
} while (0)
@@ -418,30 +419,30 @@ _Jv_CallNonvirtualMethodA (jobject obj,
++i;
}
- for (; i < param_count; ++i)
+ for (int arg = 0; i < param_count; ++i, ++arg)
{
- java::lang::Number *num = (java::lang::Number *) paramelts[i];
- if (paramelts[i] == JvPrimClass (byte))
+ java::lang::Number *num = (java::lang::Number *) argelts[arg];
+ if (paramelts[arg] == JvPrimClass (byte))
COPY (p, num->byteValue(), jbyte);
- else if (paramelts[i] == JvPrimClass (short))
+ else if (paramelts[arg] == JvPrimClass (short))
COPY (p, num->shortValue(), jshort);
- else if (paramelts[i] == JvPrimClass (int))
+ else if (paramelts[arg] == JvPrimClass (int))
COPY (p, num->intValue(), jint);
- else if (paramelts[i] == JvPrimClass (long))
+ else if (paramelts[arg] == JvPrimClass (long))
COPY (p, num->longValue(), jlong);
- else if (paramelts[i] == JvPrimClass (float))
+ else if (paramelts[arg] == JvPrimClass (float))
COPY (p, num->floatValue(), jfloat);
- else if (paramelts[i] == JvPrimClass (double))
+ else if (paramelts[arg] == JvPrimClass (double))
COPY (p, num->doubleValue(), jdouble);
- else if (paramelts[i] == JvPrimClass (boolean))
- COPY (p, ((java::lang::Boolean *) argelts[i])->booleanValue(),
+ else if (paramelts[arg] == JvPrimClass (boolean))
+ COPY (p, ((java::lang::Boolean *) argelts[arg])->booleanValue(),
jboolean);
- else if (paramelts[i] == JvPrimClass (char))
- COPY (p, ((java::lang::Character *) argelts[i])->charValue(), jchar);
+ else if (paramelts[arg] == JvPrimClass (char))
+ COPY (p, ((java::lang::Character *) argelts[arg])->charValue(), jchar);
else
{
- JvAssert (! paramelts[i]->isPrimitive());
- COPY (p, argelts[i], jobject);
+ JvAssert (! paramelts[arg]->isPrimitive());
+ COPY (p, argelts[arg], jobject);
}
}