Hey peeps,
Here’s a bit of a wierd one for you; I’d be very grateful if anyone can give me a reason why the following happens, could tell me whether or not it’s a bug, and whether it has been fixed in the latest JDK - I’m running JDK 1.4.1_01:
public class Outer
{
private class Inner
{
}
Inner i = new Inner() ;
}
When this class is compiled it produces three class files, Outer.class, Outer$Inner.class and Outer$1.class. What is Outer$1? It is generated whenever the class is compiled, but can be deleted without affecting the class’ functionality. When decompiling the three class files together, a single file equivalent to the above is generated - subsequently compiling this file produces the three class files again.
Decompiling just the Outer$1.class file produces the following:
class Outer$1
{
}
Decompiling just the Outer$Inner.class file produces the following:
private class Outer$Inner
{
private Outer$Inner()
{
super();
}
Outer$Inner(Outer$1 outer$1)
{
this();
}
}
So what is that second constructor? Why can life continue fine without the class existing? And is this expected behaviour?
Cheers,
Charlie.