-
Notifications
You must be signed in to change notification settings - Fork 69
Description
Description
The aesh-processor annotation processor has two bugs that prevent it from working correctly with real-world projects:
1. Inner class package name collision
For command classes defined as inner classes (e.g., org.example.Config.Set), the processor uses qualifiedName.lastIndexOf('.') to split package from class name. This produces package org.example.Config; — where Config is actually a class, not a package. This causes compilation errors for all inner command classes.
Fix: Use elementUtils.getPackageOf(commandElement) to get the real package, and flatten the inner class name with _ for the metadata class (e.g., Config_Set_AeshMetadata).
2. Generic type mismatch with custom CommandInvocation
The generated code calls ProcessedCommandBuilder.builder() which infers ProcessedCommandBuilder<Command<CommandInvocation>, CommandInvocation>. When a command implements Command<MyCustomInvocation>, the .command(instance) call fails with a type mismatch.
Fix: Cast to raw ProcessedCommandBuilder since the class already has @SuppressWarnings({"unchecked", "rawtypes"}).
Reproduction
Any project using @CommandDefinition on inner classes (very common with @GroupCommandDefinition patterns) or using a custom CommandInvocation subtype will fail to compile with the annotation processor.
Impact
Tested against the Infinispan CLI module (~166 command classes, 101 of which are inner classes). Without the fix: 308 compilation errors. With the fix: clean compilation and all tests pass.