Skip to content

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

@linrium

Description

@linrium

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions