Hello Rainer-

You're hitting a limitation in the current implementation.
Parameters can be passed as objects, but not as primitives.
If the signature was "Array.newInstance(Class, Integer)", all would be fine.
That's admittedly a somewhat severe limitation, and I'll look into
what's involved in removing it. It shouldn't be too hard.

In the mean time, you could use a wrapper method of your own which
performs the
type conversion, e.g.

package rainer;

public class Convert {
        static Object newInstance (Class componentType, Integer length) {
                return java.lang.reflect.Array(componentType, 
length.intValue());
        }
}

invoke('rainer.Convert', 'newInstance', ['String.class', 2], X1).

The fact that the method is static makes no difference.

As to registering the return objecy, all objects created using invoke/4
and bsf/6
are automatically registered with the BSF registry. That's also mentioned
as one
of the limitations in the HTML file.

Let me know how you make out, or if you have further questions (please
email me
directly, as this has little to do with BSF in general).
I'll keep you posted about enhancing JLog/BSF to deal with primitives.

Cheers,
Ulf

> Hello everybody,
>
> how do I create an Array and put it in the BSF-Registry in JLog?
> According to the documentation at
> http://www.ulfdittmer.com/jlog/index.html and the included example it
> should go like this:
>
> invoke('java.lang.reflect.Array', 'newInstance', ['String.class', 2], X1).
>
> Unfortunately BSF cancels the execution with following error message:
>
> No suitable method named newInstance with 2 parameters was found in class
> java.lang.reflect.Array...
>
>
> I guess the reason could be that newInstance is a static method.
> Another question that comes up is how can I register the return type -
> X1 in my example - as an object in the BSF registry for further use?
>
> Thanks in advance,
> -Rainer Hahnekamp



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to