[jboss-jira] [JBoss JIRA] Created: (JBRULES-1388) Eval error when using multiple declarations
Hao Chen (JIRA)
jira-events at lists.jboss.org
Wed Dec 12 14:40:51 EST 2007
Eval error when using multiple declarations
-------------------------------------------
Key: JBRULES-1388
URL: http://jira.jboss.com/jira/browse/JBRULES-1388
Project: JBoss Drools
Issue Type: Bug
Security Level: Public (Everyone can see)
Affects Versions: 4.0.3
Reporter: Hao Chen
Just started testing Drools 4.0.3, and found rules like the following will cause ClassCastException when invoked
when
t1 : T1()
t2 : T2()
eval(t2.f1>0)
then
...
end
Looked into the source code and found that: in JavaEvalBuilder.java
final Declaration[] declarations = new Declaration[usedIdentifiers[0].size()];
for ( int i = 0, size = usedIdentifiers[0].size(); i < size; i++ ) {
declarations[i] = context.getDeclarationResolver().getDeclaration( (String) usedIdentifiers[0].get( i ) );
}
This only retrieves the declarations used in the eval, which in the example include only t2. So the Drools generated code for the eval is like:
...
T2 t2 = (T2) declarations[0].getValue( (org.drools.common.InternalWorkingMemory) workingMemory, ( (org.drools.common.InternalFactHandle) tuple.get( declarations[0] ) ).getObject() );
...
which cause ClassCastException at runtime because the declarations[0] passed in is actually t1.
--
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
More information about the jboss-jira
mailing list