Support Java numeric literals in @Params parameters
Aleksey Shipilev
shade at redhat.com
Mon Oct 26 18:06:09 UTC 2020
Hi,
On 10/26/20 9:50 AM, Vsevolod Tolstopyatov wrote:
> ```
> @Param({"100", "1000", "10_000"})
> int integerParam = 10_000
> ```
As the workaround, you can write:
@Param({"" + 100, "" + 1_000, "" + 10_000})
int integerParam = 10_000
I understand this is ugly.
> It feels inconsistent and also complicates eye-balling parameters,
> especially when they are the power of 10.
> It would be nice to support underscores (generally speaking, to support
> integer literals in the same way javac does) and I am willing to contribute
> it, but first I would like to ask whether such change is aligned with JMH
> API shape and is a reasonable addition to JMH at all.
Well, I remember discussions (or maybe even the patches) about doing this. When JMH still supported
JDK 6, supporting underscores was at odds with source/target=6. It does not seem to be an issue
anymore: the minimal target is 7, so underscored literals are already there.
You can draft up a PR, and we shall see if there are blank spots.
--
Thanks,
-Aleksey
More information about the jmh-dev
mailing list