jvm wishes and gripes

Per Bothner per@bothner.com
Mon Feb 4 13:58:00 GMT 2002


Adam Megacz wrote:
>> Oh yeah, one more thing... why doesn't the Java Language spec allow
> this:
>> class A {
> A foo() { return null; }
> }
>> class B extends A {
> B foo() { return null; }
> }
>> Plenty of other languages (Haskell, ML) 
and C++
> let you do stuff like
> this... the code above can't violate typing rules (even if B.foo()
> returned actual instances of B instead of just null).

They did want to add it, but implementation issues made it awkward to
implement, and they were under get-it-out-the-door pressure. My
guess is that the problem is the way the return type of a method is
part of its signature, and that name+signature is used for method
matching. There are lots of other problems in Java that could have
been done better with more time.
-- 
	--Per Bothner
per@bothner.com http://www.bothner.com/per/


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /