Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JVM: generation of benchmark methods returning value classes fails #272

Open
fzhinkin opened this issue Oct 23, 2024 · 0 comments
Open

JVM: generation of benchmark methods returning value classes fails #272

fzhinkin opened this issue Oct 23, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@fzhinkin
Copy link
Contributor

Kotlin compiler mangles name of functions returning value classes. JMH can't handle such method names and fails with a cryptic error:

@JvmInline
value class Val(val value: Int)

@State(Scope.Benchmark)
open class ValueClassBenchmark {
    @Benchmark
    fun benchmark() = Val(42)
}
Generation of JMH bytecode failed with 1 errors:
  - Group name should be the legal Java identifier.
   [org.openjdk.jmh.generators.reflection.RFMethodInfo@2e052ab3]

Under the missing RFMethodInfo.toString overload the following function is hiding: org.example.ValueClassBenchmark.benchmark-5sfh64U.

Using @JvmName or rewriting the benchmark method to accept a blackhole and use it explicitly instead of returning a value class instance helps, but the solution is not that intuitive (and org.openjdk.jmh.generators.reflection.RFMethodInfo@2e052ab3 does not help here).

Perhaps, we should check method names in JmhBytecodeGeneratorWorker before passing classes down to JMH and print some meaningful error message with a fix suggestion.

@fzhinkin fzhinkin added the enhancement New feature or request label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant