Trying to use eval in a query for backward chaining causes a runtime
crash running Drools 5.5.0. Looks like a bug. The details:
Given some Integer objects as facts,
rule "find triple forward"
when
Integer( $a: intValue )
Integer( $b: intValue > $a )
Integer( $c: intValue > $b )
eval( $a*$a + $b*$b == $c*$c )
then
System.out.println( "fwd: " + $a + " " + $b + " " + $c
);
end
finds Pythagorean triples.
But
query isTriple( Integer $a, Integer $b, Integer $c )
Integer( intValue == $a )
Integer( intValue == $b && > $a )
Integer( intValue == $c && > $b )
eval( $a*$a + $b*$b == $c*$c )
end
intended to be used in combination with
rule "find triple backward"
when
isTriple( $a, $b, $c; )
then
System.out.println( "bwd: " + $a + " " + $b + " " + $c
);
end
causes a nasty runtime error (although DRL compilation succeeds):
Exception in thread "main" java.lang.NoSuchMethodError:
pythagoras.Rule_isTriple_17ac16f7237046ee9562afce35dfe174.eval0(III)Z
at
pythagoras.Rule_isTriple_17ac16f7237046ee9562afce35dfe174Eval0InvokerGenerated.evaluate(Unknown
Source)
at
pythagoras.Rule_isTriple_17ac16f7237046ee9562afce35dfe174Eval0Invoker.evaluate(Unknown
Source)
at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:114)
at org.drools.reteoo.EvalConditionNode.assertLeftTuple(EvalConditionNode.java:176)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:196)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:71)
at org.drools.reteoo.JoinNode.propagateFromRight(JoinNode.java:159)
at org.drools.reteoo.JoinNode.assertObject(JoinNode.java:148)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:350)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:311)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:903)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:847)
at
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:269)
at pythagoras.Main.makeFacts(Main.java:94)
at pythagoras.Main.execute(Main.java:78)
at pythagoras.Main.main(Main.java:103)
-W