Skip to content
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

Retrolambda can not be run under JDK 9 #137

Closed
teras opened this issue Dec 7, 2017 · 4 comments
Closed

Retrolambda can not be run under JDK 9 #137

teras opened this issue Dec 7, 2017 · 4 comments

Comments

@teras
Copy link

teras commented Dec 7, 2017

If we run retrolambda under Java 9, then this error appears:

java.lang.IncompatibleClassChangeError: Method java.util.stream.Stream.of([Ljava/lang/Object;)Ljava/util/stream/Stream; must be InterfaceMethodref constant
	at net.orfjackal.retrolambda.SystemPropertiesConfig.parsePathList(SystemPropertiesConfig.java:158)
	at net.orfjackal.retrolambda.SystemPropertiesConfig.getClasspath(SystemPropertiesConfig.java:148)
	at net.orfjackal.retrolambda.Retrolambda.run(Retrolambda.java:25)
	at net.orfjackal.retrolambda.Main.main(Main.java:28)

Compared with issue #119 indeed at net.orfjackal.retrolambda.SystemPropertiesConfig.parsePathList(SystemPropertiesConfig.java:158) there is a call to Stream.of which, since retrolamda jar is downgraded, it falls to the same problem.

Apart of the obvious answer ("run retrolambda under Java 8), is there any real solution to this problem?

@luontola
Copy link
Owner

This problem originates from Retrolambda's build processing itself with Retrolambda so that the Maven plugin, which is Java 6 compatible, can be compiled to call Retrolambda's APIs directly. Some options for fixing this:

  • Move those classes that the Maven plugin uses (SystemPropertiesConfig) into another module which is compiled using Java 6 (calling the main method probably needs reflection), and do not run Retrolambda on itself.
  • Avoid using the Stream API inside Retrolambda and instead use the streamsupport library.
  • Downgrade Retrolambda's code to pre-Java 8.

I'll try out the first option and see how it goes...

@teras
Copy link
Author

teras commented Dec 26, 2017

I think the problem could be easily solved by replacing

        return Stream.of(paths.split(File.pathSeparator))

with

        return Arrays.asList(paths.split(File.pathSeparator)).stream()

at retrolambda/retrolambda/src/main/java/net/orfjackal/retrolambda/SystemPropertiesConfig.java line 158

@luontola
Copy link
Owner

This has been fixed in Retrolambda 2.5.2

@ghost
Copy link

ghost commented Dec 28, 2017

Had this issue in Gradle 4.4.1 - currently the most recent version. Gradle 4.4.1 uses Retrolambda 2.5.1 so I hope they add the fixed version soon. I reported this issue here: Gradle - Issue 3921

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants