I came across the expression ‘subclasses of the containing class’ when I read a paper. What does that containing class mean in Java? This is the excerpt from the paper.
Primarily, this entailed three things: (i) studying the implementation of the entity, as well as its usage, to reason about the intent behind the functionality; (ii) performing static dependency analysis on the entity, and any other types, methods, or fields referenced by it, including constants; and (iii) examining the inheritance hierarchy and subclasses of the containing class. This approach took considerable time and effort to apply.
This example has a subclass of the containing class:
ParentSubclassis a subclass of the containing class ofChild. Note that outside ofParent(or its subclasses),new Child()will not work, as you need to have a containing (“outer”) class to instantiate a non-static“inner” class.Things get a bit crazy when you now add a method
doSomethingtoParent, invoke it inChildbut override it inParentSubclass.Situations like this make static code analysis a quite hard problem.