sbt-jmh icon indicating copy to clipboard operation
sbt-jmh copied to clipboard

jmh:run caused Unable to find the resource: /META-INF/BenchmarkList in multiple projects

Open linrium opened this issue 3 years ago • 0 comments

I had an error when using this plugin with modules project.

Project structure

root/

  • build.sbt
  • project/
    • plugin.sbt
  • modules/
    • projectA/
      • build.sbt
        • src/
          • main.scala.example/
            • MyBenchmark.scala
          • test.scala.example/
            • MyBenchmarkTest.scala

Code reproduce

// root/project/plugin.sbt
addSbtPlugin("pl.project13.scala" % "sbt-jmh"  % "0.4.0")
// root/build.sbt
enablePlugins(JmhPlugin)
// MyBenchmarkTest.scala
class MyBenchmark {
  @Benchmark
  def testMethod(blackHole: Blackhole): Double = {
    val list: List[Int] = List.range(1, Integer.MAX_VALUE/100)
    val sum: Double = list.sum
    blackHole.consume(sum)
    sum
  }
}
// MyBenchmark.scala
class MyBenchmark {
  @Benchmark
  def testMethod(blackHole: Blackhole): Double = {
    val list: List[Int] = List.range(1, Integer.MAX_VALUE/100)
    val sum: Double = list.sum
    blackHole.consume(sum)
    sum
  }
}

I got this error when run the command: sbt jmh:complie -> sbt jmh:run

Error

[error] WARNING: An illegal reflective access operation has occurred [error] WARNING: Illegal reflective access by org.openjdk.jmh.util.Utils (file:/Users/linhtt20/Projects/data-access/target/bg-jobs/sbt_1393f137/target/bbd5338e/49ad8c14/jmh-core-1.25.jar) to field java.io.PrintStream.charOut [error] WARNING: Please consider reporting this to the maintainers of org.openjdk.jmh.util.Utils [error] WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations [error] WARNING: All illegal access operations will be denied in a future release [error] Exception in thread "main" java.lang.RuntimeException: ERROR: Unable to find the resource: /META-INF/BenchmarkList [error] at org.openjdk.jmh.runner.AbstractResourceReader.getReaders(AbstractResourceReader.java:98) [error] at org.openjdk.jmh.runner.BenchmarkList.find(BenchmarkList.java:122) [error] at org.openjdk.jmh.runner.Runner.internalRun(Runner.java:266) [error] at org.openjdk.jmh.runner.Runner.run(Runner.java:209) [error] at org.openjdk.jmh.Main.main(Main.java:71) [error] Nonzero exit code returned from runner: 1 [error] (Jmh / run) Nonzero exit code returned from runner: 1

linrium avatar Oct 06 '21 10:10 linrium