What is the correct definition of method signature?

Discussion in 'Java' started by hiwa, May 14, 2005.

  1. hiwa

    hiwa Guest

    Does the term method signature have different definitions depending on

    JLS 8.4.2 --- This may be compiler's view.
    Two methods have the same signature if they have the same name and argument
    types. --- 3rd edition
    Description from the second edition is a little bit longer than this but
    the sense is the same.

    JLS 12.3.3 --- This may be linker's view.
    NoSuchMethodError: A symbolic reference has been encountered that refers
    to a specific method of a specific class or interface, but the class or
    interface does not contain a method of that signature. --- 3rd edition
    NoSuchMethodError checks the return type of method as a part of signature.

    If I repeat the question in other words:
    Isn't there a one single formal/official definition for the term method
    signature in Java or in a standard CS theory?
    hiwa, May 14, 2005
    1. Advertisements

  2. hiwa

    Ross Bamford Guest

    From the point of view of the language, A method signature doesn't
    include the return type at all, which is why you cannot overload on
    return type alone.

    I don't understand what you mean by 'NoSuchMethodError checks the return
    type', but in any case that exception is part of the JVM implementation
    of Reflection (etc). Consider that when you look for a method
    reflectively, you only pass in it's parameter types and name, and these
    are look the method up.

    Ross Bamford, May 14, 2005
    1. Advertisements

  3. hiwa

    Tony Morris Guest

    The method name, the order and type of parameters.
    You have found (yet another) ambiguity in the JLS, which makes it unclear.
    It is imperative that the order of the parameters as well as the type is
    explicitly stated as one aspect that contributes to a 'method signature'.

    Tony Morris
    Software Engineer, IBM Australia.
    BInfTech, SCJP 1.4, SCJP 5.0, SCJD

    http://www.jtiger.org/ JTiger Unit Test Framework for Java
    http://qa.jtiger.org/ Java Q&A (FAQ, Trivia)
    Tony Morris, May 14, 2005
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.