[
http://jira.jboss.com/jira/browse/JBRULES-1001?page=comments#action_12369001 ]
Mark Proctor commented on JBRULES-1001:
---------------------------------------
Edson,
if we look at MiscTest.testImportFunctions we get the error. This is becuase it attempts
to create implicit bindings for the function names. so this line in
ClassFieldExtractorFacotry:
final Method getterMethod = (Method) inspector.getGetterMethods().get(
fieldName );
final String className = ClassFieldExtractorFactory.BASE_PACKAGE +
"/" + Type.getInternalName( clazz ) + "$" + getterMethod.getName();
Is trying to generate something for getString2. Which results in a nullpointer and is
printed here:
} catch ( final Exception e ) {
System.out.println( e );
NullPointerException when a function is used inside a predicate value
constraint
--------------------------------------------------------------------------------
Key: JBRULES-1001
URL:
http://jira.jboss.com/jira/browse/JBRULES-1001
Project: JBoss Rules
Issue Type: Bug
Security Level: Public(Everyone can see)
Affects Versions: 4.0.0.MR3
Reporter: Edgardo Carena
Assigned To: Edson Tirelli
Priority: Minor
Fix For: 4.0.0.MR4
if you change the FibonacciExample like this:
(...)
import java.lang.Math;
function boolean approxEqual(double val1, double val2) {
return (Math.abs(val1-val2)<0.01);
}
(....)
rule Calculate
when
f1 : Fibonacci( s1 : sequence, value != -1 )
f2 : Fibonacci( s2 : sequence -> (approxEqual(sequence,(s1 + 1))),
value != -1 )
f3 : Fibonacci( sequence == (s2 + 1 ), value == -1 )
then
f3.setValue( f1.getValue() + f2.getValue() );
update( f3 );
retract( f1 );
System.out.println( f3.getSequence() + " == " + f3.getValue()
);
end
thus introducing a function inside a predicate value constraint, the example works well,
however a NullPointerException is printed out during the call of the addPackageFromDrl
method.
I tried in many examples, also calling directly the java.lang.Math.abs function, and the
message is always printed with no apparent side effect.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira