Skip to content

Reduce reflect-config.json #698

@remkop

Description

@remkop

Currently the reflect-config.json file generated by ReflectionConfigGenerator contains some unnecessary entries.

Specifically, entries for classes used internally by picocli: picocli uses reflection to allow the library to be used from Java 5 and higher while still using features available in later versions of Java. One example is type converters for classes in the java.time.* package, another example is java.io.Console.readPassword().

According to the Graal SubstrateVM docs on reflection, SubstrateVM does static analysis that detects calls to the reflection API.

The analysis intercepts calls to Class.forName(String), Class.forName(String, ClassLoader), Class.getDeclaredField(String), Class.getField(String), Class.getDeclaredMethod(String, Class[]), Class.getMethod(String, Class[]), Class.getDeclaredConstructor(Class[]) and Class.getConstructor(Class[]). If the arguments to these calls can be reduced to a constant we try to resolve the target elements. If the target elements can be resolved the calls are removed and instead the target elements are embedded in the code.

It should be possible to generate a reduced reflect-config.json that does not include entries for the above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    theme: codegenAn issue or change related to the picocli-codegen module

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions