[Bluej-discuss] private fields of superclass in object inspector
Michael Kölling
M.Kolling at kent.ac.uk
Mon Dec 17 09:26:41 GMT 2007
On 14 Dec 2007, at 16:55, Michael E. Caspersen wrote:
>> -----------------
> 8.2 Class Members
>
> The members of a class type are all of the following:
>
> * Members inherited from its direct superclass (§8.1.4), except in
> class Object, which has no direct superclass
>
> * Members inherited from any direct superinterfaces (§8.1.5)
>
> * Members declared in the body of the class (§8.1.6)
>
> Members of a class that are declared private are not inherited by
> subclasses of that class. Only members of a class that are declared
> protected or public are inherited by subclasses declared in a package
> other than the one in which the class is declared.
>
> AND LATER
> A class inherits from its direct superclass and direct superinterfaces
> all the non-private fields of the superclass and superinterfaces that
> are both accessible to code in the class and not hidden by a
> declaration in the class.
>
> Note that a private field of a superclass might be accessible to a
> subclass (for example, if both classes are members of the same class).
> Nevertheless, a private field is never inherited by a subclass
>
> ==========
>
> 12.5 Creation of New Class Instances
>
> Whenever a new class instance is created, memory space is allocated
> for it with room for all the instance variables declared in the class
> type and all the instance variables declared in each superclass of the
> class type, including all the instance variables that may be hidden
> (§8.3).
Michael,
I agree that this is unfortunate wording, and I would prefer to word
this differently.
However, we have a lifeline. The important bit is in the last paragraph.
All the previous sections talk about *classes*. The last one talks
about *instances*.
Classes, in their terminology, do not inherit the private fields.
However, 10.5 states that instances include the superclass's fields.
With that definition, the object inspector is correct, independent of
the terminology we apply.
Michael
More information about the bluej-discuss
mailing list