bizzabo / diff

Visually compare Scala data structures with out of the box support for arbitrary case classes.
Other
177 stars 17 forks source link

Malformed class name #21

Open cvogt opened 8 years ago

cvogt commented 8 years ago
scala> import ai.x.diff._
import ai.x.diff._

scala> case class Foo(i: Int, s: String)
defined class Foo

scala> case class Bar(d: Double, f: Foo)
defined class Bar

scala> val b1 = Bar(1.0,Foo(1,"test"))
b1: Bar = Bar(1.0,Foo(1,test))

scala> val b2 = Bar(2.0,Foo(1,"baz"))
b2: Bar = Bar(2.0,Foo(1,baz))

scala> DiffShow.diff(b1, b2)
java.lang.InternalError: Malformed class name
  at java.lang.Class.getSimpleName(Class.java:1330)
  at ai.x.diff.DiffShowInstances$CaseClassDiffShow.diff(diff.scala:207)
  at ai.x.diff.DiffShow$.diff(diff.scala:64)
  at ai.x.diff.DiffShowFields$$anon$3.diff(diff.scala:99)
  at ai.x.diff.DiffShowFields$$anon$3.diff(diff.scala:95)
  at ai.x.diff.DiffShowFields$$anon$3.diff(diff.scala:99)
  at ai.x.diff.DiffShowFields$$anon$3.diff(diff.scala:95)
  at ai.x.diff.DiffShowInstances$CaseClassDiffShow.diff(diff.scala:201)
  at ai.x.diff.DiffShow$.diff(diff.scala:64)
  ... 32 elided

scala>
agile-jordi commented 7 years ago

Same error here. :-(

cvogt commented 7 years ago

It's related a bug when nesting objects or classes inside other object or classes

https://issues.scala-lang.org/browse/SI-5425

As a workaround, avoid this and put them top-level.

acjay commented 7 years ago

Hmm, reorganizing my code to not have nested classes isn't really a viable solution for me. It's weird though, the only place I see getSimpleName seems protected by a try/catch. Where's this actually blowing up?

polymorpher commented 7 years ago

@acjay There are two versions of this package on Maven. It seems only "ai.x" %% "diff" % "1.2.0-get-simple-name-fix" has the try/catch block.

https://mvnrepository.com/artifact/ai.x/diff_2.11

LMnet commented 6 years ago

Actually, it should be fixed through #19