-
Notifications
You must be signed in to change notification settings - Fork 21
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: SomeClass and SomeClass$$$$anon$$1 disagree on InnerClasses attribute #1167
Comments
Imported From: https://issues.scala-lang.org/browse/SI-1167?orig=1
|
@aboisvert said: |
Geoffrey Alan Washburn (washburn) said: class Foo {
override def toString = getClass.getSimpleName
}
object SimpleName extends Application {
val foo = new Foo {}
println(foo)
} Changing the one line to override def toString = classOf[Foo].getSimpleName Makes the problem go away. |
@jrudolph said: Here's a simple example: trait Test {
def testFunc(i:Int) = ((i:Int) => i + 5)(i)
} And here the console session: Welcome to Scala version 2.7.4.final (OpenJDK 64-Bit Server VM, Java 1.6.0_0).
Type in expressions to have them evaluated.
Type :help for more information.
scala> Class.forName("Test$$$$anonfun$$testFunc$$1")
res0: java.lang.Class[_] = class Test$$$$anonfun$$testFunc$$1
scala> res0.getSimpleName
java.lang.IncompatibleClassChangeError: Test and
Test$$$$anonfun$$testFunc$$1 disagree on InnerClasses attribute
at java.lang.Class.getDeclaringClass(Native Method)
at java.lang.Class.getEnclosingClass(Class.java:1102)
at java.lang.Class.getSimpleBinaryName(Class.java:1237)
at java.lang.Class.getSimpleName(Class.java:1129)
at .<init>(<console>:6)
at .<clinit>(<console>)
at RequestR... |
@paulp said:
See also #2083, which to my frustration was closed wontfix. (It also arose in the course of what I think should be safe reflection calls.) |
@jrudolph said:
|
Matt Hellige (hellige) said: java.lang.IncompatibleClassChangeError: scala.collection.Map and scala.collection.Map$$$$anon$$5 disagree on InnerClasses attribute
at java.lang.Class.getDeclaringClass(Native Method)
at java.lang.Class.getEnclosingClass(Class.java:1085)
[...] I'm using Google's gson JSON library. AFAICS it's just doing very basic reflection... I might be able to find a workaround, but this problem is pretty serious. |
luxspes said: val classNames = Conversions.convertList(names).reduceLeft[String] { (acc, n) =>
acc + ", " + n
} Apparently this makes the compiler generate an incompatible inner class: java.lang.IncompatibleClassChangeError: com.googlecode.solder.dwr.WeldContainer and com.googlecode.solder.dwr.WeldContainer$$$$anonfun$$getClasses$$1 disagree on InnerClasses attribute
at java.lang.Class.getDeclaringClass(Native Method)
at java.lang.Class.getEnclosingClass(Class.java:1085)
at java.lang.Class.getSimpleBinaryName(Class.java:1220)
at java.lang.Class.getSimpleName(Class.java:1112)
at org.jboss.weld.util.Names.typeToString(Names.java:251)
at org.jboss.weld.util.Names.classToString(Names.java:263)
at org.jboss.weld.introspector.jlr.WeldClassImpl.<init>(WeldClassImpl.java:151)
at org.jboss.weld.introspector.jlr.WeldClassImpl.of(WeldClassImpl.java:133)
at org.jboss.weld.resources.ClassTransformer$$2.call(ClassTransformer.java:72)
at org.jboss.weld.resources.ClassTransformer$$2.call(ClassTransformer.java:68)
at java.util.concurrent.FutureTask$$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at org.jboss.weld.util.collections.ConcurrentCache.putIfAbsent(ConcurrentCache.java:125)
at org.jboss.weld.resources.ClassTransformer.loadClass(ClassTransformer.java:67)
at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:59)
at org.jboss.weld.bootstrap.BeanDeployer.addClasses(BeanDeployer.java:86)
at org.jboss.weld.bootstrap.BeanDeployment.deployBeans(BeanDeployment.java:134)
at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:367)
at org.jboss.weld.environment.servlet.Listener.contextInitialized(Listener.java:158)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) I guess this means Weld (JSR-299) and Scala are not compatible. Please fix this! |
Seto (seto) said: |
@dragos said: |
@jrudolph said: You may want to look into the [http://old.nabble.com/Re%3A-Scala-Interpreter-Oddity----General-Class-Name-Curio-p25869373.html mailing-list post] which contains more information. And here, again my example: Put that into test.scala: trait Test {
def testFunc(i:Int) = ((i:Int) => i + 5)(i)
} Then, do: % ~/downloads/sources/scala-2.8.0.r19722-b20091119020248/bin/scalac test.scala
% ~/downloads/sources/scala-2.8.0.r19722-b20091119020248/bin/scala -e 'Class.forName("Test$$$$anonfun$$testFunc$$1").getSimpleName'
java.lang.IncompatibleClassChangeError: Test and Test$$$$anonfun$$testFunc$$1 disagree on InnerClasses attribute
at java.lang.Class.getDeclaringClass(Native Method)
at java.lang.Class.getEnclosingClass(Class.java:1102)
at java.lang.Class.getSimpleBinaryName(Class.java:1237)
at java.lang.Class.getSimpleName(Class.java:1129)
at Main$$$$anon$$1.<init>((virtual file):6)
at Main$$.main((virtual file):5)
at Main.main((virtual file))
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at scala.tools.nsc.util.ScalaClassLoader$$$$anonfun$$run$$1.apply(ScalaClassLoader.scala:55)
at scala.tools.nsc.util.ScalaClassLoader$$class.asContext(ScalaClassLoader.scala:22)
at scala.tools.nsc.util.ScalaClassLoader$$URLClassLoader.asContext(ScalaClassLoader.scala:61)
at scala.tools.nsc.util.ScalaClassLoader$$class.run(ScalaClassLoader.scala:55)
at scala.tools.nsc.util.ScalaClassLoader$$URLClassLoader.run(ScalaClassLoader.scala:61)
at scala.tools.nsc.ScriptRunner$$.scala$$tools$$nsc$$ScriptRunner$$$$runCompiled(ScriptRunner.scala:326)
at scala.tools.nsc.ScriptRunner$$$$anonfun$$runCommand$$1.apply(ScriptRunner.scala:371)
at scala.tools.nsc.ScriptRunner$$$$anonfun$$runCommand$$1.apply(ScriptRunner.scala:371)
at scala.tools.nsc.ScriptRunner$$$$anonfun$$withCompiledScript$$1.apply(ScriptRunner.scala:298)
at scala.tools.nsc.ScriptRunner$$$$anonfun$$withCompiledScript$$1.apply(ScriptRunner.scala:298)
at scala.Option.map(Option.scala:74)
at scala.tools.nsc.ScriptRunner$$.withCompiledScript(ScriptRunner.scala:298)
at scala.tools.nsc.ScriptRunner$$.runCommand(ScriptRunner.scala:371)
at scala.tools.nsc.MainGenericRunner$$.main(MainGenericRunner.scala:140)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala) |
@dragos said: |
@jsuereth said: Using the following JDK: java version "1.6.0_22" I was able to induce this error with a simple static final Nested class with both -source and -target set to 1.5. Looks like we're not alone in the insanity. |
Compiling and running the attached Scala source (short) yields to this runtime exception,
java.lang.IncompatibleClassChangeError: SimpleName and SimpleName$$$$anon$$1 disagree on InnerClasses attribute
at java.lang.Class.getDeclaringClass(Native Method)
at java.lang.Class.getEnclosingClass(Class.java:1081)
at java.lang.Class.getSimpleBinaryName(Class.java:1216)
at java.lang.Class.getSimpleName(Class.java:1108)
at Foo.toString(SimpleName.scala:3)
at java.lang.String.valueOf(String.java:2615)
at java.io.PrintStream.print(PrintStream.java:616)
at java.io.PrintStream.println(PrintStream.java:753)
at scala.Console$$.println(Console.scala:162)
at scala.Predef$$.println(Predef.scala:156)
at SimpleName$$.(SimpleName.scala:13)
at SimpleName$$.(SimpleName.scala)
at SimpleName.main(SimpleName.scala)
The text was updated successfully, but these errors were encountered: