robovm
robovm copied to clipboard
Build fails due to a multi-cast with a shadowed exception
Issue details
My build with robovm fails due to a multi-catch when one of the exceptions is shadowed (in this case, java.nio.file.ClosedWatchServiceException
). The following block fails:
https://github.com/ecsec/open-ecard/blob/36ae6a497b5668a2c9fe58c9761be53f91d68c08/addon/src/main/java/org/openecard/addon/AddonFileSystemMonitor.java#L153
} catch (ClosedWatchServiceException | InterruptedException ex) {
logger.info("Watch service closed while waiting for changes.");
}
I found this issue https://github.com/Sable/soot/issues/167 and was inspired the following workaround. I can fix it by breaking the multi-cast up, so the shadowed class is in a separate catch block.
-- } catch (ClosedWatchServiceException | InterruptedException ex) {
++ } catch (ClosedWatchServiceException ex) {
++ logger.info("Watch service closed while waiting for changes.");
++ } catch (InterruptedException ex) {
Reproduction steps/code
git clone [email protected]:ecsec/open-ecard.git
cd open-ecard
# The following hash is currently origin/fix_ios_packaging
git checkout 36ae6a497b5668a2c9fe58c9761be53f91d68c08
mvn clean install -DskipTests -pl :ios-core -am
cd packager/ios-framework
mvn clean install -e
Configuration
Build Tools:
- [ ] IDEA plugin
- [ ] Eclipse plugin
- [ ] Gradle plugin
- [x] Maven plugin
Versions:
- Robovm: 2.3.8-SNAPSHOT (freshly downloaded 20/09/2019)
- XCode: Xcode-beta 6
- JDK: openjdk-11.0.2
Build Targets:
- framework
Stacktrace
The above process fails with the following statements.
Warning: java.nio.file.ClosedWatchServiceException is a phantom class!
Warning: javax.annotation.Nullable is a phantom class!
[INFO] Compiling org.openecard.addon.AddonFileSystemMonitor$Runner (ios arm64 release)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:07 min
[INFO] Finished at: 2019-09-20T09:47:08+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.mobidevelop.robovm:robovm-maven-plugin:2.3.8-SNAPSHOT:install (default) on project ios-framework: Execution default of goal com.mobidevelop.robovm:robovm-maven-plugin:2.3.8-SNAPSHOT:install failed: Exception reference used other than as the first statement of an exception handler. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.mobidevelop.robovm:robovm-maven-plugin:2.3.8-SNAPSHOT:install (default) on project ios-framework: Execution default of goal com.mobidevelop.robovm:robovm-maven-plugin:2.3.8-SNAPSHOT:install failed: Exception reference used other than as the first statement of an exception handler.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default of goal com.mobidevelop.robovm:robovm-maven-plugin:2.3.8-SNAPSHOT:install failed: Exception reference used other than as the first statement of an exception handler.
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.lang.RuntimeException: Exception reference used other than as the first statement of an exception handler.
at soot.jimple.toolkits.typing.fast.AugEvalFunction.eval_ (AugEvalFunction.java:162)
at soot.jimple.toolkits.typing.fast.AugEvalFunction.eval (AugEvalFunction.java:41)
at soot.jimple.toolkits.typing.fast.TypeResolver.applyAssignmentConstraints (TypeResolver.java:409)
at soot.jimple.toolkits.typing.fast.TypeResolver.inferTypes (TypeResolver.java:113)
at soot.jimple.toolkits.typing.TypeAssigner.internalTransform (TypeAssigner.java:102)
at soot.BodyTransformer.transform (BodyTransformer.java:51)
at soot.Transform.apply (Transform.java:97)
at soot.JimpleBodyPack.applyPhaseOptions (JimpleBodyPack.java:66)
at soot.JimpleBodyPack.internalApply (JimpleBodyPack.java:92)
at soot.Pack.apply (Pack.java:117)
at soot.coffi.CoffiMethodSource.getBody (CoffiMethodSource.java:115)
at soot.SootMethod.getBodyFromMethodSource (SootMethod.java:87)
at soot.SootMethod.retrieveActiveBody (SootMethod.java:321)
at org.robovm.compiler.plugin.lambda.LambdaPlugin.transformMethod (LambdaPlugin.java:102)
at org.robovm.compiler.plugin.lambda.LambdaPlugin.beforeClass (LambdaPlugin.java:90)
at org.robovm.compiler.ClassCompiler.compile (ClassCompiler.java:795)
at org.robovm.compiler.ClassCompiler.compile (ClassCompiler.java:297)
at org.robovm.compiler.AppCompiler.compile (AppCompiler.java:353)
at org.robovm.compiler.AppCompiler.compile (AppCompiler.java:436)
at org.robovm.compiler.AppCompiler.compile (AppCompiler.java:500)
at org.robovm.compiler.AppCompiler.build (AppCompiler.java:962)
at org.robovm.maven.plugin.AbstractRoboVMBuildMojo.execute (AbstractRoboVMBuildMojo.java:66)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Edit: change code link to be a permalink. Edit: More exact jdk version.
hi, thank you for report. pay attention that ClosedWatchServiceException is fantom class and not a part RoboVM RT. that's what makes soot not happy. Beside bug in soot app itself will be crashing (with ClassNotFound) when trying to access this class
This class is part of the java SDK. https://docs.oracle.com/javase/8/docs/api/java/nio/file/ClosedWatchServiceException.html
What might we have done to make it shadowed?
Edit: the wheels are turning. Checking the installation on iOS.
This class is part of the java SDK. https://docs.oracle.com/javase/8/docs/api/java/nio/file/ClosedWatchServiceException.html
What might we have done to make it shadowed?
By design, RoboVM RT is Android 4.0 based (API 14) and does not include this class and many others. (Aside note: it seems to have been introduced to Android in API 26.)