On Feb 14, 2008, at 4:13 PM, Marco Zappatore wrote:
Whenever I declare a Java function with a constructor method,
the command (load-function ...) gives me an error
("class cannot be instantiated") and, as a consequence,
the name set by the getName() method cannot be used in Jess.
The load-function function uses code like this to load your function
class and create an instance of it:
Class.forName(theClassName).newInstance();
If you think about it, Jess would have no idea what arguments your
constructor wanted, so Jess can't call it. Therefore a Userfunction
MUST have a no-argument constructor, or no constructor at all, to be
loaded by load-function.
That doesn't mean that your Userfunction class can't have the
constructor you want though; you just can't use load-function. You
could load it from Java using, for example
Rete engine = ...
engine.addUserfunction(new MyFunctionClass(arg1, arg2));
or from Jess, by calling these same Java methods:
((engine) addUserfunction (new MyFunctionClass arg1 arg2))
---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://www.jessrules.com
--------------------------------------------------------------------
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]
--------------------------------------------------------------------