L
Lew
If it was not valid, then it would be an error not a warning.
And yet Eclipse does not issue warnings for all valid code, just for certain
valid code.
The distinction between Eclipse and compiler is a bit fuzzy
since Eclipse uses its own compiler.
Well, normally when one refers to 'javac' explicitly, it refers to one from
Sun, otherwise one has a responsibility to specify to which 'javac' one
refers. Understanding that to be common, I spoke of 'javac' without further
brand attribution, an error I now correct; I was speaking of "javac 1.6.0_10"
from Sun, running in 64-bit Linux.
I consider the issuance of messages from that 'javac' to be normative.
On the flip side of that, when I said, "Eclipse would give a warning", I was,
of course, referring to its compiler metonymically. The distinction between
them is non-germane to how interesting it is that Eclipse would warn that one
has used a method declaration in a subclass when there exists a
signature-equivalent superclass method that is package-private.
Among the interesting thoughts that swirl around that:
- Eclipse goes out of its way to engender good coding practices.
- Eclipse provides a superset of the canonical compiler.
- Why would one care if one "pseudo-overrode" a private or package-private
method? Corollate: Should one care?
- Does Eclipse allow one to disable that particular warning? It has pretty
fine-grained control over its compiler warnings, so I expect it could.
It certainly trained the OP, me and anyone else listening to think about what
conditions actually define a method override, and about related matters like
method overloads, member visibility, package layout, escaping "this"
references fleeing from constructors, hiding, obscuring, obfuscating, ...
Bravo, OP - excellent topic.