Skip to content

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

Open
@fzhinkin

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.

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions