Open
Description
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.