Inside the inner class, you can use OuterClass.this . This expression, which allows you to reference any lexically spanning instance, is described in JLS as Qualified this .
I don't think there is a way to get an instance outside of the inner class code. Of course, you can always imagine your own property:
public OuterClass getOuter() { return OuterClass.this; }
EDIT: From experience, it looks like the field containing the link to the external class has access to the package level - at least using the JDK that I use.
EDIT: the name used ( this$0 ) is really valid in Java, although JLS prevents it from being used:
The $ character should only be used in mechanically generated source code, or, rarely, for accessing legacy systems that already exist.
source share