Menu

clipsJNI become "instable" after an error

Help
2015-10-20
2015-10-26
  • Chaubert Jérôme

    HI,

    I work with clips JNI 0.5 (with latest bug fix) on windows 7. It seems that a clips Environnement could not be used after an error occurs. More precisely every user's clips function return FALSE. For example, the following java code :

            final Environment clips = new Environment();
    
            *... load constructs and initialisation...*
    
            System.out.println("february 2015 = " + clips.eval("(plus1mois 20150101)"));
            clips.eval("(this_function_does_not_exist)");
            System.out.println("2 + 2 = " + clips.eval("(+ 2 2)"));
            System.out.println("february 2015 = " + clips.eval("(plus1mois 20150101)"));
    

    give the following result :

    february 2015 = 20150201
    [EXPRNPSR3] Missing function declaration for this_function_does_not_exist.
    2 + 2 = 4
    february 2015 = FALSE

    Is it possible to change this ?

     

    Last edit: Chaubert Jérôme 2015-10-20
  • Gary Riley

    Gary Riley - 2015-10-20

    You'll need to recompile the jni library. In the file net_sf_clipsrules_jni_Environment.c, modify the Java_net_sf_clipsrules_jni_Environment_eval function to call SetEvaluationError and SetHaltExecution before the call to EnvEval:

       SetEvaluationError(theCLIPSEnv,FALSE);
       SetHaltExecution(theCLIPSEnv,FALSE);   
       EnvEval(theCLIPSEnv,(char *) cEvalStr,&theDO);
    

    If you're using the latest CLIPS source code rather than the code include with CLIPSJNI v0.5, use this code instead:

       EnvSetEvaluationError(theCLIPSEnv,FALSE);
       EnvSetHaltExecution(theCLIPSEnv,FALSE);   
       EnvEval(theCLIPSEnv,(char *) cEvalStr,&theDO);
    
     
  • Chaubert Jérôme

    Thank you,

    It works fine.

    Why did you choose to not call these evaluation and halt error functions ? For performance ?

     
  • Gary Riley

    Gary Riley - 2015-10-26

    It was an oversight.

     

Log in to post a comment.