RFR: 8376325: [IR Framework] Detect and report overloads [v2]

Christian Hagedorn chagedorn at openjdk.org
Thu Jan 29 11:54:33 UTC 2026


On Thu, 29 Jan 2026 10:23:43 GMT, Marc Chevalier <mchevalier at openjdk.org> wrote:

>> The IR framework should not only forbid overloads between test methods, but overloads of a test method, even if other overloads are not test methods themselves. Indeed, the compiler directive file designate methods only by the class name and method name, without the parameters. Something like:
>> 
>>   {
>>     match : "ir_framework.tests.BadOverloadedMethod::sameName",
>>     log : true,
>>     PrintIdeal : true,
>>   }
>> 
>> This means that the same printing directive would apply to overloads, and make the output confusing in case these non-test methods are compiled. While test methods are necessarily compiled by the framework, the said framework doesn't prevent other methods to be compiled (a normal output of the test VM shows a lot of compilations).
>> 
>> One could emit compiler directives that take arguments into account, but this is not clear it is useful. Also, there is a simpler solution: disallow overloading of test methods at all. This way, if we regret and need overloads later, we can still allow them without breaking existing tests. With this change, one can get the new error message:
>> 
>>  - Cannot overload @Test methods, but method public void ir_framework.tests.BadOverloadedMethod.sameName(double) has 2 overloads:
>>     - public void ir_framework.tests.BadOverloadedMethod.sameName(boolean)
>>     - public void ir_framework.tests.BadOverloadedMethod.sameName()
>> 
>> which should explain well enough what is happening. A little esthetic problem is that if all three methods (in the previous example) are test-method, one get an error for each of them. I considered it acceptable.
>> 
>> This change needed adjusting some tests. I've also made them a bit more robust/easy to maintain by using a map instead so I didn't have to sift a hundred array indices.
>> 
>> Let's also emphasize that this change doesn't mean that overloads are entirely forbidden: they are fine as long as they don't involve a test method.
>> 
>> Tested on tier1,tier2,tier3,hs-precheckin-comp,hs-comp-stress.
>> 
>> Thanks,
>> Marc
>
> Marc Chevalier has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Copyright

Nice catch and thanks for cleaning the tests up! Looks good to me.

-------------

Marked as reviewed by chagedorn (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/29483#pullrequestreview-3722235070


More information about the hotspot-compiler-dev mailing list