]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorTom Tromey <tromey@gcc.gnu.org>
Mon, 17 Jan 2005 20:57:04 +0000 (20:57 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Mon, 17 Jan 2005 20:57:04 +0000 (20:57 +0000)
2005-01-17  Andrew Haley  <aph@redhat.com>

* java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): In the case
of virtual dispatch, if we have no method index, and no code
pointer, look a method up by name.

2005-01-17  Tom Tromey  <tromey@redhat.com>

* testsuite/libjava.jni/iface.c: New file.
* testsuite/libjava.jni/iface.out: New file.
* testsuite/libjava.jni/iface.java: New file.

From-SVN: r93776

libjava/ChangeLog
libjava/java/lang/reflect/natMethod.cc

index 2068e78c2970905db2bee18377b19c1c73117b3f..c6137a8dae14b1ef5a817dee46626bb08189e15c 100644 (file)
@@ -1,3 +1,15 @@
+2005-01-17  Andrew Haley  <aph@redhat.com>
+
+       * java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): In the case
+       of virtual dispatch, if we have no method index, and no code
+       pointer, look a method up by name.
+
+2005-01-17  Tom Tromey  <tromey@redhat.com>
+
+       * testsuite/libjava.jni/iface.c: New file.
+       * testsuite/libjava.jni/iface.out: New file.
+       * testsuite/libjava.jni/iface.java: New file.
+
 2004-12-06  Tom Tromey  <tromey@redhat.com>
  
        For PR java/14853:
index 736103b63dd5987527407bd73dd1b6f6497b7fd4..4ff2c9596ae84604b7e989bca501bef7d355fe0f 100644 (file)
@@ -1,6 +1,6 @@
 // natMethod.cc - Native code for Method class.
 
-/* Copyright (C) 1998, 1999, 2000, 2001 , 2002, 2003 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001 , 2002, 2003, 2005 Free Software Foundation
 
    This file is part of libgcj.
 
@@ -464,7 +464,7 @@ _Jv_CallAnyMethodA (jobject obj,
       break;
     }
 
-  void *ncode;
+  void *ncode = meth->ncode;
 
   // FIXME: If a vtable index is -1 at this point it is invalid, so we
   // have to use the ncode.  
@@ -473,16 +473,25 @@ _Jv_CallAnyMethodA (jobject obj,
   // vtable entries, but _Jv_isVirtualMethod() doesn't know that.  We
   // could solve this problem by allocating a vtable index for methods
   // in final classes.
-  if (is_virtual_call 
-      && ! Modifier::isFinal (meth->accflags)
-      && (_Jv_ushort)-1 != meth->index)
-    {
+  if (is_virtual_call)
+    { 
       _Jv_VTable *vtable = *(_Jv_VTable **) obj;
-      ncode = vtable->get_method (meth->index);
-    }
-  else
-    {
-      ncode = meth->ncode;
+      if ((_Jv_ushort)-1 == meth->index)
+       {
+         if (ncode == NULL)
+           // We have no vtable index, and we have no code pointer.
+           // Look method up by name.
+           ncode = _Jv_LookupInterfaceMethod (vtable->clas, 
+                                              meth->name,
+                                              meth->signature);
+       }
+      else
+       { 
+         // We have an index.  If METH is not final, use virtual
+         // dispatch.
+         if (! Modifier::isFinal (meth->accflags))
+           ncode = vtable->get_method (meth->index);
+       }
     }
 
   try