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

Exclusive argument groups disappear when using native-image #793

Closed
mikehearn opened this issue Aug 23, 2019 · 8 comments
Closed

Exclusive argument groups disappear when using native-image #793

mikehearn opened this issue Aug 23, 2019 · 8 comments
Milestone

Comments

@mikehearn
Copy link

I have the following code:

    static class Mode {
        @CommandLine.Option(names = {"-e", "--encrypt"}, required = true) boolean encrypt;
        @CommandLine.Option(names = {"-d", "--decrypt"}, required = true) boolean decrypt;
    }

    @CommandLine.ArgGroup(exclusive = true, multiplicity = "1")
    Mode mode;

This works as expected on HotSpot. When using the annotation processor and native-imaeg, the -e and -d options vanish from the help output and trying to access mode throws an NPE. It's like PicoCLI just forgets all about the mode parameter entirely, but the other params are still there!

I checked the generated JSON files and they look reasonable. Mode and the options are there. Seems something goes wrong at runtime.

@remkop
Copy link
Owner

remkop commented Aug 23, 2019

Thanks for raising this!
Can you share the results of running the native image with -Dpicocli.trace=DEBUG?

@remkop
Copy link
Owner

remkop commented Aug 24, 2019

I've been able to reproduce the problem.
I believe the generated reflection-info JSON is missing the group field, still investigating.

@remkop remkop added this to the 4.0.3 milestone Aug 24, 2019
remkop added a commit that referenced this issue Aug 24, 2019
…e generated `reflect-config.json` was missing the `@ArgGroup`-annotated fields)
@remkop
Copy link
Owner

remkop commented Aug 24, 2019

The problem was that the generated reflect-config.json was missing the @ArgGroup-annotated fields.

I've pushed a fix to master, and will do a release for this soon.

remkop added a commit that referenced this issue Aug 24, 2019
remkop added a commit that referenced this issue Aug 24, 2019
@mikehearn
Copy link
Author

Thanks! Amazingly fast work!

@remkop
Copy link
Owner

remkop commented Aug 26, 2019

Picocli 4.0.3 which includes a fix for this issue has been released and should be available from Maven Central in a few hours.

Thanks again for the bug report!

@remkop
Copy link
Owner

remkop commented Aug 28, 2019

@mikehearn It would be great if you could confirm that picocli 4.0.3 fixes the issue.

@mikehearn
Copy link
Author

It works! Thanks again.

@remkop
Copy link
Owner

remkop commented Aug 28, 2019

Excellent!
Please star picocli on GitHub if you like the project and tell your friends!

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

2 participants