large Class.forName() patch

Jason Baker jbaker at cs.utah.edu
Mon Jan 31 11:57:57 PST 2000


Mo DeJong <mdejong at cygnus.com> writes:

> Ok, if you have a class named "int" then the JVM should load
> that when you call forName("int"). I am not sure what Kaffe
> would do in this case because it already uses the name "int"
> for the primitive class "I". I think the best way to make
> the regression test check for this is to ensure that
> a loaded class (like "int") is not a primitive type.

ClassMethod.c is not to blame, the problem lies in itypes.c.

What happens when GCJ code is loaded after the class int?  You can
solve the forName problem by backing out this change and finding
another way to expose primitive types to GCJ code.  Since GCJ support
doesn't actually work, backing out the change along is another option.

Index: itypes.c
===================================================================
RCS file: /cvs/kaffe/kaffe/kaffe/kaffevm/itypes.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -c -r1.16 -r1.17
*** itypes.c	1999/11/04 20:29:12	1.16
--- itypes.c	1999/11/29 23:44:10	1.17
***************
*** 36,42 ****
--- 36,45 ----
  void
  initPrimClass(Hjava_lang_Class** class, char* name, char sig, int len)
  {
+ 	errorInfo info;
+ 	classEntry* centry;
  	Hjava_lang_Class* clazz = newClass();
+ 
  	if (clazz == 0) {
  		goto bad;
  	}
***************
*** 56,61 ****
--- 59,78 ----
  	TYPE_PRIM_SIZE(clazz) = len;
  	/* prevent any attempt to process those in processClass */
  	clazz->state = CSTATE_COMPLETE;
+ 
+ 	/* Add primitive types to the class pool as well 
+ 	 * This allows us to find them by name---for instance from gcj code.
+ 	 *
+ 	 * Note that a user-defined "class int" is impossible cause "int"
+ 	 * is a keyword.
+ 	 */
+ 	centry = lookupClassEntry(clazz->name, 0, &info);
+ 	if (centry == 0) {
+ 		goto bad;
+ 	}
+ 	clazz->centry = centry;
+ 	centry->class = clazz;
+ 
  	return;
  bad:
  	fprintf(stderr, "not enough memory to run kaffe\n");


Jason


More information about the kaffe mailing list