Aladdin - Scala Bugtracking
[#135] project: compiler priority: high category: bug
submitter assigned to status date submitted
Erik Martin fixed 2003-09-11 18:28:36.0
subject java.lang.ClassFormatError
code
import scala.collection.immutable.TreeMap;
import scala.collection.immutable.Order;

object Test with Executable {
    test1();
    Console.println("OK");

    val intOrder = 
	new Order((x:int,y:int) => x < y, (x:int,y:int) => x == y);     
   
    def test1() = {
	val myMap:TreeMap[int,String] = new TreeMap(intOrder);
	val map1 = myMap + 42 -> "The answer";
    }
}
what happened
When running this as a test (note the test file is not checked in):
[lamppc35]tmp 770 >./scala/test/bin/scala-test  --show-diff --run ~/scala/test/
files/run/map_test.scala
Test configuration
socos executable: /home/stenman/tmp/scala/bin/scalac
surus executable: /home/stenman/tmp/scala/bin/scalarun
scala runtime   : /home/stenman/tmp/scala/classes

Testing interpreter
testing: /home/stenman/scala/test/files/run/map_test.scala            [FAILED]
1,11c1
< Exception in thread "main" java.lang.AssertionError: scala.collection.immutabl
e.TreeMap$class->scala.collection.immutable.Map.$plus
<         at scalai.ScalaTemplate.invoke(ScalaTemplate.java:81)
<         at scalai.ScalaObject.invoke(ScalaObject.java:38)
<         at scalai.Evaluator.invoke(Evaluator.java:228)
<         at scalai.Evaluator.evaluate(Evaluator.java:177)
<         at scalai.Evaluator.evaluate(Evaluator.java:172)
<         at scalai.Evaluator.evaluate(Evaluator.java:168)
<         at scalai.Evaluator.evaluate(Evaluator.java:141)
<         at Test.test1(map_test.scala:13)
<         at Test.(map_test.scala:5)
<         at .Test(map_test.scala:4)
---
> OK

Testing jvm backend
testing: /home/stenman/scala/test/files/run/map_test.scala            [FAILED]
1,22c1
< Exception in thread "main" java.lang.ClassFormatError: scala/collection/immuta
ble/Tree$$scala$collection$immutable$Tree$Node$class (Repetitive field name/sign
ature)
<       at java.lang.ClassLoader.defineClass0(Native Method)
<       at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
<       at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
3)
<       at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
<       at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
<       at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
<       at java.security.AccessController.doPrivileged(Native Method)
<       at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
<       at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
<       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
<       at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
<       at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
<       at scala.collection.immutable.Tree$$scala$collection$immutable$Tree$Nil$
class.insert(sources/scala/collection/immutable/Tree.scala:250)
<       at scala.collection.immutable.TreeMap$class.insert(sources/scala/collect
ion/immutable/TreeMap.scala:38)
<       at scala.collection.immutable.TreeMap$class.update(sources/scala/collect
ion/immutable/TreeMap.scala:33)
<       at scala.collection.immutable.TreeMap$class.update(sources/scala/collect
ion/immutable/TreeMap.scala:31)
<       at scala.collection.immutable.Map$MapTo$class.$minus$greater(sources/sca
la/collection/immutable/Map.scala:76)
<       at Test$.test1(/home/stenman/scala/test/files/run/map_test.scala:13)
<       at Test$.(/home/stenman/scala/test/files/run/map_test.scala:5)
<       at Test$.(/home/stenman/scala/test/files/run/map_test.scala)
<       at Test.main(/home/stenman/scala/test/files/run/map_test.scala)
---
> OK

There were 2 tests that failed
what expected That the program would run without an error and print OK. Now there might very well be a bug in my TreeMap or Tree implementation, but in that case it looks like a problem the compiler should notice.
[back to overview]
Changes of this bug report
Erik  edited on  2003-09-11 18:40:30.0
This actualy seems to be two different bugs, one for the jvm and one for the interpreter. The interpreter error seems to also occur with Matthias ListMap:
import scala.collection.immutable.TreeMap;
import scala.collection.immutable.ListMap;
import scala.collection.immutable.Order;

object Test with Executable {
    test2();
    Console.println("OK");

    val intOrder = 
	new Order((x:int,y:int) => x < y, (x:int,y:int) => x == y);     

    def test1() = {
	val myMap:TreeMap[int,String] = new TreeMap(intOrder);
	val map1 = myMap + 42 -> "The answer";
    }   

    def test2() = {
	val myMap:ListMap[int,String] = new ListMap;
	val map1 = myMap + 42 -> "The answer";
    }
}

[lamppc35]tmp 772 >./scala/test/bin/scala-test  --show-diff --run ~/scala/test/
files/run/map_test.scala
Test configuration
socos executable: /home/stenman/tmp/scala/bin/scalac
surus executable: /home/stenman/tmp/scala/bin/scalarun
scala runtime   : /home/stenman/tmp/scala/classes

Testing interpreter
testing: /home/stenman/scala/test/files/run/map_test.scala            [FAILED]
1,11c1
< Exception in thread "main" java.lang.AssertionError: scala.collection.immutabl
e.ListMap$class->scala.collection.immutable.Map.$plus
<         at scalai.ScalaTemplate.invoke(ScalaTemplate.java:81)
<         at scalai.ScalaObject.invoke(ScalaObject.java:38)
<         at scalai.Evaluator.invoke(Evaluator.java:228)
<         at scalai.Evaluator.evaluate(Evaluator.java:177)
<         at scalai.Evaluator.evaluate(Evaluator.java:172)
<         at scalai.Evaluator.evaluate(Evaluator.java:168)
<         at scalai.Evaluator.evaluate(Evaluator.java:141)
<         at Test.test2(map_test.scala:19)
<         at Test.(map_test.scala:6)
<         at .Test(map_test.scala:5)
---
> OK

Testing jvm backend
testing: /home/stenman/scala/test/files/run/map_test.scala            [  OK  ]

There was 1 test that failed

Matthias  edited on  2003-09-12 12:51:23.0
Burak  edited on  2003-09-23 18:24:52.0
change priority to high
Philippe  edited on  2003-09-30 13:12:50.0

Changed Type.erasure to replace all prefixes by localThisTypes. This solves a problem that affected the interpreter which could not find the implementation of some methods because their signature was wrong (prefixes were of the wrong thistypes). This problem showed up in the following test case:

class Foo { class Bar; def foo = new Bar; } object Test { def main(args: Array[String]): Unit = { (new Foo).foo; () } }
Philippe  edited on  2003-09-30 18:19:26.0

This bug needs at least the correction of bug #167, so I reassigned it to Martin.

Philippe  edited on  2003-09-30 19:02:14.0

Fixed bug 167. This also fixed this bug.

Philippe  edited on  2003-09-30 19:02:58.0

Changed bug status.