Bug inside Class.isAssignableFrom(Class) ?
Submitted by Fabien D on Fri, 04/16/2004 - 16:35.
By calling :
Test.class.isAssignableFrom(superClass)
I have a NullPointerException in VmType.isAssignableFrom(VmType S)
Here is the begin of the method :
public boolean isAssignableFrom(VmType S) {
final VmType[] superClassesArray = S.superClassesArray;
System.out.println("superClassesArray="+superClassesArray); I added this line, superClassesArray is null
final int length = superClassesArray.length; The NPE is at this line
.....................
Apparently this array (superClassesArray) is uninitialized.
The Test class is an interface from JUnit. superClass inherits (indirectly) from Test.
I don't know if it's important but I have declared the junit.jar as a system plugin.
- Login to post comments
Bug fixed
I think the bug has been fixed. Please verify.
Make sure to update from CVS HEAD first, since a lot has changed.
JUnit is added as dependency of the test plugin, so it's classes can be found.
Make sure to load the test plugins, because they are not loaded by default.
Do.
- plugin addloader ...
- plugin load org.jnode.shell.command.test
- plugin load org.... your test plugin
- test org...your test class
PS. You can now also reload plugins (with plugin reload ...)
JUnit is NOT a system plugin
See subject.
OK, but the bug is still here without the patch
I agree with you but the bug isn't related to the fact JUnit is or isn't a system plugin.
By desactivating the patch and using JUnit as a normal plugin, the bug is still here.
createSuperClassesArray should be but is not called !
the parameter superClass is my class BasicFSTest, here is its hierarchy :
BasicFSTest -> AbstractFSTest -> JNTestCase -> TestCase -> Assert,Test
I put a trace in createSuperClassesArray and found that it is called for : JNTestCase, TestCase, Assert and Test
But not for AbstractFSTest and BasicFSTest !
Here is a test I made : System.out.println("T1="+Test.class.isAssignableFrom(Assert.class));
System.out.println("T2="+Test.class.isAssignableFrom(TestCase.class));
System.out.println("T3="+Test.class.isAssignableFrom(JNTestCase.class));
System.out.println("T4="+Test.class.isAssignableFrom(AbstractFSTest.class)); System.out.println("T5="+Test.class.isAssignableFrom(BasicFSTest.class));
It failed at evaluating T3 with the same NPE at same line.
I send a fix to Ewout
I send a fix to Ewout.
Fabien.