Skip to content

GraalVM CE 1.0 RC6 breaks Flank fat jar #653

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

Closed
bootstraponline opened this issue Sep 3, 2018 · 8 comments
Closed

GraalVM CE 1.0 RC6 breaks Flank fat jar #653

bootstraponline opened this issue Sep 3, 2018 · 8 comments
Assignees

Comments

@bootstraponline
Copy link

GraalVM CE 1.0 RC6 breaks converting the Flank fat jar to a native executable.

$ git clone https://github.com/TestArmada/flank.git
$ cd test_runner
$ ./gradlew clean assemble fatJar
$ build/libs
$ native-image -jar flank-3.0-SNAPSHOT.jar
./flank-3.0-SNAPSHOT
Exception in thread "main" picocli.CommandLine$InitializationException: Cannot instantiate subcommand ftl.cli.FirebaseCommand: the class has no constructor
	at java.lang.Throwable.<init>(Throwable.java:287)
	at java.lang.Exception.<init>(Exception.java:84)
	at java.lang.RuntimeException.<init>(RuntimeException.java:80)
	at picocli.CommandLine$PicocliException.<init>(CommandLine.java:8801)
	at picocli.CommandLine$InitializationException.<init>(CommandLine.java:8808)
	at picocli.CommandLine$Model$CommandReflection.initSubcommands(CommandLine.java:4912)
	at picocli.CommandLine$Model$CommandReflection.updateCommandAttributes(CommandLine.java:4877)
	at picocli.CommandLine$Model$CommandReflection.extractCommandSpec(CommandLine.java:4858)
	at picocli.CommandLine$Model$CommandSpec.forAnnotatedObject(CommandLine.java:3144)
	at picocli.CommandLine.<init>(CommandLine.java:147)
	at picocli.CommandLine.<init>(CommandLine.java:126)
	at picocli.CommandLine.run(CommandLine.java:1700)
	at picocli.CommandLine.run(CommandLine.java:1647)
	at ftl.Main.main(Main.kt:34)
	at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:163)
Caused by: java.lang.NoSuchMethodException: ftl.cli.FirebaseCommand.<init>()
	at java.lang.Throwable.<init>(Throwable.java:265)
	at java.lang.Exception.<init>(Exception.java:66)
	at java.lang.ReflectiveOperationException.<init>(ReflectiveOperationException.java:56)
	at java.lang.NoSuchMethodException.<init>(NoSuchMethodException.java:51)
	at java.lang.Class.getConstructor0(Class.java:3082)
	at java.lang.Class.getDeclaredConstructor(Class.java:2178)
	at picocli.CommandLine$DefaultFactory.create(CommandLine.java:2832)
	at picocli.CommandLine$Model$CommandReflection.initSubcommands(CommandLine.java:4906)
	... 9 more
@cstancu
Copy link
Member

cstancu commented Sep 4, 2018

Did this work with rc5? From the error message it looks like you need to register ftl.cli.FirebaseCommand.<init>() for reflection access.

@bootstraponline
Copy link
Author

Interesting. I'll try to define a reflectconfig. RC5 didn't work either.

@bootstraponline
Copy link
Author

bootstraponline commented Sep 6, 2018

Image building is failing after I defined a reflection config JSON.

I opened a pull request so you can easily reproduce the problem:

@dougxc
Copy link
Member

dougxc commented Sep 6, 2018

@cstancu @christianwimmer this looks like the same thing I commented on in #656.

@cstancu
Copy link
Member

cstancu commented Feb 8, 2019

@bootstraponline the java.lang.NoClassDefFoundError that your reported after adding the correct reflection configuration was fixed in RC12. You will need to add this options to native-image: --report-unsupported-elements-at-runtime --allow-incomplete-classpath. Also you need to fix the graal_reflectionconfig.json by removing the ftl.cli.firebase.test.android.AndroidRefreshCommand and ftl.cli.firebase.test.ios.IosRefreshCommand entries as those classes don't exist anymore. I guess firebase removed them since you filed this issue.

However, I still cannot successfully build an image for your app. I hit the same problem reported in #783: Non-instantiated type referenced by a compiled method: kotlin.Result$Companion.

I am closing this issue. Please follow the progress of #783.

@cstancu cstancu closed this as completed Feb 8, 2019
@bootstraponline
Copy link
Author

Thank you for looking into this! I'm excited about using graalvm in the future.

@cstancu
Copy link
Member

cstancu commented Feb 12, 2019

#783 has been fixed. Now using this command:

native-image --report-unsupported-elements-at-runtime --allow-incomplete-classpath  -jar ./build/libs/flank-SNAPSHOT.jar -H:ReflectionConfigurationFiles=graal_reflectconfig.json -H:IncludeResources="kotlin/*.*" --enable-url-protocols=http

and this reflection configuration file:

[
  {
    "name" : "ftl.Main",
    "allDeclaredConstructors" : true,
    "allPublicConstructors" : true,
    "allDeclaredMethods" : true,
    "allPublicMethods" : true
  },
  {
    "name" : "ftl.args.yml.FlankYml",
    "allDeclaredConstructors" : true,
    "allPublicConstructors" : true,
    "allDeclaredMethods" : true,
    "allPublicMethods" : true
  },
  {
    "name" : "[Lftl.args.yml.FlankYmlParams;",
    "allDeclaredConstructors" : true,
    "allPublicConstructors" : true,
    "allDeclaredMethods" : true,
    "allPublicMethods" : true
  },
  {
    "name" : "ftl.args.yml.GcloudYml",
    "allDeclaredConstructors" : true,
    "allPublicConstructors" : true,
    "allDeclaredMethods" : true,
    "allPublicMethods" : true
  },
  {
    "name" : "[Lftl.args.yml.GcloudYmlParams;",
    "allDeclaredConstructors" : true,
    "allPublicConstructors" : true,
    "allDeclaredMethods" : true,
    "allPublicMethods" : true
  },
  {
    "name" : "ftl.cli.firebase.RefreshCommand",
    "allDeclaredConstructors" : true,
    "allPublicConstructors" : true,
    "allDeclaredMethods" : true,
    "allPublicMethods" : true
  },
  {
    "name" : "ftl.cli.firebase.CancelCommand",
    "allDeclaredConstructors" : true,
    "allPublicConstructors" : true,
    "allDeclaredMethods" : true,
    "allPublicMethods" : true
  },
  {
    "name" : "ftl.cli.AuthCommand",
    "allDeclaredConstructors" : true,
    "allPublicConstructors" : true,
    "allDeclaredMethods" : true,
    "allPublicMethods" : true
  },
  {
    "name" : "ftl.cli.auth.LoginCommand",
    "allDeclaredConstructors" : true,
    "allPublicConstructors" : true,
    "allDeclaredMethods" : true,
    "allPublicMethods" : true
  },

  {
    "name" : "ftl.cli.FirebaseCommand",
    "allDeclaredConstructors" : true,
    "allPublicConstructors" : true,
    "allDeclaredMethods" : true,
    "allPublicMethods" : true
  },
  {
    "name" : "ftl.cli.firebase.TestCommand",
    "allDeclaredConstructors" : true,
    "allPublicConstructors" : true,
    "allDeclaredMethods" : true,
    "allPublicMethods" : true
  },
  {
    "name" : "ftl.cli.firebase.test.IosCommand",
    "allDeclaredConstructors" : true,
    "allPublicConstructors" : true,
    "allDeclaredMethods" : true,
    "allPublicMethods" : true
  },
  {
    "name" : "ftl.cli.firebase.test.AndroidCommand",
    "allDeclaredConstructors" : true,
    "allPublicConstructors" : true,
    "allDeclaredMethods" : true,
    "allPublicMethods" : true
  },
  {
    "name" : "ftl.cli.firebase.test.android.AndroidDoctorCommand",
    "allDeclaredConstructors" : true,
    "allPublicConstructors" : true,
    "allDeclaredMethods" : true,
    "allPublicMethods" : true
  },
  {
    "name" : "ftl.cli.firebase.test.android.AndroidRunCommand",
    "allDeclaredConstructors" : true,
    "allPublicConstructors" : true,
    "allDeclaredMethods" : true,
    "allPublicMethods" : true
  },
  {
    "name" : "ftl.cli.firebase.test.ios.IosDoctorCommand",
    "allDeclaredConstructors" : true,
    "allPublicConstructors" : true,
    "allDeclaredMethods" : true,
    "allPublicMethods" : true
  },
  {
    "name" : "ftl.cli.firebase.test.ios.IosRunCommand",
    "allDeclaredConstructors" : true,
    "allPublicConstructors" : true,
    "allDeclaredMethods" : true,
    "allPublicMethods" : true
  }
]

I can build an executable which when run does something:

$ ./flank-SNAPSHOT firebase test android run
The project is not set. Define GOOGLE_CLOUD_PROJECT, set project in flank.yml
or save service account credential to /home/cdrtz/.config/gcloud/application_default_credentials.json
 See https://github.com/GoogleCloudPlatform/google-cloud-java#specifying-a-project-id

I am not familiar with the internals of your project so I stopped there. I just wanted to see how far I can get it.

@bootstraponline
Copy link
Author

I am not familiar with the internals of your project so I stopped there. I just wanted to see how far I can get it.

Thanks. I made a simple reproducible example that doesn't require authentication with a service account.

It's awesome to see GraalVM making progress. 🙂

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

No branches or pull requests

3 participants