The above isn't valid Java (the call to super must be the first line of constructor Derived) and it is also not valid in Javassist. Is there a way round this in Javassist?

Note: this setting of a field before calling super is similar to how instance inner (nested) classes work, they set the field that points to their outer class before calling their own super constructor.

Note: this setting of a field before calling super is similar to how instance inner (nested) classes work, they set the field that points to their outer class before calling their own super constructor.

I don't think so... Setting the field that points to the outer class should be done *after* calling the super constructor.

This gives a NullPointerException since the field outer is not initialized when constructor Derived calls its super constructor, Base. Also: you can see if you dissassemble the code for InternalTest$1 that it initializes its pointer to the outer class, this$0, before calling its super.

Thanks. According to my simple study, javac of jdk1.4 andjavac of 1.5 seem to compile an inner class in a different way.I found that javac 1.5 initializes a point to the outer classbefore calling the super constructor. On the other hand,javac 1.4 does not do so. Thus, your sample code of InnerTestthrows a NullPointerException if it is compiled by javac 1.4.

It might be only a pointer to the outer class that can be initializedbefore calling a super constructor. I'll study this more.