Akka TypedActor with abstract members from trait cause java.lang.AbstractMethodError

483 Views Asked by At

Given the following code:

import akka.actor._

object TraitTest {
  trait A {
    def something()
  }
  trait B extends A
  class C extends TypedActor with B {
    override def something() {
      println("Why am I not implemented?")
    }
  }

  def main(args: Array[String]) {
    val service = TypedActor.newInstance(classOf[B], classOf[C]) 
    service.something()
  }
}

When running the main, I get the following exception:

Exception in thread "main" java.lang.AbstractMethodError: TraitTest$B$$ProxiedByAWDelegation$$1322144340710.something()V
    at TraitTest$.main(TraitTest.scala:29)
    at TraitTest.main(TraitTest.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Now, google finally spat out this link, however I don't understand how this 'works as designed'.

Could anybody please shed some light on the issue?

Thanks!

Edit
If I change my code as follows, I obviously do not get the error. However, this is of course not a solution, but more a temporary workaround.

trait B extends A {
    override def something()
  }
1

There are 1 best solutions below

3
On

We've completely reworked the TypedActor implementation for 2.0 and scrapped using bytecode weaving to implement it. This leads to a much more robust and powerful feature.

Are you running it on jdk7? (we've seen some shenanigans with that) Can you try to implement the method with the correct signature? (omitted return type == Any, but you override it with Unit-return type)

Cheers, √