large Class.forName() patch

Jason Baker jbaker at cs.utah.edu
Tue Feb 1 10:33:01 PST 2000


> 
> > 
> > Jason Baker wrote:
> > > ./developers/fixup.c:    addSymbol("_Jv_intClass", CLASS, "int", "", "");
> > 
> > That code is actually commented out already.  Godmar will have to
> > chime in on its intent.
> > 
> 
> At first, I thought I just fake the java::lang::Class _Jv_intClass structure
> as a big bss symbol.  Then I realized this doesn't work, and the structure
> is now defined in gcj-class.c
> 
> > > ./kaffe/kaffevm/itypes.c:       initPrimClass(&intClass, "int", 'I', 4);
> > 
> > I suggest using some completely bogus, yet human-readable name in this
> > context.  The primitive types should never be looked up by name, so
> > "[int]" or ";primitive int" or ... hmm, looking in the VM spec (for

I like ";int".  (But not on that line, getName() should still work.)

> > invalid name ideas), I noticed actually it says in S2.2 Identifiers:
> > "An identifier must not be ... a keyword in the Java programming
> > language."  So, maybe a class with name 'int' is bogus....  Something
> > that most JVMs don't seem to check, it seems.
> > 
> > > ./libraries/javalib/java/lang/Integer.java:     final public static Class TYPE = Class.getPrimitiveClass("int");
> > 
> > As Jason pointed out, this is an internal hack for Kaffe.  The
> > argument could just as easily be Class.PRIMITIVE_INT_MAGIC
> > 

I said nothing of the kind.  Since getPrimitiveClass doesn't look the
name up in any hashtable, no PRIMITIVE_INT_MAGIC is needed.  But, it
could be changed to do { return forName0(';' + name); }, then the
check for weird primitive classes could be done in java code with
name.charAt(0) == ';'.


> That said, I find Sun's implementation of Class.forName horrible.
> Why do I have use the L; form in an array but not for simple classes?

I'd like to know why the L notation uses dots instead of slashes.

> It makes no sense.  Of course, the JDK doc also doesn't document it.
> And why shouldn't you be able to look primitive classes up by name?

Because they aren't bytecode keywords!

Jason


More information about the kaffe mailing list