Re: [Kaffe] whatever became of my Class.forName() patches?

2000-02-29 Thread Archie Cobbs


Mo DeJong writes:
> Nice catch, that should generate an error too. I added a test case
> for this to my forName tests and attached it to this email.
> 
> Like so right?
> 
> expect("[[Ljava.lang.String",  "Exception"); // need ; at the end of class
> name

OK, I've checked in ArrayForName.java as a new test (that currently
fails) and will wait for Godmar to fix it by checking in his changes
later...

-Archie

___
Archie Cobbs   *   Whistle Communications, Inc.  *   http://www.whistle.com



Re: Class.forName() patches

2000-02-29 Thread Mo DeJong


On Tue, 29 Feb 2000, Archie Cobbs wrote:

> Mo,
> 
> I've applied the following patches -- which are a modification of yours,
> and now four tests are failing:
> 
>   FAIL: Bean.java
>   FAIL: BeanBug.java
>   FAIL: Reflect.java
>   FAIL: ReflectInvoke.java

Ugh.

> Could be my changes but they should be equivalent to yours..
> I think the problem may be that kaffe calls classFromSig()
> on types that are part of a larger string (and not necessarily
> at the end of the string) such as function types.. eg:

Godmar emailed me to say that he was working on some improvements
to my patch that would fix things once and for all. We should wait
for his improved patches and add them instead of my original patch.
I was unaware of this so I thought my original patch had been
lost in the shuffle.

Thanks
Mo Dejong
Red Hat Inc.

>   "(Ljava/lang/String;II)V"
> 
> Please let me know what you want me to do...
> 
> -Archie



Re: [Kaffe] whatever became of my Class.forName() patches?

2000-02-29 Thread Mo DeJong

On Tue, 29 Feb 2000, Archie Cobbs wrote:

> 
> Mo DeJong writes:
> > I was just looking over the ChangeLog and I noticed that my
> > Class.forName() patches never got added. I seem to remember
> > that there was a problem with one of the changes in the patch.
> > I am going to repost my patch minus the change that was
> > causing problems and see if that is acceptable. Does anyone
> > see any problems with the patch in its current form?
> 
> I'm committing it now..

Nice catch, that should generate an error too. I added a test case
for this to my forName tests and attached it to this email.

Like so right?

expect("[[Ljava.lang.String",  "Exception"); // need ; at the end of class
name

Mo DeJong
Red Hat Inc
 
> Quick question: it appears that kaffe accepts "Ljava/lang/String"
> even though you'd think a trailing semi-colon is required.
> Is this what JDK does as well (ie, semi-colon is optional at the
> end of a string)?
> 
> -Archie


public class ArrayForName {

public static void testLoadArray() throws Exception {

// Loading by built-in type ID is not allowed
// int  != I
// boolean  != Z
// long != J
// float!= F
// double   != D
// byte != B
// short!= S
// char != C
// void != V

expect("I", "Exception");
expect("Z", "Exception");
expect("J", "Exception");
expect("F", "Exception");
expect("D", "Exception");
expect("B", "Exception");
expect("S", "Exception");
expect("C", "Exception");
expect("V", "Exception");

// Not possible to load by builtin type name

expect("int", "Exception");
expect("boolean", "Exception");
expect("long","Exception");
expect("float",   "Exception");
expect("double",  "Exception");
expect("byte","Exception");
expect("short",   "Exception");
expect("char","Exception");
expect("void","Exception");

// Test loading an array by built-in type id
// int[]== [I
// int[][]  == [[I
// boolean[]== [Z
// boolean[][]  == [[Z
// long[]   == [J
// long[][] == [[J
// float[]  == [F
// float[][]== [[F
// double[] == [D
// double[][]   == [[D
// byte[]   == [B
// byte[][] == [[B
// short[]  == [S
// short[][]== [[S
// char[]   == [C
// char[][] == [[C

expect("[I",  "int[]");
expect("[[I", "int[][]");
expect("[Z",  "boolean[]");
expect("[[Z", "boolean[][]");
expect("[J",  "long[]");
expect("[[J", "long[][]");
expect("[F",  "float[]");
expect("[[F", "float[][]");
expect("[D",  "double[]");
expect("[[D", "double[][]");
expect("[B",  "byte[]");
expect("[[B", "byte[][]");
expect("[S",  "short[]");
expect("[[S", "short[][]");
expect("[C",  "char[]");
expect("[[C", "char[][]");

// Array of type void is not allowed

expect("[V","Exception");
expect("[[V",   "Exception");
expect("[[[V",  "Exception");

// When loading an array using the built-in
// type id, id must be at end of string

expect("[II",   "Exception");
expect("[ZZ",   "Exception");
expect("[JJ",   "Exception");
expect("[FF",   "Exception");
expect("[DD",   "Exception");
expect("[BB",   "Exception");
expect("[SS",   "Exception");
expect("[CC",   "Exception");
expect("[ZZ",   "Exception");
expect("[C;",   "Exception");
expect("[C\0;&quo

Class.forName() patches

2000-02-29 Thread Archie Cobbs


Mo,

I've applied the following patches -- which are a modification of yours,
and now four tests are failing:

  FAIL: Bean.java
  FAIL: BeanBug.java
  FAIL: Reflect.java
  FAIL: ReflectInvoke.java

Could be my changes but they should be equivalent to yours..
I think the problem may be that kaffe calls classFromSig()
on types that are part of a larger string (and not necessarily
at the end of the string) such as function types.. eg:

  "(Ljava/lang/String;II)V"

Please let me know what you want me to do...

-Archie

___
Archie Cobbs   *   Whistle Communications, Inc.  *   http://www.whistle.com

Index: classMethod.c
===
RCS file: /cvs/kaffe/kaffe/kaffe/kaffevm/classMethod.c,v
retrieving revision 1.75
diff -u -r1.75 classMethod.c
--- classMethod.c   2000/01/19 11:04:31 1.75
+++ classMethod.c   2000/02/29 19:10:24
@@ -2287,6 +2287,12 @@
 
/* Build signature for array type */
if (CLASS_IS_PRIMITIVE (c)) {
+   /* An array of type void is not allowed */
+   if (strcmp(CLASS_CNAME(c), "void") == 0) {
+   postExceptionMessage(einfo, JAVA_LANG(VerifyError),
+   "invalid array of type void");
+   return (0);
+   }
arr_class = CLASS_ARRAY_CACHE(c);
if (arr_class) {
return (arr_class);
Index: itypes.c
===
RCS file: /cvs/kaffe/kaffe/kaffe/kaffevm/itypes.c,v
retrieving revision 1.17
diff -u -r1.17 itypes.c
--- itypes.c1999/11/29 23:44:10 1.17
+++ itypes.c2000/02/29 19:10:24
@@ -136,24 +136,59 @@
const char* start;
const char* end;
 
+   /* Check for primitive types */
+   switch (**strp) {
+   case 'V':
+   cl = voidClass;
+   break;
+   case 'I':
+   cl = intClass;
+   break;
+   case 'Z':
+   cl = booleanClass;
+   break;
+   case 'S':
+   cl = shortClass;
+   break;
+   case 'B':
+   cl = byteClass;
+   break;
+   case 'C':
+   cl = charClass;
+   break;
+   case 'F':
+   cl = floatClass;
+   break;
+   case 'D':
+   cl = doubleClass;
+   break;
+   case 'J':
+   cl = longClass;
+   break;
+   default:
+   cl = 0;
+   break;
+   }
+   if (cl != 0) {
+   if (*++(*strp) != '\0') {
+   postExceptionMessage(einfo, JAVA_LANG(VerifyError),
+   "extra garbage after primitive type in signature");
+   return (NULL);
+   }
+   return cl;
+   }
+
+   /* Check for non-primitive and array types */
switch (*(*strp)++) {
-   case 'V': return (voidClass);
-   case 'I': return (intClass);
-   case 'Z': return (booleanClass);
-   case 'S': return (shortClass);
-   case 'B': return (byteClass);
-   case 'C': return (charClass);
-   case 'F': return (floatClass);
-   case 'D': return (doubleClass);
-   case 'J': return (longClass);
-   case '[': return (lookupArray(classFromSig(strp, loader, einfo),
- einfo));
+   case '[':
+   return lookupArray(classFromSig(strp, loader, einfo), einfo);
+
case 'L':
start = *strp;
-   for (end = start; *end != 0 && *end != ';'; end++)
+   for (end = start; *end != '\0' && *end != ';'; end++)
;
*strp = end;
-   if (*end != 0) {
+   if (*end != '\0') {
(*strp)++;
}
utf8 = utf8ConstNew(start, end - start);
@@ -163,10 +198,17 @@
}
cl = loadClass(utf8, loader, einfo);
utf8ConstRelease(utf8);
+   if (cl != 0 && CLASS_IS_PRIMITIVE(cl)) {
+   postExceptionMessage(einfo, JAVA_LANG(VerifyError),
+   "primitive type folllows `L' in signature");
+   cl = NULL;
+   }
return(cl);
+
default:
/* malformed signature */
-   postException(einfo, JAVA_LANG(VerifyError));
+   postExceptionMessage(einfo, JAVA_LANG(VerifyError),
+   "malformed signature");
return (NULL);
}
 }



Re: [Kaffe] whatever became of my Class.forName() patches?

2000-02-29 Thread Archie Cobbs


Mo DeJong writes:
> I was just looking over the ChangeLog and I noticed that my
> Class.forName() patches never got added. I seem to remember
> that there was a problem with one of the changes in the patch.
> I am going to repost my patch minus the change that was
> causing problems and see if that is acceptable. Does anyone
> see any problems with the patch in its current form?

I'm committing it now..

Quick question: it appears that kaffe accepts "Ljava/lang/String"
even though you'd think a trailing semi-colon is required.
Is this what JDK does as well (ie, semi-colon is optional at the
end of a string)?

-Archie

___
Archie Cobbs   *   Whistle Communications, Inc.  *   http://www.whistle.com



[Kaffe] whatever became of my Class.forName() patches?

2000-02-28 Thread Mo DeJong

I was just looking over the ChangeLog and I noticed that my
Class.forName() patches never got added. I seem to remember
that there was a problem with one of the changes in the patch.
I am going to repost my patch minus the change that was
causing problems and see if that is acceptable. Does anyone
see any problems with the patch in its current form?

Mo Dejong
Red Hat Inc.


Index: kaffe/kaffevm/classMethod.c
===
RCS file: /cvs/kaffe/kaffe/kaffe/kaffevm/classMethod.c,v
retrieving revision 1.75
diff -u -r1.75 classMethod.c
--- kaffe/kaffevm/classMethod.c 2000/01/19 11:04:31 1.75
+++ kaffe/kaffevm/classMethod.c 2000/01/29 01:19:59
@@ -1110,12 +1122,13 @@
}
class = loadClass(utf8, NULL, einfo);
utf8ConstRelease(utf8);
+
if (class != 0) {
if (processClass(class, CSTATE_COMPLETE, einfo) == true) {
return (class);
}
}
-   return (0);
+   return (NULL);
 }
 
 /*
@@ -2281,12 +2294,18 @@
/* If we couldn't resolve the element type, there's no way we can
 * construct the array type.
 */
-   if (c == 0) {
-   return (0);
+   if (c == NULL) {
+   return (NULL);
}
 
/* Build signature for array type */
if (CLASS_IS_PRIMITIVE (c)) {
+   /* An array of type void is not allowed */
+   if (strcmp(CLASS_CNAME(c), "void") == 0) {
+   postException(einfo, JAVA_LANG(VerifyError));
+   return (NULL);
+   }
+
arr_class = CLASS_ARRAY_CACHE(c);
if (arr_class) {
return (arr_class);
@@ -2304,12 +2323,12 @@
arr_name = utf8ConstNew(sig, -1);   /* release before returning */
if (!arr_name) {
postOutOfMemory(einfo);
-   return 0;
+   return (NULL);
}
centry = lookupClassEntry(arr_name, c->loader, einfo);
if (centry == 0) {
utf8ConstRelease(arr_name);
-   return (0);
+   return (NULL);
}
 
if (centry->class != 0) {
Index: kaffe/kaffevm/itypes.c
===
RCS file: /cvs/kaffe/kaffe/kaffe/kaffevm/itypes.c,v
retrieving revision 1.17
diff -u -r1.17 itypes.c
--- kaffe/kaffevm/itypes.c  1999/11/29 23:44:10 1.17
+++ kaffe/kaffevm/itypes.c  2000/01/29 01:19:59
@@ -131,21 +131,49 @@
 Hjava_lang_Class*
 classFromSig(const char** strp, Hjava_lang_ClassLoader* loader, errorInfo *einfo)
 {
-   Hjava_lang_Class* cl;
+   Hjava_lang_Class* cl = NULL;
Utf8Const* utf8;
const char* start;
const char* end;
 
switch (*(*strp)++) {
-   case 'V': return (voidClass);
-   case 'I': return (intClass);
-   case 'Z': return (booleanClass);
-   case 'S': return (shortClass);
-   case 'B': return (byteClass);
-   case 'C': return (charClass);
-   case 'F': return (floatClass);
-   case 'D': return (doubleClass);
-   case 'J': return (longClass);
+   case 'V':
+   if (cl == NULL)
+   cl = voidClass;
+   case 'I':
+   if (cl == NULL)
+   cl = intClass;
+   case 'Z':
+   if (cl == NULL)
+   cl = booleanClass;
+   case 'S':
+   if (cl == NULL)
+   cl = shortClass;
+   case 'B':
+   if (cl == NULL)
+   cl = byteClass;
+   case 'C':
+   if (cl == NULL)
+   cl = charClass;
+   case 'F':
+   if (cl == NULL)
+   cl = floatClass;
+   case 'D':
+   if (cl == NULL)
+   cl = doubleClass;
+   case 'J':
+   if (cl == NULL)
+   cl = longClass;
+
+   if (cl != NULL) {
+   /* If build in type char is not at the end of the string, malformed 
+signature */
+   if (*(*strp) != 0) {
+   postException(einfo, JAVA_LANG(VerifyError));
+   return (NULL);
+   }
+   }
+
+   return (cl);
case '[': return (lookupArray(classFromSig(strp, loader, einfo),
  einfo));
case 'L':
@@ -159,11 +187,17 @@
utf8 = utf8ConstNew(start, end - start);
if (!utf8) {
postOutOfMemory(einfo);
-   return 0;
+   return (NULL);
}