You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Once compiled, this will produce a broken signature in interface corresponding to T1:
Compiled from "test-generic.scala"
public interface test.generic.T1SourceFile:"test-generic.scala"ScalaSig: length =0x3050000Signature: length =0x20004RuntimeVisibleAnnotations: length =0xB0001000600010007730008
minor version: 0
major version: 49Constantpool:
const #1=AscizSourceFile;
const #2=Asciz test-generic.scala;
const #3=AscizScalaSig;
const #4=Asciz <A:Ljava/lang/Object;>Ltest/generic/C1<TA;>;; //!!! interface extends a class, not very nice
const #5=AscizSignature;
const #6=AscizLscala/reflect/ScalaSignature;;
const #7=Asciz bytes;
const #9=AscizRuntimeVisibleAnnotations;
const #10=Asciz test/generic/T1;
const #11=class#10; // test/generic/T1
const #12=Asciz java/lang/Object;
const #13=class#12; // java/lang/Object
{
}
As a bonus, define Java code:
importtest.generic.*;
public classFoo {
public static <A> void foo(T1<A> x) {
x.m1();
}
public static void main(String[] args) {
T1<Object> x =newC2<Object>();
foo(x);
}
}
and compile it using javac. Once you run, you get:
Exception in thread "main" java.lang.NoSuchMethodError: test.generic.T1.m1()V
at Foo.foo(Foo.java:6)
at Foo.main(Foo.java:11)
Which means that javac got completely confused by broken signature and created a broken class file itself. Not very good.
The solution would be to skip classes from list of extended things. We should only list traits (if there are any) so we get signature for interface that refers to interfaces only. This solution has been discussed with Martin and he is ok with it.
The text was updated successfully, but these errors were encountered:
@gkossakowski said:
Also, it's worth mentioning that signatures for interfaces should always list java.lang.Object as a super class. Thus our signature would become: <A:Ljava/lang/Object;>Ljava/lang/Object;
Commit Message Bot (anonymous) said:
(extempore in r25468) Fix java signature generation for traits: no classes as parents.
Closes #4891, review by grek.
Consider following Scala code:
Once compiled, this will produce a broken signature in interface corresponding to T1:
As a bonus, define Java code:
and compile it using javac. Once you run, you get:
Which means that javac got completely confused by broken signature and created a broken class file itself. Not very good.
The solution would be to skip classes from list of extended things. We should only list traits (if there are any) so we get signature for interface that refers to interfaces only. This solution has been discussed with Martin and he is ok with it.
The text was updated successfully, but these errors were encountered: