-
Notifications
You must be signed in to change notification settings - Fork 227
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
Default methods are not correctly backported #56
Comments
If it can help, I can add the following: |
This will instead work: public class Test2 {
static {
TestI t = new TestC();
t.test();
}
} I also tried to run it inside main() and it works, while this doen't: public class Test2 {
static {
TestC t = new TestC();
t.test();
}
} (I just changed the type of t) |
I'm unable to reproduce this. Here is the output from javap:
|
Based on your report of I presume that this is the case here, so I'm closing this issue. |
Hi, thanks for your time. I'm going to try to explain better what I want to achieve and what I understood for what the retrolambda incremental compiling limitation is. First, I'd like to do the following, which I supposed I could do:
All went well until I invoke, as the opened issue, a method on an object declared as itself when this method is declared as default in interface and it is not overridden. Maybe I was wrong but I supposed that the backport task would put the missing implementations in all the classes without the method. But it does not work.
So the method is there. For incremental compiling limitation I understood that, if I want to create or modify a class that implements the backported interface this does not work because it cannot backport the default method again in the new class. This sounds right and I can live with that. You already backported missing methods so I understand you cannot backport them twice. What made me open the issue is that the compiler output changes depending on how I declare the object (interface or itself) I do not know the implementation details but is it possible to have the backported classes work if I just use it without adding any functionality (e.g., new overriding classes)? Finally, now I'm using a simple workaround that is to implement the default methods in the concrete classes (point 2 of exceptions). Doing so it works. Am I wrong or does it make any sense to you? Thanks |
Ok, so it's some issue to do with using the methods from a different module. I'll look into it. There are a bunch of corner cases in the Java language there. |
It might have to do with Retrolambda marking the method in TestC as synthetic. I'll need to check the language spec to see whether the Java compiler disallows such calls... |
This is fixed in Retrolambda 2.0.4 |
As stated in the guide:
If I have this interface:
and this class:
as far as I understand the output of retrolambda will be:
So, If then I have a new class:
This should work. Am I right?
I'm asking this because it doesn't.
If I decompile I found:
and:
I don't think the last one is right. I'm doing something wrong or I didn't understand the section:
If I use javap I obtain
So the method is there but as the decompiler cannot find it neither javac does.
I tried both using compatibility with bytecode 50 and 51 using the latest version.
You can reproduce it by using the same source code
Of course it would be nice if my TestC has all the implementation so that I can use it in other java7 project.
The text was updated successfully, but these errors were encountered: