-
Notifications
You must be signed in to change notification settings - Fork 418
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
StackOverflowError when subcommand is subclass #787
Comments
…` when subcommand is subclass of itself
I believe this is simply a consequence of how reuse works in picocli: I improved things by throwing a more friendly Example 1: @Command(name = "self-ref", subcommands = Simplest.class)
class Simplest {} This gives the following InitializationException: "self-ref (Simplest) cannot be a subcommand of itself" Example 2: @Command(name = "parent", subcommands = Sub.class)
class Parent { }
@Command(name = "sub")
class Sub extends Parent {} This gives the following InitializationException: "parent (Parent) has a subcommand (Sub) that is a subclass of itself". To avoid this, add another level that does not have subclasses, and put the shared functionality there: //@Command // optionally define some shared command annotation attributes
class SharedFunctionality {}
@Command(name = "parent", subcommands = Sub.class)
class Parent extends SharedFunctionality { }
@Command(name = "sub")
class Sub extends SharedFunctionality {} |
As reported by @petermr on the picocli mailing list, when a subcommand subclasses its parent command, a
StackOverflowError
is thrown during initialization.To reproduce:
Example stack trace (differs per invocation):
The text was updated successfully, but these errors were encountered: