Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
linrium opened this issue Oct 6, 2021 · 0 comments

Comments

@linrium
Copy link

linrium commented Oct 6, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant