Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extensions broken from Java when compiled using JDK11 #25449

Closed
chbatey opened this Issue Aug 8, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@chbatey
Copy link
Member

chbatey commented Aug 8, 2018

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.

@chbatey chbatey changed the title Extensions broken from Java in JDK11 Extensions broken from Java when compiled using JDK11 Aug 8, 2018

@ktoso ktoso referenced this issue Aug 8, 2018

Open

Support features of JDK 9+ #139

5 of 16 tasks complete
@ktoso

This comment has been minimized.

Copy link
Member

ktoso commented Aug 8, 2018

May want to open a ticket on scala/scala I guess

eed3si9n added a commit to eed3si9n/scala that referenced this issue Aug 11, 2018

Emit bridge method forwarders with BRIDGE flag
Fixes scala/bug#11061
Ref scala/bug#10812

On 2.13.x branch scala#6531 removed the forwarder for bridge methods. I would like to do same in 2.12.x since Java 11-ea started to find them ambiguous as seen in akka/akka#25449 / scala/bug#11061.

To keep binary compatibility, I am still emitting the forwarder for bridge methods, but with `ACC_BRIDGE` flag.

eed3si9n added a commit to eed3si9n/scala that referenced this issue Aug 20, 2018

[nomerge] Emit bridge method forwarders with BRIDGE flag
Fixes scala/bug#11061
Ref scala/bug#10812

On 2.13.x branch scala#6531 removed the mirror class forwarders for bridge methods. I would like to do same in 2.12.x since Java 11-ea started to find them ambiguous as seen in akka/akka#25449 / scala/bug#11061.

To keep binary compatibility, I am still emitting the forwarders for bridge methods, but with `ACC_BRIDGE` flag.

eed3si9n added a commit to eed3si9n/scala that referenced this issue Aug 20, 2018

[nomerge] Emit bridge method forwarders with BRIDGE flag
Fixes scala/bug#11061
Ref scala/bug#10812

On 2.13.x branch scala#6531 removed the mirror class forwarders for bridge methods. I would like to do same in 2.12.x since Java 11-ea started to find them ambiguous as seen in akka/akka#25449 / scala/bug#11061.

To keep binary compatibility, I am still emitting the forwarders for bridge methods, but with `ACC_BRIDGE` flag.

@johanandren johanandren added t:jdk and removed t:jdk-next labels Oct 4, 2018

@johanandren

This comment has been minimized.

Copy link
Member

johanandren commented Oct 4, 2018

Fixed now when we are up on Scala 2.12.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.