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

ManPageGenerator as subcommand with native-image throws exception #1151

Closed
sebhoss opened this issue Aug 23, 2020 · 6 comments
Closed

ManPageGenerator as subcommand with native-image throws exception #1151

sebhoss opened this issue Aug 23, 2020 · 6 comments
Labels
theme: annotation-proc An issue or change related to the annotation processor theme: codegen An issue or change related to the picocli-codegen module type: bug 🐛
Milestone

Comments

@sebhoss
Copy link

sebhoss commented Aug 23, 2020

Heyho,

using ManPageGenerator as a subcommand fails when I compile the application as a native image with the following stack trace. Running it as a Java app works fine though.

Exception in thread "main" picocli.CommandLine$InitializationException: picocli.codegen.docgen.manpage.ManPageGenerator$Config@6408c574 is not a command: it has no @Command, @Option, @Parameters or @Unmatched annotations
        at picocli.CommandLine$Model$CommandReflection.validateCommandSpec(CommandLine.java:10905)
        at picocli.CommandLine$Model$CommandReflection.extractCommandSpec(CommandLine.java:10741)
        at picocli.CommandLine$Model$CommandSpec.forAnnotatedObject(CommandLine.java:5863)
        at picocli.CommandLine$Model$CommandReflection.buildMixinForMember(CommandLine.java:10936)
        at picocli.CommandLine$Model$CommandReflection.initFromAnnotatedTypedMembers(CommandLine.java:10821)
        at picocli.CommandLine$Model$CommandReflection.initFromAnnotatedFields(CommandLine.java:10800)
        at picocli.CommandLine$Model$CommandReflection.extractCommandSpec(CommandLine.java:10731)
        at picocli.CommandLine$Model$CommandSpec.forAnnotatedObject(CommandLine.java:5863)
        at picocli.CommandLine.<init>(CommandLine.java:223)
        at picocli.CommandLine.toCommandLine(CommandLine.java:3496)
        at picocli.CommandLine.access$14300(CommandLine.java:145)
        at picocli.CommandLine$Model$CommandReflection.initSubcommands(CommandLine.java:10765)
        at picocli.CommandLine$Model$CommandReflection.extractCommandSpec(CommandLine.java:10727)
        at picocli.CommandLine$Model$CommandSpec.forAnnotatedObject(CommandLine.java:5863)
        at picocli.CommandLine.<init>(CommandLine.java:223)
        at picocli.CommandLine.<init>(CommandLine.java:196)

This is using the latest Graal 20.2 with pico 4.5.0 on Java 11.

@remkop
Copy link
Owner

remkop commented Aug 23, 2020

Ouch! Thanks for letting me know. Investigating...

@remkop remkop added type: bug 🐛 theme: annotation-proc An issue or change related to the annotation processor theme: codegen An issue or change related to the picocli-codegen module labels Aug 23, 2020
@remkop
Copy link
Owner

remkop commented Aug 23, 2020

@sebhoss Update: I was able to reproduce the issue and create a failing test for it.

The problem (based on my analysis so far) is that the reflect-config.json file generated by the picocli-codegen annotation processor is incomplete and does not contain the names of the @Option-annotated fields of the ManPageGenerator$Config class. This results in the native image failing when the ManPageGenerator subcommand is invoked, with the exception you reported.

In my test, I found that the picocli-codegen annotation processor only receives the class of the parent command, and not the ManPageGenerator subcommand. I guess this is since the ManPageGenerator subcommand has already been compiled to a .class file. The annotation processor is not ready for this scenario.

I have a few ideas about how to solve this, but this will take me some time.
I will let you know when I make more progress on this.

@remkop remkop added this to the 4.6 milestone Aug 23, 2020
@sebhoss
Copy link
Author

sebhoss commented Aug 23, 2020

That's a very cool test!

I could actually live without the command, so take all the time you need. If there is anything I can do to help/investigate/test, let me know - happy to help.

@remkop
Copy link
Owner

remkop commented Aug 25, 2020

I pushed a fix for this to master.
I will do a 4.5.1 bugfix release soon (in the next day or so).

@remkop
Copy link
Owner

remkop commented Aug 26, 2020

@sebhoss Picocli 4.5.1 has been released, with a fix for this issue.

Don't forget to star ⭐ picocli on GitHub if you like the project! 😉

@sebhoss
Copy link
Author

sebhoss commented Aug 26, 2020

Nice, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: annotation-proc An issue or change related to the annotation processor theme: codegen An issue or change related to the picocli-codegen module type: bug 🐛
Projects
None yet
Development

No branches or pull requests

2 participants