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
    context?

    JLS 8.4.2 --- This may be compiler's view.
    <quote>
    Two methods have the same signature if they have the same name and argument
    types. --- 3rd edition
    </quote>
    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.
    <quote>
    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
    </quote>
    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
    1. Advertising

  2. hiwa

    Ross Bamford Guest

    On Fri, 2005-05-13 at 16:29 -0700, hiwa wrote:
    > Does the term method signature have different definitions depending on
    > context?
    >
    > JLS 8.4.2 --- This may be compiler's view.
    > <quote>
    > Two methods have the same signature if they have the same name and argument
    > types. --- 3rd edition
    > </quote>
    > 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.
    > <quote>
    > 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
    > </quote>
    > 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?


    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

    --
    [Ross A. Bamford] [ross AT the.website.domain]
    Roscopeco Open Tech ++ Open Source + Java + Apache + CMF
    http://www.roscopec0.f9.co.uk/ + in
     
    Ross Bamford, May 14, 2005
    #2
    1. Advertising

  3. hiwa

    Tony Morris Guest

    "hiwa" <> wrote in message
    news:...
    > Does the term method signature have different definitions depending on
    > context?
    >
    > JLS 8.4.2 --- This may be compiler's view.
    > <quote>
    > Two methods have the same signature if they have the same name and

    argument
    > types. --- 3rd edition
    > </quote>
    > 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.
    > <quote>
    > 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
    > </quote>
    > 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?


    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)
    http://xdweb.net/~dibblego/
     
    Tony Morris, May 14, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JJBW
    Replies:
    1
    Views:
    10,333
    Joerg Jooss
    Apr 24, 2004
  2. hiwa
    Replies:
    1
    Views:
    2,160
    Chris Uppal
    May 13, 2005
  3. lyallex
    Replies:
    6
    Views:
    550
    lyallex
    Sep 29, 2007
  4. Gustavo Narea
    Replies:
    14
    Views:
    876
    Gustavo Narea
    Feb 16, 2009
  5. Francis Hwang
    Replies:
    4
    Views:
    128
    Pit Capitain
    Mar 8, 2005
Loading...

Share This Page