@Param support for enum
Aleksey Shipilev
aleksey.shipilev at oracle.com
Tue May 27 18:57:04 UTC 2014
Hi Joe,
On 05/26/2014 07:59 PM, Joe Kearney wrote:
> I will reply properly to your earlier email and try out the new code
> drop. However I was hoping for an no-arg version of @Param that would
> implicitly pick out all enum values so as not to require keeping the
> strings in the @Param.value in sync with the enum type names. I can look
> at supplyng a patch for that if you'd like.
Sure, please go ahead. Submit the OCA right now, as it takes some time
to be processed: http://openjdk.java.net/contribute/, paragraph 0.
What you are suggesting is at odds with our current @Param handling: JMH
now allows no-arg @Param annotations, and fails in runtime if no value
was supplied. Which means your suggestion would place @Param(<enum>) in
a very special position at runtime, and possibly confuses users.
We can probably dump that, and require the default settings for @Param
for every primitive/String type, and relax that for enums. This also
places @Param(<enum>) in a special position, but this time it is
enforced in compile time, and so it should be not as confusing.
Doing this will require a bit of rework in @Param checking logic, and
Runners handling them. The best course of action would be change the
@Param tests in jmh-core-ct, and work your way through failed tests.
Here are a few pointers:
*
http://hg.openjdk.java.net/code-tools/jmh/file/669d4200029c/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params
*
http://hg.openjdk.java.net/code-tools/jmh/file/669d4200029c/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java#l211
*
http://hg.openjdk.java.net/code-tools/jmh/file/669d4200029c/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java#l277
Thanks,
-Aleksey.
More information about the jmh-dev
mailing list