Bug in command invokation
Project: | JNode Core |
Component: | Miscellaneous |
Category: | bug report |
Priority: | minor |
Assigned: | QaDeS |
Status: | closed |
Jump to:
When a command gets executed from the Shell, it first checks if it is a sublcass of "Command", if not, the main method will be called. Otherwise the execute(...) method of the Command gets executed.
See ThreadCommandInvoker$CommandRunner.run(): There via an InvokeAction the execute method gets called, but it the object is allways null. Thus when the execute method is running it doesn't have a "this" context. So every Command accessing a non-static field throws a NullPointerException.
I'm not sure if that is only a bug in ThreadCommandInvoker, which should for sure pass an instance of the Command to InvokeAction too, or if java.lang.reflect.Method.invoke(..) has a bug, too. Should it be possible to call a non-static method with Object being null?
UPDATE:
This issue contains two bugs. One is the CommandInvoker has to pass an instance of the Command and second, the reflect code should not invoke a non-static method without an instance, it has to throw a NullPointerException.
- Login to post comments
#1
Here is a patch for the bug in java.lang.reflect.Method#invoke.
There are a number of problems in ThreadCommandInvoker in addition
to the one that Peter identified. For example:
Does anyone mind if I take a meat-axe to the code?
#2
Sigh ... patch upload failed. Here it is inline.
svn diff core/src/core/org/jnode/vm/VmReflection.java
Index: core/src/core/org/jnode/vm/VmReflection.java
===================================================================
--- core/src/core/org/jnode/vm/VmReflection.java (revision 2883)
+++ core/src/core/org/jnode/vm/VmReflection.java (working copy)
@@ -318,6 +318,9 @@
}
if (!method.isStatic()) {
+ if (o == null) {
+ throw new NullPointerException();
+ }
Unsafe.pushObject(o);
} else {
method.getDeclaringClass().initialize();
#3
fixed in head rev 2885
#4
#5
#6
#7
#8