1.0.0-beta2 lambda-conversion compile error (full stack trace included) (robovm-maven-plugin)

104 views
Skip to first unread message

Michael Ennen

unread,
Jan 6, 2015, 7:03:35 PM1/6/15
to rob...@googlegroups.com
Hello,

When I attempt to compile my Java 8 project via the maven plugin, I get the following error:

[ERROR] Failed to execute goal org.robovm:robovm-maven-plugin:1.0.0-beta-02:ipad-sim (default-cli) on project ios: Execution default-cli of goal org.robovm:robovm-maven-plugin:1.0.0-beta-02:ipad-sim failed: org.robovm.compiler.plugin.lambda.java.lang.invoke.LambdaConversionException: Functional interface java.util.function.ToDoubleFunction is not an interface -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.robovm:robovm-maven-plugin:1.0.0-beta-02:ipad-sim (default-cli) on project ios: Execution default-cli of goal org.robovm:robovm-maven-plugin:1.0.0-beta-02:ipad-sim failed: org.robovm.compiler.plugin.lambda.java.lang.invoke.LambdaConversionException: Functional interface java.util.function.ToDoubleFunction is not an interface
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.robovm:robovm-maven-plugin:1.0.0-beta-02:ipad-sim failed: org.robovm.compiler.plugin.lambda.java.lang.invoke.LambdaConversionException: Functional interface java.util.function.ToDoubleFunction is not an interface
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:143)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 25 more
Caused by: org.robovm.compiler.CompilerException: org.robovm.compiler.plugin.lambda.java.lang.invoke.LambdaConversionException: Functional interface java.util.function.ToDoubleFunction is not an interface
at org.robovm.compiler.plugin.lambda.LambdaPlugin.transformMethod(LambdaPlugin.java:172)
at org.robovm.compiler.plugin.lambda.LambdaPlugin.beforeClass(LambdaPlugin.java:85)
at org.robovm.compiler.ClassCompiler.compile(ClassCompiler.java:605)
at org.robovm.compiler.ClassCompiler.compile(ClassCompiler.java:282)
at org.robovm.compiler.AppCompiler.compile(AppCompiler.java:233)
at org.robovm.compiler.AppCompiler.compile(AppCompiler.java:283)
at org.robovm.compiler.AppCompiler.compile(AppCompiler.java:326)
at org.robovm.maven.plugin.AbstractRoboVMMojo.buildArchive(AbstractRoboVMMojo.java:370)
at org.robovm.maven.plugin.AbstractIOSSimulatorMojo.execute(AbstractIOSSimulatorMojo.java:61)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
... 26 more
Caused by: org.robovm.compiler.plugin.lambda.java.lang.invoke.LambdaConversionException: Functional interface java.util.function.ToDoubleFunction is not an interface
at org.robovm.compiler.plugin.lambda.java.lang.invoke.AbstractValidatingLambdaMetafactory.<init>(AbstractValidatingLambdaMetafactory.java:147)
at org.robovm.compiler.plugin.lambda.java.lang.invoke.InnerClassLambdaMetafactory.<init>(InnerClassLambdaMetafactory.java:157)
at org.robovm.compiler.plugin.lambda.java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:300)
at org.robovm.compiler.plugin.lambda.LambdaPlugin.transformMethod(LambdaPlugin.java:121)
... 35 more

It's curious, because ToDoubleFunction is indeed an interface...something whacky is going on with the lambda conversion.

Thanks very much!

Niklas Therning

unread,
Jan 7, 2015, 5:35:48 AM1/7/15
to Michael Ennen, rob...@googlegroups.com
The ToDoubleFunction interface is not available in RoboVM's runtime
class library. RoboVM's runtime is based on Android's which doesn't
have this interface either. This is probably why you see this error.
You will have to change your code if possible to make it work without
ToDoubleFunction in order to get it to work on RoboVM.
> --
> You received this message because you are subscribed to the Google Groups
> "RoboVM" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to robovm+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Michael Ennen

unread,
Jan 8, 2015, 3:21:11 AM1/8/15
to rob...@googlegroups.com, mike....@gmail.com
Niklas,

Thanks for the info. Would it be possible to add the classes from Java 8's java.util.function package to the robovm libraries? Having the lambda conversion in robovm seems incomplete without providing the interfaces that are so commonly used as lambdas in Java 8.

Niklas Therning

unread,
Jan 8, 2015, 5:21:58 AM1/8/15
to Michael Ennen, rob...@googlegroups.com
In the future we will hopefully add OpenJDK's runtime as an option
which will give you all the functional interfaces and other Java8
APIs. We cannot just rip out those interfaces from OpenJDK and include
in RoboVM's runtime I'm afraid because of licensing issues. Someone
would have to make a clean room Apache licensed implementation of the
interfaces without looking at Oracle's code.

While you wait for us to add OpenJDK support (it won't happen any time
soon) you can provide those interfaces yourself. Just copy them from
OpenJDK's sources or write them from scratch and place then in your
project in the correct packages and your app should compile fine.

Michael Ennen

unread,
Jan 8, 2015, 4:36:07 PM1/8/15
to rob...@googlegroups.com
Where would I place them so robovm-maven-plugin can see them, since one can't put anything in the java.* packages. Thanks for helping me walk through this, I really appreciate it.

Niklas Therning

unread,
Jan 9, 2015, 2:29:59 AM1/9/15
to Michael Ennen, rob...@googlegroups.com
I don't think the Java compiler will have any issues with classes in java.* packages. We compile the RoboVM runtime classes (which are under java.*, javax.*) using Maven without any special options. Hotspot will complain if you have java.* classes in the user classpath and not in the bootclasspath. RoboVM will happily accept that.

--

Michael Ennen

unread,
Jan 9, 2015, 3:49:06 PM1/9/15
to rob...@googlegroups.com, mike....@gmail.com
Okay I am beginning to think I understand what you are saying, so that's good. The runtime classes are in robovm-rt.jar. One option I have is to include the classes I need in that library and re-compile it. I am currently using the robovm-maven-plugin and so I am wondering if there is a config option where I can specify that the plugin use my local .jar (with the added classes) as opposed to the one in maven central. 

Thanks.

Niklas Therning

unread,
Jan 15, 2015, 2:43:14 AM1/15/15
to Michael Ennen, rob...@googlegroups.com
IIRC there's no currently  way to override the boot classpath from a maven build. The rt jar goes in the boot classpath. What we did to make JavaFX work on RoboVM was to just package stubs for  the missing Java 8 classes in a separate jar and include as a dependency. That will work and imo it is a lot easier than repackaging the rt jar.

Michael Ennen

unread,
Jan 15, 2015, 4:00:38 AM1/15/15
to rob...@googlegroups.com, mike....@gmail.com
I was able to get it to work with that suggestion, just added the classes I need (in java.util.function) to the src directory. Thanks very much.
To unsubscribe from this group and stop receiving emails from it, send an email to robovm+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages