Patch: _Jv_FindClassFromSignature

Jeff Sturm jsturm@one-point.com
Fri Mar 23 05:49:00 GMT 2001


Working through the Jacl testsuite, I found some corner cases that aren't
handled nicely by libgcj.  In particular, user code such as

  Class.forName("[int");

causes libgcj to abort.  Sun's java throws ClassNotFoundException in this
case.  With the patch below libgcj does the same.

Tested on the 3.0 branch.

2000-03-23  Jeff Sturm  <jsturm@one-point.com>

	* prims.cc (_Jv_FindClassFromSignature): Check return of
	recursive call.  Do not abort on invalid signature; return NULL
	instead.

Index: prims.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/prims.cc,v
retrieving revision 1.46.4.1
diff -u -p -r1.46.4.1 prims.cc
--- prims.cc	2001/03/12 07:33:57	1.46.4.1
+++ prims.cc	2001/03/23 13:27:28
@@ -559,10 +559,17 @@ _Jv_FindClassFromSignature (char *sig, j
 
       }
     case '[':
-      return _Jv_GetArrayClass (_Jv_FindClassFromSignature (&sig[1], loader),
+      {
+	jclass cl = _Jv_FindClassFromSignature (&sig[1], loader);
+	if (cl == NULL)
+	  return NULL;
+	return _Jv_GetArrayClass (_Jv_FindClassFromSignature (&sig[1], loader),
 				loader);
+      }
     }
+#if 0
   JvFail ("couldn't understand class signature");
+#endif
   return NULL;			// Placate compiler.
 }
 



More information about the Java-patches mailing list