#341 NPE when invoking abstract method in a constructo

General (151)

Class B extends A, so when constructing B, first the constructor of A is called. But A constructor calls an abstract method prepared by B, which is not constructed yet. I guess this is the reason for the following code to throw exceptions in 2.0b4
(This makes it impossible to use java class A in BeanShell).

// This was in reality a java class, so we cannot modify its twisted constructor
abstract class A
abstract public int fun();

public A()

class B extends A
public int fun()
return 0;

new B();

bsh.InterpreterError: Error in class initialization: java.lang.NullPointerException
at bsh.ClassGeneratorUtil.initInstance(Unknown Source)
at A.<init>(BeanShell Generated via ASM (www.objectweb.org))
at B.<init>(BeanShell Generated via ASM (www.objectweb.org))


  • Jarek Czekalski

    Jarek Czekalski - 2012-08-31
    • status: open --> closed-duplicate

Log in to post a comment.

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

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks