JDK11 is still in early release but just tried this.
With Scala 2.11.6 and JDK8/9/10 compiling an extension e.g.
object TestKitExtension extends ExtensionId[TestKitSettings] {
override def get(system: ActorSystem): TestKitSettings = super.get(system)
def createExtension(system: ExtendedActorSystem): TestKitSettings = new TestKitSettings(system.settings.config)
}
Where ExtentionId is:
trait ExtensionId[T <: Extension] {
def apply(system: ActorSystem): T = {
java.util.Objects.requireNonNull(system, "system must not be null!").registerExtension(this)
}
def get(system: ActorSystem): T = apply(system)
def createExtension(system: ExtendedActorSystem): T
}
The override def get would result in a single get method in the compiled class:
javap TestKitExtension [NORMAL]
Warning: Binary file TestKitExtension contains akka.testkit.TestKitExtension
Compiled from "TestKitExtension.scala"
public final class akka.testkit.TestKitExtension {
public static boolean equals(java.lang.Object);
public static int hashCode();
public static akka.actor.Extension apply(akka.actor.ActorSystem);
public static akka.testkit.TestKitSettings createExtension(akka.actor.ExtendedActorSystem);
public static akka.testkit.TestKitSettings get(akka.actor.ActorSystem);
}
When compiled with Scala 2.12.6 and JDK11:
javap TestKitExtension
Warning: Binary file TestKitExtension contains akka.testkit.TestKitExtension
Compiled from "TestKitExtension.scala"
public final class akka.testkit.TestKitExtension {
public static boolean equals(java.lang.Object);
public static int hashCode();
public static akka.actor.Extension apply(akka.actor.ActorSystem);
public static akka.testkit.TestKitSettings createExtension(akka.actor.ExtendedActorSystem);
public static akka.testkit.TestKitSettings get(akka.actor.ActorSystem);
public static akka.actor.Extension get(akka.actor.ActorSystem);
}
We end up with two get methods so any call to them won't compile as it is ambiguous.
May want to open a ticket on scala/scala I guess
Fixed now when we are up on Scala 2.12.7
Most helpful comment
Fixed now when we are up on Scala 2.12.7