I want to understand class files and inner/nested classes a bit better and I'm wondering about the following things:
- Is the
InnerClassesattribute used to refer tothe inner/nested classes in the ´containing´ class or is it used in the inner/nested classes to refer to the ‘container’ class? - Is the
InnerClassesattribute in class files sufficient? E.g. Do inner/nested classes have to follow the name mangling with$or is this just a convention? - Is there a way to make a class look like an inner/nested class to the JVM without setting the
InnerClassesattribute and does this depend on the JLM vendor? (I remember hearing that IBM's implementation had less strict requirements in some parts.) - How much does the class loading mechanism of the JVM interact with Java reflection? Would it be possible to make the JVM disagree with the results from Java reflection?
I tried looking it up in the JVM specification but didn't find a description of the actual mechanism.
I only found this sentence in “The InnerClasses Attribute” remotely connected to my question:
The Java virtual machine does not currently check the consistency of the InnerClasses attribute with any class file actually representing a class or interface referenced by the attribute.