Java Inner Classes

Some curiosities regarding the Java inner class feature. Some of the proofs are more verbose than they could be (if we used reflection, we would not need two versions of the class, one for the compiler, and one for the execution). Nonetheless, the proof seems clearer in this form than it would be if using reflection.

The Private Inner Class

How the Virtual Machine ignores the inner class access modifiers.

The Inner Class Role

How the Virtual Machine can be fooled into using a non-inner class in place of an inner class, and vice-versa.

The Synthetic Outer Class Method

How the Virtual Machine allows unrestricted access to synthetic methods generated for inner class support, methods providing acces to otherwise private fields and/or methods of the outer class.

Leave a Reply