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.

Reply via email to