Re: acces of members of subclass
- From: Lew <lew@xxxxxxxxxxxxx>
- Date: Mon, 28 Jul 2008 14:28:59 -0700 (PDT)
On Jul 28, 5:16 pm, Eric Sosman <Eric.Sos...@xxxxxxx> wrote:
You said "The call to super() is *always* present," but that is
not the case. It is absent in three cases: (1) the class happens to
be java.lang.Object, (2) there is an explicit call to a superclass
constructor other than super(), or (3) the superclass has no no-
arguments constructor. Case (1) need not concern us, but case (2)
is perfectly ordinary, and case (3) is code that cannot produce a
"given class" because it won't even compile.
Case 1 did not concern me, agreed. For case2, a superclass
constructor call is always 'super()', it just may be 'super()' with
arguments. It is conventional in Usenet discussions to refer to a
constructor or method generally without regard for the arity. That is
what I did. So case 2 is covered by what I said, since there is no
call to a superclass constructor save through 'super()', in some
arity, implicit or explicit. Case 3 does not produce a class, so
therefore if there is a "given class", it has a 'super()' call. QED.
Lew (and the JLS) are right in saying that the compiler inserts a
call to super() if the constructor does not begin with a call to one
How can I be wrong if I said the same thing that the JLS does?
I said you "are right," did I not?
Actually, what you said was, "No, Mark is right, and Daniel and Lew
are wrong. "
I suspect we may be in violent agreement, differing only in our
use of nomenclature. When you refer to a "given class," it seems you
mean a bunch of source code processed by javac, whether or not it can
be compiled. I take the word "class" to mean the thing loaded into
the JVM by a ClassLoader, so in my view an uncompilable source cannot
become a "class."
Therefore by your definition, a given class always has a 'super()'
call in its constructors, else there would be no class to be "given".
Violent agreement indeed.
I don't know why you imputed a source-code only context to my claim
when it works in the scenario you had in mind, that of compiled
classes. If there is a compiled class, there is a 'super()' call in
each of its constructors. We agree. Violently.
In addition, it is also true that that call exists in code that fails
to compile correctly due to an inaccessible superclass constructor. I
only ever claimed that the call exists. In fact, the belief that it
does *not* exist leads to the bug that a unit will not compile because
the author didn't account for accessibility of the superclass
constructor. It is the belief that the superclass constructor does
*not* always exist that leads to bugs. Understanding that the
superclass constructor call is *always* present leads to more correct
code.
You are right: The compiler will decorate constructors with calls
to super() in the absence of explicit calls to superclass constructors.
This is the sum total of what I asserted.
I am right: Classes without calls to super() exist, and superclasses
exist that cannot be constructed via super() calls.
You were right in your analysis, only mistaken in thinking that I had
disagreed with it.
--
Lew
.
- References:
- [General]acces of members of subclass
- From: Daniel Moyne
- Re: [General]acces of members of subclass
- From: RedGrittyBrick
- Re: [General]acces of members of subclass
- From: Lew
- Re: [General]acces of members of subclass
- From: Daniel Moyne
- Re: [General]acces of members of subclass
- From: Lew
- Re: [General]acces of members of subclass
- From: Daniel Moyne
- Re: [General]acces of members of subclass
- From: Lew
- Re: [General]acces of members of subclass
- From: Mark Space
- Re: acces of members of subclass
- From: Lew
- Re: acces of members of subclass
- From: Eric Sosman
- Re: acces of members of subclass
- From: Lew
- Re: acces of members of subclass
- From: Eric Sosman
- [General]acces of members of subclass
- Prev by Date: Re: acces of members of subclass
- Next by Date: Error in the equal method of generic Pair class
- Previous by thread: Re: acces of members of subclass
- Next by thread: Re: acces of members of subclass
- Index(es):
Relevant Pages
|