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

java.lang.ClassFormatError: Duplicate method name&signature when upgrading to cats 1.0.0-MF #1802

Closed
julien-truffaut opened this issue Aug 8, 2017 · 3 comments · Fixed by #1804
Assignees

Comments

@julien-truffaut
Copy link
Contributor

Hi all,

When @sellout tried to upgrade newts (https://github.com/julien-truffaut/newts) from cats 0.9.0 to 1.0.0-MF, we started to experience java.lang.ClassFormatError when calling show on case class using AnyVal e.g.:

final case class First[A](getFirst: A) extends AnyVal
object First {
  implicit def showInstance[A](implicit ev: Show[A]): Show[First[A]] = new Show[First[A]] {
    override def show(f: First[A]): String = s"First(${ev.show(f.getFirst)})"
  }
}

First("aString").show

here is the exact error:

[info] newts.FirstTest *** ABORTED ***
[info]   java.lang.ClassFormatError: Duplicate method name&signature in class file newts/First$$anon$1
[info]   at java.lang.ClassLoader.defineClass1(Native Method)
[info]   at java.lang.ClassLoader.defineClass(ClassLoader.java:760)

Now what's interesting is that the error disappear if you:

  • remove Anyval or
  • change uses Show.show e.g.
implicit def showInstance[A](implicit ev: Show[A]): Show[First[A]] =  Show.show(a =>
    s"First(${Show[A].show(a.getFirst)})"
  )

For precision, everything worked fine in 0.9.0

@kailuowang
Copy link
Contributor

Confirmed it's not simulacrum. A possible work around at the cats side is to rename the show in ContravariantShow. In the meantime, @julienrf @sellout can you guys use the Show.show work around before next release?

@julien-truffaut
Copy link
Contributor Author

sure PR is already pending. I was mostly creating this issue in case in anyone else face it.

@dwijnand
Copy link
Contributor

dwijnand commented Aug 9, 2017

Confirmed it's not simulacrum. A possible work around at the cats side is to rename the show in ContravariantShow.

An alternative workaround is to make simulacrum.typeclass see the original show in ContravariantShow.

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.

3 participants