These are some more patches for japhar:
  - A Method is limited to 256 parameters according to jvm spec.
  - Wrong env parameter in java.io.File.seek()
  - We have to recursively search for interface methods.  This
    really happened to me on the Set interface, which inherits
    most methods from Collection.
  - LL_x2L and LL_L2x:  Parameters were also in wrong order for x=F,D.

BTW: My bytecode verifier for japhar is under construction, if you want
to take a look at it:

http://www.informatik.uni-oldenburg.de/~delwi/japhar/verifier 

But it doesn't even compile yet, and some important methods are still
missing.

  Jochen

diff -Nur japhar-19991126/include/runtime.h japhar/include/runtime.h
--- japhar-19991126/include/runtime.h   Wed Nov  3 07:08:55 1999
+++ japhar/include/runtime.h    Tue Nov 30 18:40:34 1999
@@ -126,7 +126,7 @@
   HVMSigTag tag;  
   char *return_type;
   int num_params;
-  char *params[100];
+  char *params[256];
 } HVMMethodSigStruct;
 
 typedef struct {
diff -Nur japhar-19991126/lib/libnative/java.io/filein.c 
japhar/lib/libnative/java.io/filein.c
--- japhar-19991126/lib/libnative/java.io/filein.c      Mon Oct 25 09:10:10 1999
+++ japhar/lib/libnative/java.io/filein.c       Tue Nov 30 18:40:34 1999
@@ -79,7 +79,7 @@
                                  jlong skip_amount)
 {
   HungryEnv *henv = HVM_ThreadGetEnv();
-  int fd = get_file_descriptor(env, obj);
+  int fd = get_file_descriptor(henv, obj);
   off_t pos = 0, newpos = 0;
   pos = lseek(fd, 0, SEEK_CUR);
   newpos = lseek(fd, skip_amount, SEEK_CUR);
diff -Nur japhar-19991126/lib/libruntime/clparse.c japhar/lib/libruntime/clparse.c
--- japhar-19991126/lib/libruntime/clparse.c    Tue Oct 26 22:13:31 1999
+++ japhar/lib/libruntime/clparse.c     Tue Nov 30 18:44:15 1999
@@ -322,7 +322,7 @@
       if (method->code_length)
         {
           method->code = (PRUint8*)PR_Calloc(method->code_length,
-                                          sizeof(PRUint8));
+                                             sizeof(PRUint8));
 
           memcpy(method->code, buf + *buf_pos, method->code_length);
           *buf_pos += method->code_length;
@@ -334,7 +334,7 @@
         {
           int i;
           method->exceptions = 
(ExceptionBlock*)PR_Calloc(method->num_exception_blocks,
-                                                       sizeof(ExceptionBlock));
+                                                          sizeof(ExceptionBlock));
 
           for (i = 0;
                i < method->num_exception_blocks;
@@ -1208,7 +1208,6 @@
            entry->res_method_info.sig_str = sig_str;
          }
 
-
        for (i = 0; i < method_clazz->num_methods; i ++)
          {
            if (!PL_strcmp(method_clazz->methods[i].name, method_name)
@@ -1377,6 +1376,29 @@
   return clazz->vmethods[virtual_method->index];
 }
 
+static MethodStruct *
+internalResolveInterfaceMethod(ClazzFile * method_clazz,
+                         const char* name_str, const char* sig_str) {
+  int i;
+  for (i = 0; i < method_clazz->num_methods; i ++)
+    {
+      if (!PL_strcmp(method_clazz->methods[i].name, name_str)
+          && !PL_strcmp(method_clazz->methods[i].sig_str, sig_str))
+        {
+          return &method_clazz->methods[i];
+        }
+    }
+      
+  for (i = 0; i < method_clazz->num_interfaces; i++)
+    {
+      MethodStruct *method = internalResolveInterfaceMethod
+        (method_clazz->interface_tuples[i].interface, name_str, sig_str);
+      if (method != NULL)
+        return method;
+    }
+  return NULL;
+}
+
 MethodStruct *
 ResolveInterfaceMethod(HungryEnv *henv, ClazzFile *clazz,
                        ConstantPoolEntry *constant,
@@ -1402,22 +1424,10 @@
              clazz->constants[
               
constant->interfacemethodref_info.name_and_type_index].nameandtype_info.name_index]);
       
-      constant->res_interfacemethodref_info.tag |= CONSTANT_RESOLVED;
-      constant->res_interfacemethodref_info.name = name_str;
-      constant->res_interfacemethodref_info.sig_str = sig_str;
-      
-      for (i = 0; i < method_clazz->num_methods; i ++)
-        {
-          if (!PL_strcmp(method_clazz->methods[i].name, name_str)
-              && !PL_strcmp(method_clazz->methods[i].sig_str, sig_str))
-            {
-              method = &method_clazz->methods[i];
-              break;
-            }
-        }
-      
+      method = internalResolveInterfaceMethod(method_clazz, name_str, sig_str);
       PR_ASSERT(method != NULL);
 
+      constant->res_interfacemethodref_info.tag |= CONSTANT_RESOLVED;
       constant->res_interfacemethodref_info.method = method;
       constant->res_interfacemethodref_info.name = name_str;
       constant->res_interfacemethodref_info.sig_str = sig_str;
diff -Nur japhar-19991126/lib/libruntime/interpfunc.c 
japhar/lib/libruntime/interpfunc.c
--- japhar-19991126/lib/libruntime/interpfunc.c Mon Nov 22 23:12:24 1999
+++ japhar/lib/libruntime/interpfunc.c  Tue Nov 30 18:40:34 1999
@@ -2059,7 +2059,7 @@
 
   op_stack_pop_long(f->_env->op_stack, lvalue);
 
-  LL_L2F(lvalue, fvalue);
+  LL_L2F(fvalue, lvalue);
 
   op_stack_push_float(f->_env->op_stack, fvalue);
 }
@@ -2071,7 +2071,7 @@
 
   op_stack_pop_long(f->_env->op_stack, lvalue);
 
-  LL_L2D(lvalue, dvalue);
+  LL_L2D(dvalue, lvalue);
 
   op_stack_push_double(f->_env->op_stack, dvalue);
 }
@@ -2083,7 +2083,7 @@
 
   op_stack_pop_float(f->_env->op_stack, fvalue);
 
-  LL_F2L(fvalue, lvalue);
+  LL_F2L(lvalue, fvalue);
 
   op_stack_push_long(f->_env->op_stack, lvalue);
 }
@@ -2103,7 +2103,7 @@
 
   op_stack_pop_double(f->_env->op_stack, dvalue);
 
-  LL_D2L(dvalue, lvalue);
+  LL_D2L(lvalue, dvalue);
 
   op_stack_push_long(f->_env->op_stack, lvalue);
 }

Reply via email to