Method Signature Ambiguity
ggarrison5 at gmail.com
Mon Sep 13 12:59:05 UTC 2021
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 (§22.214.171.124
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 (§
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
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the compiler-dev