RFR: 8376325: [IR Framework] Detect and report overloads [v2]
Marc Chevalier
mchevalier at openjdk.org
Thu Jan 29 10:23:43 UTC 2026
> 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
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/29483/files
- new: https://git.openjdk.org/jdk/pull/29483/files/6a19fc93..7d61034c
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=29483&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=29483&range=00-01
Stats: 3 lines in 3 files changed: 0 ins; 0 del; 3 mod
Patch: https://git.openjdk.org/jdk/pull/29483.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/29483/head:pull/29483
PR: https://git.openjdk.org/jdk/pull/29483
More information about the hotspot-compiler-dev
mailing list