Hi Alex, I found a solution indeed to improve type checking for Java function calls. Your code should now work with the latest snapshot [1].
There is a minor overhead when calling Java functions if the type is not statically known, but as long as your arrays don’t have millions of entries, you shouldn’t really notice the difference. I mostly revised the type checking process to reduce memory (e.g., a large byte array will be much smaller if passed on as byte[] instead of Object[]), so it is likely that most invocations will even be faster than before. The dynamic item type detection currently works for primitive types (double, float, boolean, int, short, byte) and Strings. Cheers, Christian [1] http://files.basex.org/releases/latest/ On Fri, Jun 29, 2018 at 12:37 PM Alexander Shpack <[email protected]> wrote: > Thanks! > > On Fri, Jun 29, 2018 at 1:34 PM Christian Grün <[email protected]> > wrote: > >> I see! As XQuery sequences may contain items of arbitrary type, it is >> not always possible to decide at compile time which Java function >> needs to be chosen for evaluation. I recommend you to stick with the >> "Object..." declaration. >> >> Nevertheless, I will check if we can optimize the static function >> selection without compromising performance. >> >> Best, >> Christian >> >> >> >> On Fri, Jun 29, 2018 at 12:30 PM Alexander Shpack <[email protected]> >> wrote: >> > >> > Hi Christian, >> > >> > Right now we are using the next code >> > >> > public static String exec(String key) { >> > return ... >> > } >> > >> > public static String exec(Object... keys) { >> > return ... >> > } >> > >> > The code that doesn't work: >> > >> > public static String exec(String... keys) >> > >> > >> > >> > On Fri, Jun 29, 2018 at 10:51 AM Christian Grün < >> [email protected]> wrote: >> >> >> >> Hi Alex, >> >> >> >> How does the signature of the invoked Java function look like? >> >> >> >> Best, >> >> Christian >> >> >> >> >> >> >> >> On Mon, Jun 18, 2018 at 9:43 PM Alexander Shpack <[email protected]> >> wrote: >> >> > >> >> > Hey, team! >> >> > >> >> > Just simple question. How to pass sequence of string to the java >> class? >> >> > >> >> > let $values := for $i in (1 to 3) return $i cast to xs:string >> >> > return j:exec($values) >> >> > >> >> > In case when local function returns one item all is good. Otherwise >> j:exec takes array of item()+, but not the array of stings. >> >> > >> >> > If you just call j:exec(("1","2")) than all works as expected. >> >> > >> >> > Any thoughts? Is it bug or feature? ;) >> >> > >> >> > BaseX 9.0 >> >> > >> >> > Thanks! >> >> > >> >> > >> >> > -- >> >> > s0rr0w >> > >> > >> > >> > -- >> > s0rr0w >> > > > -- > s0rr0w >

