title: How to bench Scala with JMH in Intellij?
body: <p>I can't figure out how to do benchmarks of Scala programs in Intellij with JMH.</p>
  
  <p>Here's what I've done so far:</p>
  
  <p><strong>Added the JMH SBT-Plugin</strong></p>
  
  <pre><code>// build.sbt
  name := "Project"
  version := "1.0"
  scalaVersion := "2.11.8"
  enablePlugins(JmhPlugin)
  
  // project/plugins.sbt
  logLevel := Level.Warn
  addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.2.10")
  </code></pre>
  
  <p>Here is the <a href="https://github.com/ktoso/sbt-jmh" rel="nofollow noreferrer">plugin's website</a></p>
  
  <p><strong>Created a benchmark class</strong></p>
  
  <pre><code>// src/main/scala/MyBenchmark.scala
  import org.openjdk.jmh.annotations.Benchmark
  
  class MyBenchmark {
  
      @Benchmark
      def test(): Unit = println("test")
  
  }
  </code></pre>
  
  <p><strong>Created an SBT-Task in Intellij</strong></p>
  
  <p><a href="https://i.stack.imgur.com/v1Os1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v1Os1.png" alt="Intellij Run Configuration"></a></p>
  
  <p>But after running the task I just get an exception:</p>
  
  <pre><code>Annotation generator had thrown the exception.
  java.lang.NullPointerException
      at org.openjdk.jmh.generators.reflection.RFClassInfo.getPackageName(RFClassInfo.java:51)
      at org.openjdk.jmh.generators.core.BenchmarkGenerator.validateBenchmark(BenchmarkGenerator.java:243)
      at org.openjdk.jmh.generators.core.BenchmarkGenerator.generate(BenchmarkGenerator.java:90)
      ....
  </code></pre>
  
  <p>What am I doing wrong?</p>