Stefan Ram said:
The Java programming language is a strongly typed
language, which means that every variable and every
expression has a type that is known at compile time. There
is also a special null type, the type of the expression
null. A null literal is always of the null type.
The null reference can always be cast to any reference
type. (JLS3)
The null literal has a type, while the null reference is
typeless as is any other reference in Java. Only variables and
expressions have types, and objects have classes (as run-time
types). References themselves are typeless.
Your criticism agains methods returning "null" to signal a
special condition does not seem to be related to the type of
null. -- It also would apply if it would return a specially
typed null reference or null object of the declared return
type of the method.
Your quoting of the JLS was indeed expected, but you must understand that I
do not accept it as an authoritative source. In fact, many of my colleagues,
who work alongside with me implementing this specification, do not
acknowledge it as an authority. This is the fundamental reason why you may
not see why a "method that returns null" is not related to the defective
existence of null itself. That few people are able to consider an
alternative, and perhaps less contrived solution (an exception is not it,
because they are defective too as the never-ending exception debate clearly
indicates), is the result of the subscription to the authority of the JLS.
One must also acknowledge the nature of specifications written using English
and the potential and intrinsic ambiguity as a result. If the JLS said that
'null is a language defect, and we wish we didn't introduce it, however, our
most prominent language experts are unable to determine a suitable solution,
so we simply concede to the point and introduce it as a dynamic type, while
providing the illusion that it is not through the JLS', is this correct as
an authority? I certainly think it is a more plausible description of
reality, and many agree, but are unable to disclose evidence due to the
filth within which they work and therefore, depend on to survive.
Ignoring the JLS, marketing material, etc. and working purely with
programming languages, I define that null is dynamically-typed according to
my, and the generally accepted, definition in language research. Sure, we
can redefine our axiom as the JLS and discuss within that frame of
reference, in which case, I concede entirely, but my initial assumption was
not that due to the aforemention failure to acknowledge the illusion of a
proclaimed authority as being real.