-
Notifications
You must be signed in to change notification settings - Fork 21
Cannot generate java-compatible abstract varargs method #10658
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
Comments
How does this (does it even?) relate to #3899? |
It is a bit different, since scalac is, in fact, generating the correct Java varargs signature:
but the problem is that it isn't making it abstract; it is generating it as a concrete implementation that (I presume) is calling the generated abstract:
I'm suspected that this is new as of scala's support for JDK 1.8 interfaces with default implementations. So I tried targeting JDK 1.7 with scalac's 2.11 compiler and I see that the method is indeed output in a way that JNA can use it:
But since "-target:jvm-1.7" is unavailable in scalac 2.12, this isn't a viable workaround. |
I am running up against this as well. I have the following method in a trait.
And try to overrride with the following from Java.
I get the following error:
See update below. |
My comment above was a misunderstanding about the way the code was generated.
Once number 3 was complete, only one method was needed. If the forwarding method in Java was not there, property based testing would have found it I think as you can pass an array to a Java varargs method otherwise property based testing would not test it at all from Scala to Java. I think the key take home is that if you are using
|
Update: Things are a bit more complex but seem to work. Steps followed.
You can not override the method with the Java signature but you can add a method to allow the Java code to run. I didn't investigate the byte code but the solution is not very intuitive but can be used it seems. |
Update working code is here. Dead link removed above. Annotation in the interface is here. Edit 3-3-2020 - fix link Issue filed with Dotty: scala/scala3#7212 @SethTisue Can this issue be closed? |
I need to generate a java-compatible varargs method in an interface in order to access a JNA native method (which relies on the varargs signature). This appears to still be an issue in 2.12.4, despite some other similar issues (such as #1459) listing this as having been fixed.
The text was updated successfully, but these errors were encountered: