#245 Inherited methods execution error

open
nobody
Parsing (77)
5
2005-10-04
2005-10-04
Bruno
No

The following code produces a NullPointerException when atempting
to execute an inherited method for a subclass which has the same
name as the superclass.

package a;
public class A{ public void print(){print("a.A.print()");}}
package a.b;
public class A extends a.A{}
public class B extends a.A{}
objB = new a.b.B();
objB.print();
objA = new a.b.A();
objA.print();

// Error: // Uncaught Exception: Method Invocation obj.print : at
Line: 1 : in file: <unknown file> : obj .print( )

Target exception: java.lang.NullPointerException

bsh % java.lang.NullPointerException
at a.A.printA(BeanShell Generated via ASM (www.objectweb.
org))
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at sun.reflect.NativeMethodAccessorImpl.
invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.
invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at bsh.Reflect.invokeOnMethod(Unknown Source)
at bsh.Reflect.invokeObjectMethod(Unknown Source)
at bsh.Name.invokeMethod(Unknown Source)
at bsh.BSHMethodInvocation.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.Interpreter.run(Unknown Source)
at java.lang.Thread.run(Thread.java:595)

Discussion

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks