I think Medvedeva, Olga wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
>
> Hi,
> This is probable an easy question. How to pass a multislot value to Java
> side? I need to get this value as a List.
>
> class Foo {
> public static void presentMessage(Object msgs){
> //debug
> System.out.println("Got frem Jess : "+msgs);
> }
>
> Everything works if I pass a slot value form Jess
> (call Foo presentMessage ?bar),
> but for a multislot value
> (call Foo presentMessage $?bar) I'm getting a JessException from
> ReflectFunctions ""No overloading of method 'presentMessage' ..."
>
This question has a simple answer, but it's not an easy question -- I
had to think about it for a bit.
When Jess calls a Java function with a multifield as an argument, it
always tries to convert the multifield into an array. If the function
doesn't take an array argument, this fails (yes, I realize that an
array is a Object -- but this is an edge case.) You want Java to end
up with an Object that is a reference to some representation of the
original multifield's contents. Without changing the signature of your
Java function, the only way to do this is to call some other function
to accept the array and possibly convert it to some other kind of
container.
Here's one way to do it:
(call Foo presentMessage (call java.util.Arrays asList $?bar))
asList takes an Object[] as an argument and returns a List. That List
will then be passed to presentMessage.
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
Org. 8920, MS 9012 [EMAIL PROTECTED]
PO Box 969 http://herzberg.ca.sandia.gov
Livermore, CA 94550
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------