Method Signature Ambiguity
G G
ggarrison5 at gmail.com
Mon Sep 13 12:59:05 UTC 2021
Hello,
Sorry if this is the wrong place for this email, I'm fairly new to OpenJDK
projects. I was recently asked "What is a method signature in Java?" Having
recently worked with bytecode, I was confident that my JVMS (§4.7.9.1
<https://docs.oracle.com/javase/specs/jvms/se16/html/jvms-4.html#jvms-4.7.9.1>)
based knowledge would be correct in this fashion:
> A *method signature* encodes type information about a (possibly generic)
> method declaration. It describes any type parameters of the method; the
> (possibly parameterized) types of any formal parameters; the (possibly
> parameterized) return type, if any; and the types of any exceptions
> declared in the method's throws clause.
However, after a quick Google search I was able to uncover that the JLS (§
<http://goog_6165633>8.4.2
<https://docs.oracle.com/javase/specs/jls/se16/html/jls-8.html#jls-8.4.2>)
gave a different definition:
> Two methods or constructors, M and N, have the *same signature* if they
> have the same name, the same type parameters (if any) (§8.4.4
> <https://docs.oracle.com/javase/specs/jls/se16/html/jls-8.html#jls-8.4.4>),
> and, after adapting the formal parameter types of N to the type
> parameters of M, the same formal parameter types.
While both are consistent with the implementation, I believe that the two
disagree on the question of "What is a method signature in Java?" After
asking a few other people, I found that I was told each definition a few
times, so I do believe that I am not entirely alone in this confusion.
My suggestion for this is to rename one or both of the names. The JLS
definition could be changed to "override method signature", as the
definition seems to be defined around that. The JVMS definition could steal
a page out of what Wikipedia currently calls it (not backed up by official
documentation as far as I know) and call it an "internal method signature".
I may be completely off base here, if so at the very least it will be a
learning experience for me and a few others.
Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20210913/8d6aa396/attachment.htm>
More information about the compiler-dev
mailing list