how to tell 2 methods are override-equivalent

Hamlin Li at
Mon Mar 20 02:13:28 UTC 2017

Hi Vicente,

Thank you for responding, please check the comments inline.

On 2017/3/17 21:08, Vicente Romero wrote:
> Hi Hamlin,
> How do you obtain m2? I mean at some point it should have been 
> obtained from an executable element or similar. 
I have a java doclet which scans jdk versions iteratively, m2 was got in 
previous round of run of the tool , then it's stored in a file (for 
example when scan jdk 1.8 source code), then parsed and retrieved from 
the file again (for example when scan jdk 9 source code).
> In the worst case you can always generate a simple test case and try 
> to compile it for example:
> class Test {
>     void getContent(java.lang.Class<?>[] c) {}
>     void getContent(java.lang.Class[] c) {}
> }
> this one will fail saying that both methods have the same erasure,
Yes, it should fail.
In my situation, "getContent(java.lang.Class[] c) {}" is the code in jdk 
1.8, "getContent(java.lang.Class<?>[] c) {}" is the corresponding code 
in jdk 9. When I scan jdk 9 source code, I need to tell that 
getContent(java.lang.Class<?>[] c) and getContent(java.lang.Class[] c) 
are in fact the same method, rather than 2 different methods.

Thank you
> HTH,
> Vicente
> On 03/16/2017 11:15 PM, Hamlin Li wrote:
>> Hi,
>> ( I'm not sure if this is the right alias to ask the question, please 
>> help forward if necessary. )
>> I have a question about telling whether one method is subsignature of 
>> another one. My situation is,
>> 1. there is a TypeElement *t1 *which represents, and a 
>> ExecutableElement *m1* which represents 
>> getContent(java.lang.Class*<?>*[]),
>> 2. there is a String *t2* which is "", and another String 
>> *m2 *which is "getContent(java.lang.Class[])".
>> The difference between m1 and m2 is that, m1 is an instance of 
>> ExecutableElement, m2 is an instance of String; there is a wildcard 
>> type argument in m1.
>> Is there a way to tell whether m1 and m2 are override-equivalent, m2 
>> is subsignature of m1?
>> I suppose I should use 
>> javax.lang.model.util.Types.isSubsignature(ExecutableType m1, 
>> ExecutableType m2), but I don't know how can I convert 
>> ExecutableElement *m1* and String *m2* to**ExecutableType.
>> Or I'm in wrong direction?
>> Thank you
>> -Hamlin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the compiler-dev mailing list