To me it seems obvious that it wouldn't get maintained, but I've bee fooled before by subtle features of java, like providing a reference to an enclosing type by parameterizing the constructor of the inner class, all the while being ignorant of the syntax EnclosingType.this
. I may also be ignorant of some other method of retrieving references to instances of inner classes from their enclosing types. So if I create an instance of an inner class, and don't maintain a reference, but I do maintain the reference to the instance of the enclosing type, will GC ever clean up the inner classes instance?
Yes, the instance of the inner class will be eligible for GC. The inner class instance has a reference to the instance of the containing class instance, not the other way round.
See more on this question at Stackoverflow