I found two bugs in Japhar.
First, when I cast an Object to an Object[][] (or more specifically, to a
String[][]), Japhar throws a ClassCastException. Yes, it is a String[][].
Digging into the code a bit showed that it was failing because the dimension
check in checkcast() [interpfunc.c] failed. One of the items (f) had a
signature of "[[Ljava/langString;". The other (obj) had a signature of
"[L[Ljava/langString;". I'm not an expert on arrays of object arrays and
their signatures, but I believe the former one it correct. It appears that
all multi-dimensional object arrays in Japhar have class names of the form
"[L[L", which is not correct. (I think). I am attaching a patch to
interpfunc.c that fixes this problem.
I immediately encountered another bug. The instanceof operator is failing
in the multi-dimentional object case as well. If an Object[][] is passed to
a method expecting an Object[], then I test object[x] against Object[], it
fails. This is confusing so I am attaching a sample of the function that
bombs. It recursively dumps multi-dimentional arrays. I don't have time to
look into this one tonight but if I may later if you don't fix it first.
(No promises though). Unlike the previous error, this one isn't a
showstopper for me.
Here's the method that fails. Imagine this is called with a String[][]
passed as 'o'.
private static void
arrayDump(TestHarness harness, Object[] o, String desc)
{
harness.debug("Dumping Object Array: " + desc);
if (o == null)
{
harness.debug("null");
return;
}
for (int i = 0; i < o.length; i++)
if (o[i] instanceof Object[])
^^^^^^^^^^^^^^^^^^^^^^^^^ ----> This the the failed test.
arrayDump(harness, (Object[])o[i], desc + " element " + i);
else
harness.debug(" Element " + i + ": " + o[i]);
}
BTW: Has anyone looked at the Classpath patches I posted yet?
--
Aaron M. Renn ([EMAIL PROTECTED]) http://www.urbanophile.com/arenn/
? lib/libruntime/foo
Index: lib/libruntime/interpfunc.c
===================================================================
RCS file: /cvsroot/hungry/java/japhar/lib/libruntime/interpfunc.c,v
retrieving revision 1.88
diff -u -r1.88 interpfunc.c
--- interpfunc.c 1998/11/07 17:04:57 1.88
+++ interpfunc.c 1999/01/06 05:18:44
@@ -2713,7 +2713,10 @@
get_constant(METHOD(f)->clazz,ob_type));
array_classname = (char*)malloc(strlen(element_classname) + 4);
- sprintf (array_classname, "[L%s;", element_classname);
+ if ((element_classname[0] == '[') && (element_classname[1] == 'L'))
+ sprintf (array_classname, "[%s", element_classname);
+ else
+ sprintf (array_classname, "[L%s;", element_classname);
op_stack_pop_int (ENV(f), OPSTACK(f), &size);