Aladdin - Scala Bugtracking
[#79] project: compiler priority: medium category: bug
submitter assigned to status date submitted
Matthias Michel fixed 2003-07-21 14:05:26.0
subject Too many methods mixed in
code
object Test {
  import scala.collection._;
  def main(args: Array[String]) = {
    val map =
        new mutable.ImmutableMapAdaptor[Int, String, immutable.ListMap[Int, String]](
            immutable.ListMap.Empty[Int, String]);
      map += 1 -> "one";
      map += 2 -> "two";
      map -= 1;
      System.out.println(map);
  }
}
what happened
Compiles, but when executing the program, the following exception is thrown:
Exception in thread "main" java.lang.ClassFormatError: scala/collection/mutable/ImmutableMapAdaptor
(Repetitive method name/signature)
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:250)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
        at Test.main(T.scala)
Sorry, I couldn't reduce the program.
what expected In the Java interface representing scala.collection.mutable.ImmutableMapAdaptor there are two abstract toString methods. Of course, we want only one; in the optimal case even none! (since every interface defines implicitly a subtype of java.lang.Object.
[back to overview]
Changes of this bug report
Matthias  edited on  2003-07-21 14:05:49.0
Matthias  edited on  2003-07-21 14:08:04.0
Michel  edited on  2003-07-22 09:23:02.0

This was actually a bug in ImmutableMapAdaptor.scala, which defined the "toString" method twice. Since this is not catched (yet) by the compiler, it goes to the backend which generates two identical method definitions. I fixed ImmutableMapAdaptor, and your program now runs.

As we discussed already several times, this should (and will) be fixed in Erasure.

Matthias  edited on  2003-07-22 10:02:56.0
Ah, this explains why I couldn't reduce the "bug".... Sorry!