<br>&nbsp;&nbsp; Yes, drools is deferring the type verification until it is needed (in your example, to check the constraint). May I ask you please to open a JIRA... I will fix that.<br><br>&nbsp; []s<br>&nbsp; Edson<br><br><div><span class="gmail_quote">
2007/9/27, Chris Woodrow &lt;<a href="mailto:woodrow.chris@gmail.com">woodrow.chris@gmail.com</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I am sorry I didn&#39;t mean &#39;for&#39; but &#39;from&#39;.<br>:D<br><br><div><span class="gmail_quote">2007/9/27, Chris Woodrow &lt;<a href="mailto:woodrow.chris@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
woodrow.chris@gmail.com</a>&gt;:</span><div><span class="e" id="q_115472efc9b3d8ad_1"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>I recently find out a few issues using for, and I wanted to share it with you. I made a simple exemple to illustrate my purpose.<br><br>My classes are (I did not represent accessors &amp; constructors):<br><br><div style="margin-left: 40px;">


public class Cheese {<br>&nbsp;&nbsp;&nbsp;&nbsp;protected String name;<br>}<br><br>public class FrenchCheese extends Cheese{<br>&nbsp;&nbsp;&nbsp;&nbsp;private String smell;<br>}<br><br>public class Person {<br>&nbsp;&nbsp;&nbsp;&nbsp;private Cheese likes;<br>}<br></div><br>Here is my rule set :
<br><br><div style="margin-left: 40px;">package rules<br><br>rule &quot;likes cheese&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;when<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$person : Person ()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cheese(&nbsp;&nbsp;) from $person.getLikes()<br>&nbsp;&nbsp;&nbsp;&nbsp;then <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println


(&quot;likes cheese&quot;);<br>end<br><br><br>rule &quot;likes french cheese&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;when<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$person : Person ()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FrenchCheese(&nbsp;&nbsp;) from $person.getLikes()<br>&nbsp;&nbsp;&nbsp;&nbsp;then <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println

(&quot;likes french cheese&quot;);
<br>end<br></div><br>First test :<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Cheese cheese = new FrenchCheese(&quot;good&quot;, &quot;camembert&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Person person = new Person();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; person.setLikes(cheese);<br><br>Output :<br><div style="margin-left: 40px;">


likes french cheese<br>likes cheese<br></div><br>Wich is expected...<br><br>Second test : <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Cheese cheese = new Cheese();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Person person = new Person();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; person.setLikes(cheese);<br><br>Output :
<br><div style="margin-left: 40px;">likes french cheese<br>likes cheese<br></div><br>That&#39;s the first strange thing. As far as I am concerned, rule &quot;likes french cheese&quot; should not match (since a Cheese is not a FrenchCheese).
<br><br>I made a change to the second rule :<br><div style="margin-left: 40px;">rule &quot;likes french cheese&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;when<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$person : Person ()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FrenchCheese( smell == &quot;good&quot; ) from $person.getLikes()<br>
&nbsp;&nbsp;&nbsp;&nbsp;then <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&quot;likes french cheese&quot;);<br>
end<br></div><br>Third test :<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Cheese cheese = new Cheese();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Person person = new Person();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; person.setLikes(cheese);<br><br>output : <br>It throwed an exception : Exception in thread &quot;main&quot; java.lang.ClassCastException: rules.Cheese<br>I am not saying the ClassCastException is not to expect in such a case but I think I would simply expect it not to match (as far as a Cheese is not a FrenchCheese).
<br><span><br>Chris<br>
</span></blockquote></span></div></div><br>
<br>_______________________________________________<br>rules-users mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">
https://lists.jboss.org/mailman/listinfo/rules-users</a><br><br></blockquote></div><br><br clear="all"><br>-- <br>&nbsp;&nbsp;Edson Tirelli<br>&nbsp;&nbsp;Software Engineer - JBoss Rules Core Developer<br>&nbsp;&nbsp;Office: +55 11 3529-6000<br>&nbsp;&nbsp;Mobile: +55 11 9287-5646
<br>&nbsp;&nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>