[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with 1.2.4 classfiles.. ?



Etienne M. Gagnon wrote:
> > Don't look at the Jimple code, look at the classfile itself.
> > It has: INVOKEVIRTUAL AbstractValueBox.canContainValue().
> 
> Ah!  You're right. This does make sense, and I think where the bug is,
> in SableVM.  I should add inherited interface methods into the normal
> virtual table of abstract classes.

Here's a workaround I've been using that seems to fix things.

This may be more memory efficient, since it avoids the extra
vtable entries, at the cost of slightly slower instruction
preparation time (because virtual methods are searched before
interface methods).

-Archie

__________________________________________________________________________
Archie Cobbs     *     Packet Design     *     http://www.packetdesign.com

--- work/sablevm-1.0.5/src/libsablevm/instructions.m4.c.orig	Tue Sep 10 10:35:39 2002
+++ work/sablevm-1.0.5/src/libsablevm/instructions.m4.c	Mon Dec 16 17:28:28 2002
@@ -4838,10 +4838,28 @@
 	  }
 
 	  addr[0].jint = methodref_info->method->java_args_count;
-	  addr[1].offset =
-	    sizeof (_svmt_vtable) +
-	    (methodref_info->method->method_id *
-	     sizeof (_svmt_method_info *));
+
+	  /*
+	   * _svmf_resolve_CONSTANT_Methodref() may return an interface
+	   * method in certain situations (e.g., invoking an interface
+	   * method that's implemented in a subclass of an abstract class
+	   * not implementing the method but implementing the interface).
+	   */
+	  if (_svmf_is_set_flag
+	      (methodref_info->method->class_info->access_flags,
+	       SVM_ACC_INTERFACE))
+	    {
+	      addr[1].offset =
+		-((1 + methodref_info->method->method_id) *
+		  sizeof (_svmt_method_info *));
+	    }
+	  else
+	    {
+	      addr[1].offset =
+		sizeof (_svmt_vtable) +
+		(methodref_info->method->method_id *
+		 sizeof (_svmt_method_info *));
+	    }
 
 	  /* execute bytecode */
 	  {