Summary: | JNI: IsAssignableFrom reverses arguments | ||
---|---|---|---|
Product: | gcc | Reporter: | Thomas Fitzsimmons <fitzsim> |
Component: | libgcj | Assignee: | Tom Tromey <tromey> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | gcc-bugs, java-prs |
Priority: | P2 | ||
Version: | 4.1.0 | ||
Target Milestone: | 4.0.2 | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2005-09-05 21:31:13 | |
Attachments: | test case demonstrating incorrect IsAssignableFrom results |
Description
Thomas Fitzsimmons
2005-09-05 18:51:00 UTC
Created attachment 9669 [details]
test case demonstrating incorrect IsAssignableFrom results
To build the test case, run "make" in the iaf directory.
$ make JAVA=gij run
LD_LIBRARY_PATH=. $JAVA iaf
B extends A
isAssignableFrom (A, B): 1
isAssignableFrom (B, A): 0
$ make JAVA=/usr/java/jdk1.5.0_01/bin/java run
LD_LIBRARY_PATH=. $JAVA iaf
B extends A
isAssignableFrom (A, B): 0
isAssignableFrom (B, A): 1
How embarrassing. One question is whether we ought to change CNI to conform. I suspect the answer is 'yes', for clarity's sake. I'm testing a patch IMO Sun actually got it wrong here ;-) Reading function arguments from left-to-right, I'd expect the first argument to be the context ("Is") and the second to be the class refered to in (the "From"). Having said that, it is rather confusing that the order is reversed between JNI and libgcj's internal function. I agree we should fix it, though there are a lot of callers to update. It is not an issue for CNI, because IsAssignableFrom is not exposed as a public CNI function. Subject: Bug 23739 CVSROOT: /cvs/gcc Module name: gcc Changes by: tromey@gcc.gnu.org 2005-09-06 16:01:32 Modified files: libjava : ChangeLog jni.cc link.cc prims.cc libjava/java/lang: natClass.cc libjava/java/lang/reflect: natMethod.cc libjava/testsuite: Makefile.in Added files: libjava/testsuite/libjava.jni: pr23739.c pr23739.java pr23739.out Log message: 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. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&r1=1.3733&r2=1.3734 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/jni.cc.diff?cvsroot=gcc&r1=1.99&r2=1.100 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/link.cc.diff?cvsroot=gcc&r1=1.17&r2=1.18 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/prims.cc.diff?cvsroot=gcc&r1=1.112&r2=1.113 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/java/lang/natClass.cc.diff?cvsroot=gcc&r1=1.89&r2=1.90 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/java/lang/reflect/natMethod.cc.diff?cvsroot=gcc&r1=1.46&r2=1.47 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/Makefile.in.diff?cvsroot=gcc&r1=1.86&r2=1.87 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/libjava.jni/pr23739.c.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/libjava.jni/pr23739.java.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/libjava.jni/pr23739.out.diff?cvsroot=gcc&r1=NONE&r2=1.1 Subject: Bug 23739 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: tromey@gcc.gnu.org 2005-09-06 16:03:12 Modified files: libjava : ChangeLog jni.cc Log message: PR libgcj/23739: * jni.cc (_Jv_JNI_IsAssignableFrom): Reversed arguments. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.3391.2.94&r2=1.3391.2.95 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/jni.cc.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.95.2.1&r2=1.95.2.2 Fix checked in. |