Re: method overriding

From: Sebastian Millies (s.millies_at_REPLACE-CAPS.idsMINUSscheerDOTde)
Date: 03/22/04


Date: Mon, 22 Mar 2004 15:42:53 +0100

this maybe off-topic for this discussion, but *why* has
Java chosen to
a) define the signature of a method as not including the return type?
b) not consider subtype-relationships in the definition of overriding?

That is, what are the (historical) reasons for having
   Child Child.method(Child)
not override
   Parent Parent.method(Parent)

In my view, that would be so much easier to understand!

(It would be similar to strongly typed functional languages
like ML, where a method's type is described as a function
from the argument types to the result type. The function denotes
a set, and subtype relationships map directly to subset relationships
in the model. Nothing like that is possible for Java, in fact, I haven't
yet seen a semantics for Java ...).

And it wouldn't be any more complex intuitively either: Child.method
would override Parent.method if all slots in the child method's signature
were at least as narrow as those in the parent method's.

Well, I guess we'd have less runtime type checking, because the
legality of the method call in e. g.
    Parent p = (Parent) new Child;
    Child c = Child.method( p );
could only be determined on the basis of p's runtime type. But I guess
I'd still like that better than what's happening in Java.

-- Sebastian

"Neal Gafter" <gafter@spamcop.net> schrieb im Newsbeitrag
news:405E93CD.4020103@spamcop.net...
> Chris Uppal wrote:
> [snip]
>> Child Child.method(Child) does not override Parent
Parent.method(Parent)
>
> Simple: overriding is by signature, which is method name and argument
types.
> The same way you always explained it. What's the problem?
> [snip]



Relevant Pages

  • Re: The Override Problem
    ... >> occasionally override. ... >> get the method signature off by a hair. ... > JBuilder provides an "override method" wizard which can insert stubs ... > for all inherited abstract methods and can insert stubs for selected ...
    (comp.lang.java.programmer)
  • Verifying digitally signed data from a .NET application in a Java Servlet
    ... I am working on a project that takes signed data from an application ... that can be in either Java or .NET. ... of "Invalid encoding for signature" or it just fails verification. ...
    (comp.lang.java.programmer)
  • Unable to verify signature with Sun JSSE
    ... In a nutshell I cannot get signature verification to work, ... and what doesn't work in Java. ... all of the input data (the public key, the SHA-1 hashed data that was ... bytepublicKey = ...
    (comp.lang.java.security)
  • How to decipher data in .NET using "RSA/ECB/PKCS1Padding"?
    ... The data and signature is encrypted in Java using RSA Public key encryption. ...
    (microsoft.public.dotnet.security)
  • Re: How to decipher data in .NET using "RSA/ECB/PKCS1Padding"?
    ... I am receiving RSA encrypted data with the digital signature. ... signature is encrypted in Java using RSA Public key encryption. ... I am able to do it in Java using following code. ... RSAPrivateKey privateKey = getPrivateKey(keystoreFile, aliasName, ...
    (microsoft.public.dotnet.security)