kotlinx-benchmark
kotlinx-benchmark copied to clipboard
Can't build when used with Kotlin experimental features
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.
Hi @ShreckYe, The problem may come with quoted benchmark function names with spaces. Could you please check if that is the case for you?
Related: https://github.com/melix/jmh-gradle-plugin/issues/150
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.