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

IncompatibleClassChangeError with custom runner #66

Closed
yanns opened this issue Mar 8, 2016 · 4 comments · Fixed by #117
Closed

IncompatibleClassChangeError with custom runner #66

yanns opened this issue Mar 8, 2016 · 4 comments · Fixed by #117

Comments

@yanns
Copy link
Contributor

yanns commented Mar 8, 2016

I just added object CustomRunnerApp extends App.
I do not use it.

By running:

jmh:run -i 1 -wi 1 -f1 -t1

I have the following exception:

Annotation generator had thrown the exception.
java.lang.IncompatibleClassChangeError: sphere.CustomRunnerApp and sphere.CustomRunnerApp$delayedInit$body disagree on InnerClasses attribute
    at java.lang.Class.getDeclaringClass0(Native Method)
    at java.lang.Class.getDeclaringClass(Class.java:1235)
    at java.lang.Class.getEnclosingClass(Class.java:1277)
    at java.lang.Class.getCanonicalName(Class.java:1392)
    at org.openjdk.jmh.generators.reflection.RFClassInfo.getQualifiedName(RFClassInfo.java:67)
    at org.openjdk.jmh.generators.core.BenchmarkGenerator.buildAnnotatedSet(BenchmarkGenerator.java:219)
    at org.openjdk.jmh.generators.core.BenchmarkGenerator.generate(BenchmarkGenerator.java:85)
    at org.openjdk.jmh.generators.bytecode.JmhBytecodeGenerator.main(JmhBytecodeGenerator.java:100)
    at pl.project13.scala.sbt.JmhPlugin$.pl$project13$scala$sbt$JmhPlugin$$internalGenerateBenchmarkSourcesAndResources(JmhPlugin.scala:81)
    at pl.project13.scala.sbt.JmhPlugin$$anonfun$2.apply(JmhPlugin.scala:64)
    at pl.project13.scala.sbt.JmhPlugin$$anonfun$2.apply(JmhPlugin.scala:62)

Should I remove this class from the jmh "transformations"?

@TimSoethout
Copy link
Contributor

TimSoethout commented Apr 21, 2017

Any solution on this?
I have the same problem with a custom runner in the same module as my Benchmarks.

@mefu
Copy link

mefu commented Apr 22, 2017

I think I found a workaround it for now. Use a normal main function instead of extending App. Like do following instead of example in readme

package com.example

import java.io.{File, FileOutputStream}

import org.openjdk.jmh.results.RunResult
import org.openjdk.jmh.runner.Runner
import org.openjdk.jmh.runner.options.CommandLineOptions

object CustomRunnerApp {
  import scala.collection.JavaConversions._
  def main(args: Array[String]): Unit = {
    val opts = new CommandLineOptions(args: _*) // parse command line arguments, and then bend them to your will! ;-)

    val runner = new Runner(opts) // full access to all JMH features, you can also provide a custom output Format here

    val results = runner.run() // actually run the benchmarks

    val f = new FileOutputStream(new File("custom.out"))
    results.foreach { result: RunResult ⇒
      // usually you'd use these results to report into some external aggregation tool for example
      f.write(s"custom reporting result: ${result.getAggregatedResult.getPrimaryResult}".getBytes("UTF-8"))
    }
    f.close()
  }

}

I do not know if this would cause any other problems but it looks like working properly for me.

@TimSoethout
Copy link
Contributor

Thanks @mefu, this seems to work for me as well.

@sfosdal
Copy link

sfosdal commented May 17, 2017

This worked for me as well.

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

Successfully merging a pull request may close this issue.

4 participants