I'm guessing that what should be happening is a compile error on the private access method, however I am also getting an error on the default access:Note that I made significant changes from their discussion code to get this far, so it is quite probable that I have deviated from what they were intending to demonstrate. This is probably a "wood for the trees" issue, but I am not seeing why the default access method is failing.
As for what this is intended to show, it is all tied up in showing what is accessible in the test() method, which has an parameter of type T which is itself defined as extending C and implementing I:So the author was intending to show what was inherited from where, and that standard access control rules apply (of course that leads me back to the question of "why didnt mCDefault() work given that it is in the same (default) package as the CT class and the I interface"?
It should also be noted that the fact that class CT extends C and implements I is a red herring - it has nothing to do with the code under discussion, and may distract you from what is really important.
The following code works (or fails to work!) in exactly the same way:Regards, Andrew
Originally posted by Garrett Smith: I'm trying to understand what this code is intended to demonstrate.
Taken from pg 50 of the JLS, third edition.
The problem is that the code does not compile. The indentation is wrong, there's an extra closing curly brace, and there is no enclosing type.
[ July 20, 2006: Message edited by: Garrett Smith ]
It is intended to demonstrate what members the type variable T has: the intersection of C & I. Unfortunately the example is horribly broken as you have found out. Were the generic method moved to a different class declaration, and had CT implemented mI() you would see what they intended.