Hello Rainer and all- I looked into this some more, and it turns out the problem lies elsewhere, not where I suggested. Firstly, when using invoke('java.lang.reflect.Array', 'newInstance', ['String.class', 2], X1). the 'String.class' parameter would be considered a string, not the object it would be in Java. The following snippet shows how to create a String.class object in JLogBSF: create('strcl', 'String', []), invoke('strcl', 'getClass', [], STRCL), invoke('java.lang.reflect.Array', 'newInstance', [STRCL, 2], X1).
Secondly, there was a problem with the way Arrays with null elements are handled (like the one that's returned by the above call). This has been fixed, and I will upload the new version on Monday. Let me know if you have any questions. Cheers, Ulf ---------------------------- Original Message ---------------------------- Subject: Re: JLog issue From: "Ulf Dittmer" <[EMAIL PROTECTED]> Date: Sun, January 23, 2005 4:30 pm To: "Bean Scripting Framework users" <bsf-user@jakarta.apache.org> Cc: [EMAIL PROTECTED] -------------------------------------------------------------------------- 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]