natClass.cc (_Jv_LayoutInterfaceMethods): New method.
authorBryce McKinlay <mckinlay@redhat.com>
Wed, 21 Apr 2004 19:26:22 +0000 (19:26 +0000)
committerBryce McKinlay <bryce@gcc.gnu.org>
Wed, 21 Apr 2004 19:26:22 +0000 (20:26 +0100)
2004-04-21  Bryce McKinlay  <mckinlay@redhat.com>

        * java/lang/natClass.cc (_Jv_LayoutInterfaceMethods): New method.
        Set method->index values for interface methods to their itable
index.
        (initializeClass): Call _Jv_LayoutInterfaceMethods.

From-SVN: r80978

libjava/ChangeLog
libjava/java/lang/Class.h
libjava/java/lang/natClass.cc

index 56bcc3278645bdd9fab2939df2ede30f51ea5740..b5a60bd1216717d7e9a228fb338e0c784df4c849 100644 (file)
@@ -1,3 +1,9 @@
+2004-04-21  Bryce McKinlay  <mckinlay@redhat.com>
+
+       * java/lang/natClass.cc (_Jv_LayoutInterfaceMethods): New method.
+       Set method->index values for interface methods to their itable index.
+       (initializeClass): Call _Jv_LayoutInterfaceMethods.
+
 2004-04-21  Michael Koch  <konqueror@gmx.de>
 
        * java/nio/DirectByteBufferImpl.java
index 86dc6a079db68b131a5162aa9b3a9ad97d68819c..e93920c06b51583bf1e2b8cb2b1eec02b2335d18 100644 (file)
@@ -339,6 +339,7 @@ private:
   friend jshort _Jv_AppendPartialITable (jclass, jclass, void **, jshort);
   friend jshort _Jv_FindIIndex (jclass *, jshort *, jshort);
   friend void _Jv_LinkSymbolTable (jclass);
+  friend void _Jv_LayoutInterfaceMethods (jclass);
   friend void _Jv_LayoutVTableMethods (jclass klass);
   friend void _Jv_SetVTableEntries (jclass, _Jv_VTable *, jboolean *);
   friend void _Jv_MakeVTable (jclass);
index 419ed7d9d293131187971d7b0ceb0a1611572233..3ceda11238f58b0e1d98b27761d0758cdde4e140 100644 (file)
@@ -790,6 +790,9 @@ java::lang::Class::initializeClass (void)
        }
     }
 
+  if (isInterface ())
+    _Jv_LayoutInterfaceMethods (this);
+
   _Jv_PrepareConstantTimeTables (this);
 
   if (vtable == NULL)
@@ -1787,6 +1790,20 @@ _Jv_abstractMethodError (void)
   throw new java::lang::AbstractMethodError();
 }
 
+// Set itable method indexes for members of interface IFACE.
+void
+_Jv_LayoutInterfaceMethods (jclass iface)
+{
+  if (! iface->isInterface())
+    return;
+  
+  // itable indexes start at 1. 
+  // FIXME: Static initalizers currently get a NULL placeholder entry in the
+  // itable so they are also assigned an index here.
+  for (int i = 0; i < iface->method_count; i++)
+    iface->methods[i].index = i + 1;
+}
+
 // Prepare virtual method declarations in KLASS, and any superclasses as 
 // required, by determining their vtable index, setting method->index, and
 // finally setting the class's vtable_method_count. Must be called with the