Can't really say about this exact case but I use the varArg form from Java and that works fine
public void getById( @Parameter(names={"-t", "--tenant"}, absentValue="") @Descriptor(TENANT_DESCR + REQ) String tenantName, @Parameter(names="-ps", absentValue= "") @Descriptor(PS_DESCR) String psName, @Descriptor(IDS_DESCR) String... elementsId) { } Alain On Thu, Feb 2, 2023 at 5:12 AM Dmitry Savenko <dsave...@xored.com> wrote: > Hi, > > Is there a way to use arrays as @Parameters in GoGo? Consider this command: > > @Descriptor("print array") > public void print_array(@Parameter(names = { "--arr" }, absentValue = > "[5]") int[] arr, String header) > { > System.out.println(header); > if (null != arr) > { > for (int i = 0; i < arr.length; ++i) > { > System.out.println(arr[i]); > } > } > } > > If I call it without --arr ("print_array a"), I get > java.lang.IllegalArgumentException: Cannot coerce print_array(Token) to any > of [(int[], String)] > at org.apache.felix.gogo.runtime.Reflective.invoke(Reflective.java:204) > at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:91) > > If I try to specify --arr ("print_array --arr [1 2] a"), I get > java.lang.ClassCastException: class [I cannot be cast to class > [Ljava.lang.Object; ([I is in module java.base of loader 'bootstrap') > at org.apache.felix.gogo.runtime.Reflective.coerce(Reflective.java:448) > at org.apache.felix.gogo.runtime.Reflective.docoerce(Reflective.java:367) > at org.apache.felix.gogo.runtime.Reflective.coerce(Reflective.java:306) > at org.apache.felix.gogo.runtime.Reflective.invoke(Reflective.java:116) > at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:91) > > Best regards, > Dmitry. >