Scala Programming Language
  1. Scala Programming Language
  2. SI-4753

java.lang.ClassFormatError: Duplicate method name&signature in class file EXAMPLE$

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.9.0
    • Fix Version/s: Scala 2.10.0
    • Component/s: Misc Compiler
    • Labels:
      None
    • Environment:

      Glenn-Osbornes-MacBook-Pro-2:CatavoltRoot gwo$ scala -version
      Scala code runner version 2.9.0.1 – Copyright 2002-2011, LAMP/EPFL

      Description

      Mac OSX
      Scala 2.9.0-1 REPL

      scala> trait A

      { val typeName: String }

      defined trait A

      scala> trait B extends A

      { val actualType: Class[_]; final lazy val typeName = actualType.getName }

      defined trait B

      scala> trait C extends B

      { final val actualType = classOf[Boolean] }

      defined trait C

      scala> object EXAMPLE extends C
      java.lang.ClassFormatError: Duplicate method name&signature in class file EXAMPLE$
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:466)
      at scala.tools.nsc.interpreter.AbstractFileClassLoader.findClass(AbstractFileClassLoader.scala:52)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
      at scala.tools.nsc.interpreter.AbstractFileClassLoader.scala$tools$nsc$util$ScalaClassLoader$$super$loadClass(AbstractFileClassLoader.scala:17)
      at scala.tools.nsc.util.ScalaClassLoader$class.loadClass(ScalaClassLoader.scala:50)
      at scala.tools.nsc.interpreter.AbstractFileClassLoader.loadClass(AbstractFileClassLoader.scala:17)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
      at java.lang.Class.getDeclaredMethods0(Native Method)
      at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
      at java.lang.Class.privateGetPublicMethods(Class.java:2547)
      at java.lang.Class.getMethods(Class.java:1410)
      at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.evalMethod(IMain.scala:628)
      at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:592)
      at scala.tools.nsc.interpreter.IMain$Request$$anonfun$10.apply(IMain.scala:828)
      at scala.tools.nsc.interpreter.Line$$anonfun$1.apply$mcV$sp(Line.scala:43)
      at scala.tools.nsc.io.package$$anon$2.run(package.scala:31)
      at java.lang.Thread.run(Thread.java:680)

        Activity

        Hide
        Commit Message Bot added a comment -

        (extempore in r25217) Fixed a bug involving classOf[Foo] having the wrong erasure.
        Luckily I had only days ago deciphered the unique handling of
        classOf, so I knew what was up. Closes #4753, review by odersky.

        Show
        Commit Message Bot added a comment - (extempore in r25217 ) Fixed a bug involving classOf [Foo] having the wrong erasure. Luckily I had only days ago deciphered the unique handling of classOf, so I knew what was up. Closes #4753, review by odersky.
        Hide
        Ricardo L added a comment -

        This is not fixed yet in Scala 2.9.2. I just ran into a similar situation.
        See the current results below:

        rleon$ scala -version
        Scala code runner version 2.9.2 – Copyright 2002-2011, LAMP/EPFL
        rleon$ scala
        Welcome to Scala version 2.9.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_33).
        Type in expressions to have them evaluated.
        Type :help for more information.

        scala> trait A

        { val typeName: String }

        ; trait B extends A

        { val actualType: Class[_]; final lazy val typeName = actualType.getName }

        ; trait C extends B

        { final val actualType = classOf[Boolean] }

        ;
        defined trait A
        defined trait B
        defined trait C

        scala> object EXAMPLE extends C
        java.lang.ClassFormatError: Duplicate method name&signature in class file EXAMPLE$
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:465)
        at scala.tools.nsc.interpreter.AbstractFileClassLoader.findClass(AbstractFileClassLoader.scala:52)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at scala.tools.nsc.interpreter.AbstractFileClassLoader.scala$tools$nsc$util$ScalaClassLoader$$super$loadClass(AbstractFileClassLoader.scala:17)
        at scala.tools.nsc.util.ScalaClassLoader$class.loadClass(ScalaClassLoader.scala:50)
        at scala.tools.nsc.interpreter.AbstractFileClassLoader.loadClass(AbstractFileClassLoader.scala:17)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
        at java.lang.Class.privateGetPublicMethods(Class.java:2547)
        at java.lang.Class.getMethods(Class.java:1410)
        at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.evalMethod(IMain.scala:748)
        at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:704)
        at scala.tools.nsc.interpreter.IMain$Request$$anonfun$14.apply(IMain.scala:920)
        at scala.tools.nsc.interpreter.Line$$anonfun$1.apply$mcV$sp(Line.scala:43)
        at scala.tools.nsc.io.package$$anon$2.run(package.scala:25)
        at java.lang.Thread.run(Thread.java:680)

        If I remove the "final" keyword, it works.

        Show
        Ricardo L added a comment - This is not fixed yet in Scala 2.9.2. I just ran into a similar situation. See the current results below: rleon$ scala -version Scala code runner version 2.9.2 – Copyright 2002-2011, LAMP/EPFL rleon$ scala Welcome to Scala version 2.9.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_33). Type in expressions to have them evaluated. Type :help for more information. scala> trait A { val typeName: String } ; trait B extends A { val actualType: Class[_]; final lazy val typeName = actualType.getName } ; trait C extends B { final val actualType = classOf[Boolean] } ; defined trait A defined trait B defined trait C scala> object EXAMPLE extends C java.lang.ClassFormatError: Duplicate method name&signature in class file EXAMPLE$ at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) at java.lang.ClassLoader.defineClass(ClassLoader.java:615) at java.lang.ClassLoader.defineClass(ClassLoader.java:465) at scala.tools.nsc.interpreter.AbstractFileClassLoader.findClass(AbstractFileClassLoader.scala:52) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at scala.tools.nsc.interpreter.AbstractFileClassLoader.scala$tools$nsc$util$ScalaClassLoader$$super$loadClass(AbstractFileClassLoader.scala:17) at scala.tools.nsc.util.ScalaClassLoader$class.loadClass(ScalaClassLoader.scala:50) at scala.tools.nsc.interpreter.AbstractFileClassLoader.loadClass(AbstractFileClassLoader.scala:17) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2427) at java.lang.Class.privateGetPublicMethods(Class.java:2547) at java.lang.Class.getMethods(Class.java:1410) at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.evalMethod(IMain.scala:748) at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:704) at scala.tools.nsc.interpreter.IMain$Request$$anonfun$14.apply(IMain.scala:920) at scala.tools.nsc.interpreter.Line$$anonfun$1.apply$mcV$sp(Line.scala:43) at scala.tools.nsc.io.package$$anon$2.run(package.scala:25) at java.lang.Thread.run(Thread.java:680) If I remove the "final" keyword, it works.
        Hide
        Paul Phillips added a comment -

        I don't know why the ticket says "fixed in 2.9.0", but the patch is only in 2.10.

        Show
        Paul Phillips added a comment - I don't know why the ticket says "fixed in 2.9.0", but the patch is only in 2.10.

          People

          • Assignee:
            Paul Phillips
            Reporter:
            Glenn Osborne
          • Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development