-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
Description
Compiler version
3.6.3-RC2
Minimized code
trait I0 {
def func(): AnyRef
}
trait I1 extends I0 {
override def func(): String = "123"
}Output
Use javap -c -s- v I1 to check the bytecode: (Simplified it a bit)
public static java.lang.String func$(I1);
descriptor: (LI1;)Ljava/lang/String;
flags: ACC_PUBLIC, ACC_STATIC
public java.lang.String func();
descriptor: ()Ljava/lang/String;
flags: ACC_PUBLICExpectation
When I1 is written by Java, the output is:
public java.lang.String func();
descriptor: ()Ljava/lang/String;
flags: ACC_PUBLIC
public java.lang.Object func();
descriptor: ()Ljava/lang/Object;
flags: ACC_PUBLIC, ACC_BRIDGE, ACC_SYNTHETIC
}Note that java does not generate static method func$ here. But scalac misses a bridge method here.
Further bug: java.lang.AbstractMethodError when implements I1 with a Java class
trait I0 {
def func(): AnyRef
}
trait I1 extends I0 {
override def func(): String = "123"
}
object Main {
def main(args: Array[String]): Unit = {
val i0: I0 = A()
println(i0.func())
}
}// Java file
public class A implements I1 {
}Exception in thread "main" java.lang.AbstractMethodError: Method A.func()Ljava/lang/Object; is abstract
at A.func(A.java)
at Main$.main(A1.scala:14)
at Main.main(A1.scala)