Fix aesh-processor for inner classes and custom CommandInvocation types#373
Merged
stalep merged 3 commits intoaeshell:masterfrom Mar 23, 2026
Conversation
…Invocation types Two bugs in the annotation processor: 1. Inner class commands (e.g., Config.Set) used qualifiedName string splitting to derive the package, producing invalid package names like "org.example.Config". Now uses elementUtils.getPackageOf() and flattens inner class names with underscore (Config_Set_AeshMetadata). 2. Generated code used typed ProcessedCommandBuilder.builder() which fails when commands use custom CommandInvocation subtypes. Now casts to raw ProcessedCommandBuilder since @SuppressWarnings is already present.
…M native image Add BiConsumer fieldSetter and Consumer fieldResetter to ProcessedOption, allowing the annotation processor to generate direct field access lambdas instead of relying on reflection. This enables aesh commands to work in GraalVM native images without reflection metadata for field population. - ProcessedOption: add fieldSetter/fieldResetter, injectValueWithSetter(), resetField() methods - ProcessedOptionBuilder: add fieldSetter/fieldResetter builder methods - AeshCommandPopulator: delegate resetField to ProcessedOption - CodeGenerator: generate fieldSetter/fieldResetter lambdas for non-private fields, skip private fields (fall back to reflection)
…ption() copy ProcessedCommand.addOption() and setOptions() create a copy of the ProcessedOption but didn't carry over fieldSetter/fieldResetter, causing the annotation processor's generated field accessors to be silently discarded. Also adds comprehensive tests for field setter population.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CommandInvocationsubtypesProcessedCommand.addOption()copyFixes #372
Details
Inner class fix: Uses
elementUtils.getPackageOf()instead of string splitting onqualifiedName. Inner class metadata classes use flattened names (e.g.,Config_Set_AeshMetadata).Raw type fix: Casts
ProcessedCommandBuilder.builder()to rawProcessedCommandBuilderso.command(instance)works regardless of theCommandInvocationtype parameter.Reflection-free field population: Adds
BiConsumer<Object, Object> fieldSetterandConsumer<Object> fieldResettertoProcessedOption, allowing the annotation processor to generate direct field access lambdas instead of relying on reflection. This enables aesh commands to work in GraalVM native images without reflection metadata for field population. Private fields fall back to reflection.addOption copy fix:
ProcessedCommand.addOption()andsetOptions()create copies ofProcessedOptionbut were not carrying overfieldSetter/fieldResetter, silently discarding the generated field accessors.Test plan
FieldSetterPopulatorTestandMetadataProviderFieldSetterTest--versionand interactive mode work correctly