This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Best way to find out is to write some code for yourself. Declare static and instance variables in the ancestor class. Make sure you have some private, some protected, some with default access and some with public access. Then try to access these variables from the inner class in the descendant? You can try the same thing with methods in the ancestor .
Inner classes whose declarations do not occur in a static context may freely refer to the instance variables of their enclosing class.
So, in your example, since B does not enclose C, C can't access the variables of B except in that they are inherited into A. Here is an example:
the output is: x in B: 3 x in Test: 4 x in A: 4 y in A: 6 you can see that the inner class can access the variables but it can only get the variables that are inherited into its enclosing class. The part that did puzzle me (and the JLS didn't mention it) is that the lines A.this.y and A.this.x compiled - I half expected them not to because of the A reference in them. However, the result was what I expected in that because it doesn't enclose it you can't access it. hope that helps
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com