summaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2005-09-06 16:01:31 +0000
committerTom Tromey <tromey@gcc.gnu.org>2005-09-06 16:01:31 +0000
commit852993e3817924f37fdfa9d8c6b191cb30934cfb (patch)
tree3a53772caa4302c9e6c17a8f4d8ff1296f451bb1 /libjava
parent3e248b831501dcc1b222a2f27e880eff0b54e523 (diff)
downloadgcc-852993e3817924f37fdfa9d8c6b191cb30934cfb.tar.gz
re PR libgcj/23739 (JNI: IsAssignableFrom reverses arguments)
PR libgcj/23739: * testsuite/libjava.jni/pr23739.c: New file. * testsuite/libjava.jni/pr23739.java: New file. * testsuite/libjava.jni/pr23739.out: New file. * jni.cc (_Jv_JNI_IsAssignableFrom): Reversed arguments. * java/lang/reflect/natMethod.cc (invoke): Updated. * java/lang/natClass.cc (isAssignableFrom): Updated. (isInstance): Likewise. (_Jv_IsAssignableFrom): Reversed arguments. (_Jv_IsInstanceOf): Updated. (_Jv_CheckCast): Likewise. (_Jv_CheckArrayStore): Likewise. (_Jv_IsAssignableFromSlow): Reversed arguments. (_Jv_InterfaceAssignableFrom): Likewise. * link.cc (verify_type_assertions): Updated. * prims.cc (_Jv_CheckAccess): Updated. From-SVN: r103953
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog19
-rw-r--r--libjava/java/lang/natClass.cc24
-rw-r--r--libjava/java/lang/reflect/natMethod.cc2
-rw-r--r--libjava/jni.cc2
-rw-r--r--libjava/link.cc2
-rw-r--r--libjava/prims.cc2
-rw-r--r--libjava/testsuite/Makefile.in2
-rw-r--r--libjava/testsuite/libjava.jni/pr23739.c12
-rw-r--r--libjava/testsuite/libjava.jni/pr23739.java22
-rw-r--r--libjava/testsuite/libjava.jni/pr23739.out3
10 files changed, 73 insertions, 17 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 2dd4b703c81..b8c11d90ee3 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,22 @@
+2005-09-06 Tom Tromey <tromey@redhat.com>
+
+ PR libgcj/23739:
+ * testsuite/libjava.jni/pr23739.c: New file.
+ * testsuite/libjava.jni/pr23739.java: New file.
+ * testsuite/libjava.jni/pr23739.out: New file.
+ * jni.cc (_Jv_JNI_IsAssignableFrom): Reversed arguments.
+ * java/lang/reflect/natMethod.cc (invoke): Updated.
+ * java/lang/natClass.cc (isAssignableFrom): Updated.
+ (isInstance): Likewise.
+ (_Jv_IsAssignableFrom): Reversed arguments.
+ (_Jv_IsInstanceOf): Updated.
+ (_Jv_CheckCast): Likewise.
+ (_Jv_CheckArrayStore): Likewise.
+ (_Jv_IsAssignableFromSlow): Reversed arguments.
+ (_Jv_InterfaceAssignableFrom): Likewise.
+ * link.cc (verify_type_assertions): Updated.
+ * prims.cc (_Jv_CheckAccess): Updated.
+
2005-09-05 Ranjit Mathew <rmathew@hotmail.com>
Testsuite changes for PR java/23431.
diff --git a/libjava/java/lang/natClass.cc b/libjava/java/lang/natClass.cc
index 19a9d7d3580..fa52713cc36 100644
--- a/libjava/java/lang/natClass.cc
+++ b/libjava/java/lang/natClass.cc
@@ -623,7 +623,7 @@ java::lang::Class::isAssignableFrom (jclass klass)
// Arguments may not have been initialized, given ".class" syntax.
_Jv_InitClass (this);
_Jv_InitClass (klass);
- return _Jv_IsAssignableFrom (this, klass);
+ return _Jv_IsAssignableFrom (klass, this);
}
jboolean
@@ -632,7 +632,7 @@ java::lang::Class::isInstance (jobject obj)
if (! obj)
return false;
_Jv_InitClass (this);
- return _Jv_IsAssignableFrom (this, JV_CLASS (obj));
+ return _Jv_IsAssignableFrom (JV_CLASS (obj), this);
}
jobject
@@ -964,7 +964,7 @@ _Jv_LookupInterfaceMethodIdx (jclass klass, jclass iface, int method_idx)
}
jboolean
-_Jv_IsAssignableFrom (jclass target, jclass source)
+_Jv_IsAssignableFrom (jclass source, jclass target)
{
if (source == target)
return true;
@@ -984,7 +984,7 @@ _Jv_IsAssignableFrom (jclass target, jclass source)
// two interfaces for assignability.
if (__builtin_expect
(source->idt == NULL || source->isInterface(), false))
- return _Jv_InterfaceAssignableFrom (target, source);
+ return _Jv_InterfaceAssignableFrom (source, target);
_Jv_IDispatchTable *cl_idt = source->idt;
_Jv_IDispatchTable *if_idt = target->idt;
@@ -1033,19 +1033,19 @@ _Jv_IsAssignableFrom (jclass target, jclass source)
// superinterface of SOURCE. This is used when SOURCE is also an interface,
// or a class with no interface dispatch table.
jboolean
-_Jv_InterfaceAssignableFrom (jclass iface, jclass source)
+_Jv_InterfaceAssignableFrom (jclass source, jclass iface)
{
for (int i = 0; i < source->interface_count; i++)
{
jclass interface = source->interfaces[i];
if (iface == interface
- || _Jv_InterfaceAssignableFrom (iface, interface))
+ || _Jv_InterfaceAssignableFrom (interface, iface))
return true;
}
if (!source->isInterface()
&& source->superclass
- && _Jv_InterfaceAssignableFrom (iface, source->superclass))
+ && _Jv_InterfaceAssignableFrom (source->superclass, iface))
return true;
return false;
@@ -1056,14 +1056,14 @@ _Jv_IsInstanceOf(jobject obj, jclass cl)
{
if (__builtin_expect (!obj, false))
return false;
- return (_Jv_IsAssignableFrom (cl, JV_CLASS (obj)));
+ return _Jv_IsAssignableFrom (JV_CLASS (obj), cl);
}
void *
_Jv_CheckCast (jclass c, jobject obj)
{
if (__builtin_expect
- (obj != NULL && ! _Jv_IsAssignableFrom(c, JV_CLASS (obj)), false))
+ (obj != NULL && ! _Jv_IsAssignableFrom(JV_CLASS (obj), c), false))
throw new java::lang::ClassCastException
((new java::lang::StringBuffer
(obj->getClass()->getName()))->append
@@ -1084,7 +1084,7 @@ _Jv_CheckArrayStore (jobject arr, jobject obj)
return;
jclass obj_class = JV_CLASS (obj);
if (__builtin_expect
- (! _Jv_IsAssignableFrom (elt_class, obj_class), false))
+ (! _Jv_IsAssignableFrom (obj_class, elt_class), false))
throw new java::lang::ArrayStoreException
((new java::lang::StringBuffer
(JvNewStringUTF("Cannot store ")))->append
@@ -1095,7 +1095,7 @@ _Jv_CheckArrayStore (jobject arr, jobject obj)
}
jboolean
-_Jv_IsAssignableFromSlow (jclass target, jclass source)
+_Jv_IsAssignableFromSlow (jclass source, jclass target)
{
// First, strip arrays.
while (target->isArray ())
@@ -1129,7 +1129,7 @@ _Jv_IsAssignableFromSlow (jclass target, jclass source)
{
// We use a recursive call because we also need to
// check superinterfaces.
- if (_Jv_IsAssignableFromSlow (target, source->getInterface (i)))
+ if (_Jv_IsAssignableFromSlow (source->getInterface (i), target))
return true;
}
}
diff --git a/libjava/java/lang/reflect/natMethod.cc b/libjava/java/lang/reflect/natMethod.cc
index b616d1bab63..94bc49be548 100644
--- a/libjava/java/lang/reflect/natMethod.cc
+++ b/libjava/java/lang/reflect/natMethod.cc
@@ -163,7 +163,7 @@ java::lang::reflect::Method::invoke (jobject obj, jobjectArray args)
else
{
jclass objClass = JV_CLASS (obj);
- if (! _Jv_IsAssignableFrom (declaringClass, objClass))
+ if (! _Jv_IsAssignableFrom (objClass, declaringClass))
throw new java::lang::IllegalArgumentException;
}
diff --git a/libjava/jni.cc b/libjava/jni.cc
index 59b380c1a60..13bb12cf5dd 100644
--- a/libjava/jni.cc
+++ b/libjava/jni.cc
@@ -552,7 +552,7 @@ _Jv_JNI_GetSuperclass (JNIEnv *env, jclass clazz)
static jboolean JNICALL
_Jv_JNI_IsAssignableFrom (JNIEnv *, jclass clazz1, jclass clazz2)
{
- return unwrap (clazz1)->isAssignableFrom (unwrap (clazz2));
+ return unwrap (clazz2)->isAssignableFrom (unwrap (clazz1));
}
static jint JNICALL
diff --git a/libjava/link.cc b/libjava/link.cc
index 5411f4aacca..7e51a2670e3 100644
--- a/libjava/link.cc
+++ b/libjava/link.cc
@@ -1620,7 +1620,7 @@ _Jv_Linker::verify_type_assertions (jclass klass)
if (cl1 == NULL || cl2 == NULL)
continue;
- if (! _Jv_IsAssignableFromSlow (cl2, cl1))
+ if (! _Jv_IsAssignableFromSlow (cl1, cl2))
{
jstring s = JvNewStringUTF ("Incompatible types: In class ");
s = s->concat (klass->getName());
diff --git a/libjava/prims.cc b/libjava/prims.cc
index af177241acf..ba5c9efd260 100644
--- a/libjava/prims.cc
+++ b/libjava/prims.cc
@@ -1557,7 +1557,7 @@ _Jv_CheckAccess (jclass self_klass, jclass other_klass, jint flags)
return ((self_klass == other_klass)
|| ((flags & Modifier::PUBLIC) != 0)
|| (((flags & Modifier::PROTECTED) != 0)
- && _Jv_IsAssignableFromSlow (other_klass, self_klass))
+ && _Jv_IsAssignableFromSlow (self_klass, other_klass))
|| (((flags & Modifier::PRIVATE) == 0)
&& _Jv_ClassNameSamePackage (self_klass->name,
other_klass->name)));
diff --git a/libjava/testsuite/Makefile.in b/libjava/testsuite/Makefile.in
index 074fda1a1dd..4a8ea65ca0a 100644
--- a/libjava/testsuite/Makefile.in
+++ b/libjava/testsuite/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.4 from Makefile.am.
+# Makefile.in generated by automake 1.9.3 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
diff --git a/libjava/testsuite/libjava.jni/pr23739.c b/libjava/testsuite/libjava.jni/pr23739.c
new file mode 100644
index 00000000000..0f6bfbefe16
--- /dev/null
+++ b/libjava/testsuite/libjava.jni/pr23739.c
@@ -0,0 +1,12 @@
+#include <stdio.h>
+#include "pr23739.h"
+
+JNIEXPORT void JNICALL
+Java_pr23739_checkOrder (JNIEnv *env, jclass cls, jclass clazz1, jclass clazz2)
+{
+ printf ("B extends A\n");
+ printf ("isAssignableFrom (A, B): %d\n",
+ (*env)->IsAssignableFrom (env, clazz1, clazz2));
+ printf ("isAssignableFrom (B, A): %d\n",
+ (*env)->IsAssignableFrom (env, clazz2, clazz1));
+}
diff --git a/libjava/testsuite/libjava.jni/pr23739.java b/libjava/testsuite/libjava.jni/pr23739.java
new file mode 100644
index 00000000000..b2e54c5488b
--- /dev/null
+++ b/libjava/testsuite/libjava.jni/pr23739.java
@@ -0,0 +1,22 @@
+public class pr23739
+{
+ static
+ {
+ System.loadLibrary ("pr23739");
+ }
+
+ public static class A
+ {
+ }
+
+ public static class B extends A
+ {
+ }
+
+ static native void checkOrder (Class clazz1, Class clazz2);
+
+ public static void main (String[] args)
+ {
+ checkOrder (A.class, B.class);
+ }
+}
diff --git a/libjava/testsuite/libjava.jni/pr23739.out b/libjava/testsuite/libjava.jni/pr23739.out
new file mode 100644
index 00000000000..3e94564c244
--- /dev/null
+++ b/libjava/testsuite/libjava.jni/pr23739.out
@@ -0,0 +1,3 @@
+B extends A
+isAssignableFrom (A, B): 0
+isAssignableFrom (B, A): 1