Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-7120

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

    Details

    • Type: Bug
    • Status: CLOSED
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: Scala 2.10.0
    • Fix Version/s: Scala 2.11.0-M2
    • Component/s: None
    • Labels:
      None

      Description

      After migrating from 2.9.2 to 2.10 my team has encountered a runtime ClassFormatError, which I've managed to reduce to a simple single-file reproduction case which involves a type parameter, type alias and a partial function. The sample is reproduced here (full code as a gist):

      case class Container( v: String )
       
      trait Base[ T <: AnyRef ] {
        type UserType = T
      	protected def defect: PartialFunction[ UserType, String ]
      }
       
      trait Derived extends Base[ Container ] {
        protected def defect = { case c: Container => c.v.toString }
      }
       
      object Test extends Derived with App {
      	println( defect( Container( "8" ) ) )
      }
      

      The generated class file for Derived.defect clearly has duplicate method signatures:

      wanamingo:tmp tomer$ scalap -cp . 'com.tomergabel.examples.Derived$$anonfun$defect$1'
      package com.tomergabel.examples;
      final class Derived$$anonfun$defect$1 extends scala.runtime.AbstractPartialFunction with scala.Serializable {
        def this(com.tomergabel.examples.Derived): scala.Unit;
        def applyOrElse(scala.Any, scala.Function1): scala.Any;
        def isDefinedAt(scala.Any): scala.Boolean;
        def isDefinedAt(com.tomergabel.examples.Container): scala.Boolean;
        def applyOrElse(scala.Any, scala.Function1): scala.Any;
      }
      object Derived$$anonfun$defect$1 {
        final val serialVersionUID: scala.Long;
      }
      

      Fortunately this can be worked around by qualifying the derived method with a full return type:

        protected def defect: PartialFunction[ Container, String ] = { case c: Container => c.v.toString }
      

        Attachments

          Activity

            People

            • Assignee:
              retronym Jason Zaugg
              Reporter:
              holograph Tomer Gabel
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: