-
Notifications
You must be signed in to change notification settings - Fork 225
Java 9 question & issue #119
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
This seems to be a case of Java 9 having better bytecode validation than Java 8. Retrolambda is unable to backport calls to default methods in foreign APIs (JDK or third-party libraries), so the results are undefined. Retrolambda needs to change invokestatic instructions to refer to normal method references instead of interface method references for them to work on Java < 8: https://github.com/orfjackal/retrolambda/blob/master/retrolambda/src/main/java/net/orfjackal/retrolambda/interfaces/FixInvokeStaticOnInterfaceMethod.java#L32 |
Here is the javap output of the method in question. The diff is between before running Retrolambda (-) and after running it (+).
|
If the code produced by Retrolambda can be run on Java 7, then it should also run on Java 8 and 9. There are no guarantees for code which uses APIs that don't exist on Java 7. |
Thanks, so as I suspected, the Java 9 byte-code verifier got better. |
My maven build fails with when compiling with Java 9
is there a way to workaround this? |
Are you using |
Hmm, now that I look at the stack trace more closely, it's coming from Retrolambda's code (it's the commandline parsing which happens before your code is even loaded). Please create a new issue. Preferrably with a sample project for reproducing the issue (http://sscce.org/). |
As a workaround you could try configuring |
Fails with also, specifying |
Are there any plans to support java 9, meaning that the generated bytecode should be compatible with java 9, right?
I'm asking this because I encountered an interesting issue:
I have a project lambdamatchers which has some lambdas based on Stream class, which I agree they are not supposed to work on Java < 8.
I run retrolambda on the classes and after I run unit tests using Java 8, it works fine with the code created by retrolambda (using as a target 1.5, 1.6, 1.7 and even 1.8), but when running the unit tests using Java 9 i get the
IncompatibleClassChangeError
:This can be easily reproduced with:
Stream::empty
is a static interface method, maybe the way they are invoked is the issue.Also, running unit tests with Java 9 without retrolambda-ing the project does not reproduce the issue.
I'm not 100% sure, but this might to be an issue with the jvm.
Note: This is not a real issue, I observed it during some tests, but I can work around it, as only the test code had issues, but I wanted to bring it into attention. Hopefully this does not cause problems for anybody. The test code in my case can be read as "the client code" and the client should not use retrolambda if the target is Java >= 8.
The text was updated successfully, but these errors were encountered: