melix / jmh-gradle-plugin

Integrates the JMH benchmarking framework with Gradle
Apache License 2.0
666 stars 88 forks source link

Add support Kotlin methods with spaces #150

Open l0rinc opened 5 years ago

l0rinc commented 5 years ago

In Kotlin you can create method names with spaces - they're supported in JUnit already. E.g.

@Benchmark fun `transitive dependency calculation`() = dependencies.transitive(root)

The bytecode will actually contain spaces, so it's possible the problem is actually in JMH generators, not your plugin:

// declaration: java.util.Set<com.lorinc.gradle.Dependency> transitive dependency calculation()
public final transitive dependency calculation()Ljava/util/Set;

The error I'm getting when using such a method is the following:

> A failure occurred while executing me.champeau.gradle.JmhBytecodeGeneratorRunnable
   > Generation of JMH bytecode failed with 1 errors:
       - Group name should be the legal Java identifier.
        [org.openjdk.jmh.generators.reflection.RFMethodInfo@27328ae]

If the problem is indeed in JMH, could we provide a workaround from the plugin to e.g. add underlines to the method names before generation or something?

Thanks!

melix commented 5 years ago

This is probably an issue with JMH itself. Did you try to upgrade to the latest version?

l0rinc commented 5 years ago

You mean compile it from https://hg.openjdk.java.net/code-tools/jmh? No, used the version from the plugin.

l0rinc commented 5 years ago

I guess the problem is with https://github.com/msteindorfer/jmh/blob/master/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorUtils.java#L85

melix commented 5 years ago

No, I mean the plugin lets you choose the version of JMH to use.

melix commented 5 years ago

Likely, yes.

l0rinc commented 5 years ago

https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-4.html#jvms-4.2.1 also suggests it should accept spaces.