My company ran into a pretty serious issue yesterday in the process of trying to migrate our stack from Scala 2.8.1 to 2.9.1. We are in the (unfortunate) situation of still being heavily reliant on Jersey for web services. We were also making heavy use of traits in our REST resources for modularizing shared behavior. Yesterday, we discovered that methods defined in traits are treated as bridge methods in concrete classes that mix them in. Jersey ignores bridge methods when collecting a resource's methods. This is a serious problem for us. What's the motivation for this new behavior in Scala 2.9.1?
Here's a snippet from a 2.9.1 REPL transcript to illustrate the behavior:
scala> trait Base { def getFoo(): String = "foo" }
defined trait Base
scala> class Sub extends Base { def getBar(): String = "bar" }
defined class Sub
scala> classOf[Sub].getDeclaredMethods
res19: Array[java.lang.reflect.Method] = Array(public java.lang.String Sub.getFoo(), public java.lang.String Sub.getBar())
scala> classOf[Sub].getDeclaredMethods()(0).isBridge
res20: Boolean = true
scala> classOf[Sub].getDeclaredMethods()(1).isBridge
res21: Boolean = false
Are there any recommended work-arounds?
Thanks,
Robert
This is a serious problem for us. What's the motivation for this new behavior in Scala 2.9.1?
Thanks, Paul. Two questions: can you point me to the corresponding fix? I'd be interested to see what was required. Secondly, do you have any idea when we might expect to see another 2.9.x release?