kotlinx-benchmark icon indicating copy to clipboard operation
kotlinx-benchmark copied to clipboard

Can't build when used with Kotlin experimental features

Open ShreckYe opened this issue 3 years ago • 3 comments

The library I am benchmarking uses Kotlin's ExperimentalUnsignedTypes. I have already added

@OptIn(ExperimentalUnsignedTypes::class)

to the benchmark class and

tasks.withType<KotlinCompile>().configureEach {
    kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
}

to build.gradle.kts but still got the following Gradle error:

Execution failed for task ':app:mainBenchmarkGenerate'.
> There was a failure while executing work items
   > A failure occurred while executing kotlinx.benchmark.gradle.JmhBytecodeGeneratorWorker
      > Generation of JMH bytecode failed with 1errors:
          - Group name should be the legal Java identifier.
           [org.openjdk.jmh.generators.reflection.RFMethodInfo@3212c77c]

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.


ShreckYe avatar Aug 02 '21 06:08 ShreckYe

Hi @ShreckYe, The problem may come with quoted benchmark function names with spaces. Could you please check if that is the case for you?

qurbonzoda avatar Aug 06 '21 01:08 qurbonzoda

Related: https://github.com/melix/jmh-gradle-plugin/issues/150

qurbonzoda avatar Aug 06 '21 01:08 qurbonzoda

Hi @ShreckYe, The problem may come with quoted benchmark function names with spaces. Could you please check if that is the case for you?

Thanks. I checked the code again and found the reason. It's actually due to using a single expression function with = as a @Benchmark function, and the inferred return type is not Unit. It just happened that I used experimental features inside so I made a mistake there. Sorry for this.

ShreckYe avatar Aug 06 '21 09:08 ShreckYe