[rules-users] rule parse error for null check
Wolfgang Laun
wolfgang.laun at gmail.com
Sun Aug 28 14:03:05 EDT 2011
See JBRULES-3064 <https://issues.jboss.org/browse/JBRULES-3064>, dialect
"mvel" flouts generic parameters.
If you omit "<String,Integer>" after "new HashMap" all is well. Of course,
this is another MVEL bug or restriction - who knows.
But don't try to work around this by
then
if($u.subjectGradeMap == null){
$u.subjectGradeMap = new HashMap*/*<String,Integer>*/*();
}
You'll just run into another MVEL bug.
-W
2011/8/28 Neel <neeleshdev at yahoo.co.in>
> Hi,
> I'm using drools-5.3.0.Beta1. I've following rule file:
>
> import java.util.*;
>
>
> declare Student
>
> name : String @key
>
> subjectGradeMap : HashMap
>
> end
>
>
>
> rule "Subject grade points"
>
> dialect "mvel"
>
> when
>
> $u : Student()
>
> then
>
> if($u.subjectGradeMap == null)
>
> {
>
> $u.subjectGradeMap = new HashMap<String,Integer>();
>
> }
>
> $u.subjectGradeMap["CompSc"] += 100;
>
> System.out.println("Marks added");
>
> end
>
>
> I get following error while rule compilation:
>
> Unable to Analyse Expression if($u.subjectGradeMap == null);
>
> {
>
> $u.subjectGradeMap = new HashMap<String,Integer>();
>
> };
>
> $u.subjectGradeMap["CompSc"] += 100;
>
> System.out.println("Marks added");:
>
> [Error: was expecting type: java.lang.Object; but found type: <Unknown>]
>
> [Near : {... if($u.subjectGradeMap == null) ....}]
>
> ^
>
> [Line: 1, Column: 1] : [Rule name='Subject grade points']
>
>
> Please let me know if this is correct usage in the above scenario.
>
>
> Thanks,
>
> Neel
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110828/11020c9b/attachment.html
More information about the rules-users
mailing list