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

Generated GraalVM reflection configuration can exclude Jansi Console #645

Closed
shanetreacy opened this issue Mar 14, 2019 · 4 comments
Closed
Labels
theme: codegen An issue or change related to the picocli-codegen module
Milestone

Comments

@shanetreacy
Copy link

shanetreacy commented Mar 14, 2019

When generating the reflection configuration by running the generateGraalReflectionConfig gradle task, the AnsiConsole class is picked up and included in the output.

  {
    "name" : "org.fusesource.jansi.AnsiConsole",
    "allDeclaredConstructors" : true,
    "allPublicConstructors" : true,
    "allDeclaredMethods" : true,
    "allPublicMethods" : true,
    "fields" : [
      { "name" : "out" }
    ]
  }

Giving this error when attempting to generate a nativeImage

error: Error parsing reflection configuration in blah/build/cli-reflect.json:
Class org.fusesource.jansi.AnsiConsole not found
Verify that the configuration matches the schema described in the -H:PrintFlags=+ output for option ReflectionConfigurationFiles.
Error: Image building with exit status 1

Manually removing the AnsiConsole block from the reflection configuration allows native image to build successfully.

Similar to issue #630

@shanetreacy shanetreacy changed the title The Jansi Console Issue also affects GraalVM reflection configuration generation The Jansi Console Issue also affects GraalVM reflection configuration generation (building with gradle) Mar 14, 2019
@remkop
Copy link
Owner

remkop commented Mar 15, 2019

The error occurs because the jansi jar is missing from the classpath. Adding it to the classpath when generating the GraalVM native image is another way to resolve this error.

I understand that this is not strictly necessary because GraalVM does not yet support native images for Windows, so it is probably okay to exclude the org.fusesource.jansi.AnsiConsole class from the generated reflect.json file. (It'll be interesting to see what happens when running the resulting native image when system property "os.name" is set to "Windows", and GraalVM does reflection on an unknown class.)

Do you think you will be able to provide a pull request for this?

@remkop remkop changed the title The Jansi Console Issue also affects GraalVM reflection configuration generation (building with gradle) Generated GraalVM reflection configuration can exclude Jansi Console Mar 15, 2019
@remkop remkop added the theme: codegen An issue or change related to the picocli-codegen module label Mar 15, 2019
@remkop remkop modified the milestones: 4.0-alpha-2, 4.0-alpha-3 Apr 17, 2019
@remkop remkop closed this as completed in 58a42a7 May 8, 2019
@remkop
Copy link
Owner

remkop commented May 8, 2019

Pushed to master.
This will be included in 4.0.0-alpha-3 and later.

@remkop
Copy link
Owner

remkop commented May 12, 2019

Reopening since Graal GA was released in the last few days with native-image capabilities for Windows.
This means that it makes sense to include Jansi again in some cases.

I will add a command line flag for the gen-reflect-config tool to optionally include configuration for the org.fusesource.jansi.AnsiConsole class. This flag will be false by default, so users need to explicitly request it to be included. I will update the documentation accordingly.

@remkop remkop reopened this May 12, 2019
@remkop
Copy link
Owner

remkop commented May 12, 2019

Actually, I found a better way to do this.

picocli can now detect whether Jansi was installed without reflecting on any Jansi classes.
This has two advantages:

@remkop remkop closed this as completed May 12, 2019
remkop added a commit that referenced this issue May 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: codegen An issue or change related to the picocli-codegen module
Projects
None yet
Development

No branches or pull requests

2 participants