[PATCH] java.lang.Class newInstance fixes

Dalibor Topic robilad at yahoo.com
Mon Mar 4 08:07:55 PST 2002


Hi,

I've been running into a few bugs with reflection, so I wrote a
small patch that fixes some issues with java.lang.Class. I reimplemented
newInstance in Java, since it could be done without directly using
native methods.

have fun.

dali


-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-diff
Size: 5012 bytes
Desc: not available
Url : http://kaffe.org/pipermail/kaffe/attachments/20020304/9e246d96/attachment-0003.diff 
-------------- next part --------------
	* libraries/clib/native/Class.c:
	(java_lang_Class_newInstance) removed.
	(checkParameters) fixed NullPointerException if argtypes were
	NULL, but the method didn't take 0 arguments.
	(checkIfClassHasFailed) new function.
	(java_lang_Class_getMethod0) added call to checkIfClassHasFailed,
	to avoid fiddling with classes that didn't load and link properly.
	(java_lang_Class_getConstructor0) added call to checkIfClassHasFailed,
	to avoid fiddling with classes that didn't load and link
	properly. Use METHOD_IS_CONSTRUCTOR instead of bit operations.
	
	* libraries/javalib/java/lang/Class.java:
	(newInstance) reimplemented in Java using reflection. Added checks
	for interfaces and abstract classes.
	
	* test/regression/ConstructorTest.java:
	Changed expected exception to InstantiationException, since the
	spec implies that an InstantiationException is thrown if the call
	to newInstance fails for some reason.


More information about the kaffe mailing list