On Thu, Jan 14, 2010 at 2:08 PM, Gerhard Muenz <[email protected]> wrote:
> public double[] evaluateModel(Classifier classifier,
> Instances data,
> java.lang.Object... forPredictionsPrinting)
> throws java.lang.Exception
>
>
> Calling
>> java_invoke(o, "evaluateModel", c, d)
> I get this error:
> error: [java] java.lang.NoSuchMethodException: evaluateModel
>
> So, I need to provide the optional parameter "forPredictionsPrinting".
> If provided, forPredictionsPrinting needs to be a StringBuffer object, a
> weka.core.Range object, and a boolean:
That's the way variable arguments are represented internally in JVM,
as an additional array argument. There's no specific support to detect
whether the last argument is actually a varargs array.
> sf = java_new('java.lang.StringBuffer');
> range = java_new('weka.core.Range','first-last');
> jtrue = java_new('java.lang.Boolean', true);
I don't think that jtrue is actually an octave_java object.
> The only solution I've found was to remove lines 762 to 770 in
> __java__.cc:
>
> if (retval.is_undefined ())
> {
> cls = jni_env->FindClass ("java/lang/Boolean");
> if (jni_env->IsInstanceOf (jobj, cls))
> {
> jmethodID m = jni_env->GetMethodID (cls, "booleanValue",
> "()Z");
> retval = jni_env->CallBooleanMethod (jobj, m);
Could you try the following instead:
retval = (jni_env->CallBooleanMethod (jobj, m) ? true : false);
You'll also need to modify the unbox function with the following code
(put if before the test is_real_scalar()):
else if (val.is_bool_scalar ())
{
bool bval = val.bool_value ();
jclass_ref bcls (jni_env, jni_env->FindClass ("java/lang/Boolean"));
jfieldID fid = jni_env->GetStaticFieldID (bcls, "TYPE",
"Ljava/lang/Class;");
jmethodID mid = jni_env->GetMethodID (bcls, "<init>", "(Z)V");
jcls = reinterpret_cast<jclass> (jni_env->GetStaticObjectField
(bcls, fid));
jobj = jni_env->NewObject (bcls, mid, bval);
}
This is untested, you might need some adaptation.
Let me know if it works.
Michael.
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Octave-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/octave-dev