<br>&nbsp;&nbsp;&nbsp; Godmar,<br><br>&nbsp;&nbsp;&nbsp; We are getting there. Lets forget, as you suggested, the SingletonMap example. Lets take, for instance:<br><br>class MyMapClass extends TreeMap {<br>&nbsp;&nbsp; //...<br>}<br><br>&nbsp;&nbsp;&nbsp; We can&#39;t shadow it by using:<br>
<br>Map shadow = new HashMap( myMapInstance );<br><br>&nbsp;&nbsp;&nbsp; This is because you can write rules against your concrete class:<br><br>rule XYZ<br>when<br>&nbsp;&nbsp;&nbsp; MyMapClass( ... )<br>then<br>end<br>&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; So, shadow proxies must be a subclass of the concrete class that is asserted. In this case, it would be a dynamically generated MyMapClassShadowProxy class. <br>
&nbsp;&nbsp;&nbsp; Now, how can we transfer the state from a MyMapClass instance, whose only information we have is that it implements the Map interface, to a newly instantiated MyMapClassShadowProxy instance?<br><br>&nbsp;&nbsp;&nbsp; If MyMapClass respect this &quot;best practice&quot; of having a constructor receiving a Map parameter to do a shallow copy, great, we use that as I explained in my previous e-mail. But the problem with SingletonMap and eventually other user implemented Map/Collection classes is that they may not have such constructor.<br>
<br>&nbsp;&nbsp;&nbsp; So, what I&#39;m trying to say is, we do allow you to assert Map/Collection instances as facts and to reason over then, but at this point you must be careful with which concrete class you use. Asserting a HashMap is fine, asserting a SingletonMap is not.<br>
<br>&nbsp;&nbsp;&nbsp; I know it is far from ideal at this point, but I don&#39;t know how to improve that in current codebase. That is why in the next major release we are trying to get rid of shadow facts.<br><br>&nbsp;&nbsp;&nbsp; Options you have to improve that is, for instance, dynamically generated beans. Even using a custom class that has your maps/collections as attributes is better than asserting your maps/collections directly.<br>
<br>&nbsp;&nbsp;&nbsp; A blog I wrote a long time ago about dynamically generated beans:<br><br><a href="http://blog.athico.com/2006/12/dynamically-generated-class-beans-as.html">http://blog.athico.com/2006/12/dynamically-generated-class-beans-as.html</a><br>
<br>&nbsp;&nbsp;&nbsp; []s<br>&nbsp;&nbsp;&nbsp; Edson<br><br><div><span class="gmail_quote">2008/2/20, Godmar Back &lt;<a href="mailto:godmar@gmail.com">godmar@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;">
On Feb 20, 2008 12:30 PM, Edson Tirelli &lt;<a href="mailto:tirelli@post.com">tirelli@post.com</a>&gt; wrote:<br> &gt;<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;Godmar,<br> &gt;<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;Shadow Facts are a necessary evil in current version. Basically what they<br>
 &gt; do is keep the working memory consistent in face of attribute changes on the<br> &gt; facts, that may happen both internally and externally to the working memory.<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp; Our implementation to shadow facts is a lazy proxy that caches the<br>
 &gt; values until a safe point to synchronize the actual attribute value with the<br> &gt; one seen by the engine.<br> &gt;<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;So, the question is: given an object:<br> &gt;<br> &gt; (Map) fact<br> &gt;<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;How can we create an identical copy of it (shadow), if there is no<br>
 &gt; &quot;clone&quot; operation?<br> <br> <br>Can you explain why you require the use of &quot;clone()&quot;?<br> <br> Cloning a map is otherwise easy - it&#39;s also referred to as a &quot;shallow<br> copy&quot; -- HashMap&#39;s HashMap(Map) constructor will do it.<br>
 <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/HashMap.html#HashMap(java.util.Map)">http://java.sun.com/j2se/1.4.2/docs/api/java/util/HashMap.html#HashMap(java.util.Map)</a><br> I know you know that, so explain what necessitates the use of clone().<br>
 <br><br> &gt; More than that, the shadow must be a subclass of it.<br> <br> <br>java.util.HashMap is a subclass of Map.<br> <br><br> &gt;<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;Most Collection and Map implementations have a single parameter<br> &gt; constructor that allows us to do:<br>
 &gt;<br> &gt;<br> &gt; proxy = (ShadowProxy) this.shadowClass.getConstructor( new Class[]{cls}<br> &gt; ).newInstance( new Object[]{fact} );<br> &gt;<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp; But the SingletonMap you were using does not accept that constructor.<br>
 &gt; So, one way is to explicit check if the fact is a SingletonMap and handle it<br> &gt; accordingly, but that is a specific class hack... is there any general<br> &gt; solution we can use?<br> &gt;<br> <br> <br>Forget about the SingletonMap.&nbsp;&nbsp;That was just one of the many things I<br>
 tried and failed.<br> <br> Fundamentally, I would like Drools to process facts that were obtained<br> from real-world sources, and these facts have properties I do not know<br> in advance. Therefore, I cannot use beans (or using beans would be<br>
 highly inconvenient since it will require changes to Java code<br> whenever I&#39;m referring to a new property, something I&#39;d rather avoid.)<br> <br><br>&nbsp;&nbsp;- Godmar<br> <br><br> &gt;<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp; []s<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp; Edson<br>
 &gt;<br> &gt; 2008/2/20, Godmar Back &lt;<a href="mailto:godmar@gmail.com">godmar@gmail.com</a>&gt;:<br> &gt; &gt; I don&#39;t really understand what you mean by &quot;shadow&quot;.&nbsp;&nbsp;What is the<br> &gt; &gt; purpose of such shadowing. Mark&#39;s email implies that it has to do with<br>
 &gt; &gt; concurrency protection; it&#39;s not clear what that means.<br> &gt; &gt;<br> &gt; &gt; In my view, whatever purpose you pursue with &quot;shadowing&quot;, it does not<br> &gt; &gt; justify treating beans and maps differently.<br>
 &gt; &gt;<br> &gt; &gt; Your example of class Person shows that. If a person has two<br> &gt; &gt; attributes, name and age, then this is equivalent to a map with two<br> &gt; &gt; keys &#39;name&#39; and &#39;age&#39;.<br>
 &gt; &gt;<br> &gt; &gt; Here&#39;s the mapping:<br> &gt; &gt;<br> &gt; &gt; p.getName()&nbsp;&nbsp;&nbsp;&nbsp;corresponds to m[&quot;name&quot;]<br> &gt; &gt; p.getAge() corresponds to m[&quot;age&quot;]<br> &gt; &gt;<br> &gt; &gt; and setName/setAge accordingly.<br>
 &gt; &gt;<br> &gt; &gt; Mathematically, a bean is an associative array with a fixed set of<br> &gt; &gt; keys (called &quot;properties&quot;) that map to values. For all practical<br> &gt; &gt; purposes, that is the same as a map. There&#39;s no reason to treat them<br>
 &gt; &gt; differently. Wherever you&#39;d do &quot;getXXX()&quot; with a bean you&#39;d do<br> &gt; &gt; .get(&quot;XXX&quot;) with a map.<br> &gt; &gt;<br> &gt; &gt; - Godmar<br> &gt; &gt;<br> &gt; &gt; On Feb 20, 2008 11:25 AM, Edson Tirelli &lt;<a href="mailto:tirelli@post.com">tirelli@post.com</a>&gt; wrote:<br>
 &gt; &gt; &gt;<br> &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;Ok, let me show one example. Imagine the class Person, with 2<br> &gt; attributes<br> &gt; &gt; &gt; (name and age) and the corresponding getter/setters.<br> &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;What are the data for that fact that must be shadowed? easy answer:<br>
 &gt; just<br> &gt; &gt; &gt; shadow all getXXX() methods (getName and getAge).<br> &gt; &gt; &gt;<br> &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;Now, take a Map. What is the data that must be shadowed?<br> &gt; &gt; &gt;<br> &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;So, we do our best to work with facts that don&#39;t follow the javabean<br>
 &gt; &gt; &gt; spec, but collections and maps are a complicated beast. Again, if you<br> &gt; have<br> &gt; &gt; &gt; suggestions on how to improve the current support we provide for them,<br> &gt; &gt; &gt; please share with us.<br>
 &gt; &gt; &gt;<br> &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;[]s<br> &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;Edson<br> &gt; &gt; &gt;<br> &gt; &gt; &gt; 2008/2/20, Godmar Back &lt;<a href="mailto:godmar@gmail.com">godmar@gmail.com</a>&gt;:<br> &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; On Feb 20, 2008 9:23 AM, Edson Tirelli &lt;<a href="mailto:tirelli@post.com">tirelli@post.com</a>&gt; wrote:<br>
 &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;Godmar,<br> &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;Short answer: collection/maps objects are not javabeans.<br> &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt;<br>
 &gt; &gt; &gt; &gt; Explain why this is a problem.<br> &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; What is it about JavaBeans that your algorithm relies upon?&nbsp;&nbsp;Is it the<br> &gt; &gt; &gt; &gt; fact that the set of properties remains fixed and can be determined at<br>
 &gt; &gt; &gt; &gt; (fact) insertion time via reflection?<br> &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; Otherwise, I do not see any conceptual difference between a map and a<br> &gt; &gt; &gt; bean.<br> &gt; &gt; &gt; &gt; If that is the difference, then please allow maps with an immutable<br>
 &gt; key<br> &gt; &gt; &gt; set.<br> &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; - Godmar<br> &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;Long answer: collection/maps must be shadowed to ensure<br>
 &gt; consistency<br> &gt; &gt; &gt; &gt; &gt; during execution, but how can we shadow the data if it is not<br> &gt; exposed in<br> &gt; &gt; &gt; a<br> &gt; &gt; &gt; &gt; &gt; default, spec manner, as in javabeans? The algorithm we have in<br>
 &gt; place<br> &gt; &gt; &gt; right<br> &gt; &gt; &gt; &gt; &gt; now is bellow. As you can see, it is a weak algo, but was the best I<br> &gt; &gt; &gt; could<br> &gt; &gt; &gt; &gt; &gt; come up at that time. If you have any suggestions on how to improve<br>
 &gt; &gt; &gt; that, I<br> &gt; &gt; &gt; &gt; &gt; appreciate.<br> &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; public Object getShadow(final Object fact) throws<br> &gt; &gt; &gt; RuntimeDroolsException<br>
 &gt; &gt; &gt; &gt; &gt; {<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ShadowProxy proxy = null;<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( isShadowEnabled() ) {<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try {<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( Collection.class.isAssignableFrom(<br>
 &gt; this.shadowClass<br> &gt; &gt; &gt; )<br> &gt; &gt; &gt; &gt; &gt; || Map.class.isAssignableFrom( this.shadowClass ) ) {<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// if it is a collection, try to instantiate<br>
 &gt; using<br> &gt; &gt; &gt; &gt; &gt; constructor<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try {<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; proxy = (ShadowProxy)<br> &gt; &gt; &gt; &gt; &gt; this.shadowClass.getConstructor( new Class[]{cls} ).newInstance( new<br>
 &gt; &gt; &gt; &gt; &gt; Object[]{fact} );<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch ( Exception e ) {<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // not possible to instantiate using<br> &gt; constructor<br>
 &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( proxy == null ) {<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( this.instantiator == null ) {<br>
 &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.setInstantiator();<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; proxy = (ShadowProxy)<br> &gt; &gt; &gt; this.instantiator.newInstance();<br>
 &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; proxy.setShadowedObject( fact );<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch ( final Exception e ) {<br>
 &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println( &quot;shadow: &quot; +proxy.getClass() +<br> &gt; &quot;:&quot; +<br> &gt; &gt; &gt; &gt; &gt; fact.getClass() );<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new RuntimeDroolsException( &quot;Error creating<br>
 &gt; shadow<br> &gt; &gt; &gt; &gt; &gt; fact for object: &quot; + fact,<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e );<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
 &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return proxy;<br> &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[]s<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Edson<br>
 &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt; 2008/2/19, Godmar Back &lt;<a href="mailto:godmar@gmail.com">godmar@gmail.com</a>&gt;:<br> &gt; &gt; &gt; &gt; &gt; &gt; As a general comment, the examples for which I find Drools failing<br>
 &gt; are<br> &gt; &gt; &gt; &gt; &gt; &gt; not the actual examples for which my application is failing. It&#39;s<br> &gt; just<br> &gt; &gt; &gt; &gt; &gt; &gt; the smallest test case I was able to eliminate.<br> &gt; &gt; &gt; &gt; &gt; &gt;<br>
 &gt; &gt; &gt; &gt; &gt; &gt; I&#39;m now a bit concerned about your comment that Maps and<br> &gt; Collections<br> &gt; &gt; &gt; &gt; &gt; &gt; aren&#39;t well-defined as Facts. I am planning to make extensive use<br> &gt; of<br>
 &gt; &gt; &gt; &gt; &gt; &gt; them (that&#39;s also why I&#39;d prefer to use the MVEL dialect, because<br> &gt; in<br> &gt; &gt; &gt; &gt; &gt; &gt; Java I cannot do this without creating Bean wrappers.)<br> &gt; &gt; &gt; &gt; &gt; &gt;<br>
 &gt; &gt; &gt; &gt; &gt; &gt; Could you elaborate what makes the semantics not &quot;well-defined&quot;.<br> &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt; &gt; I&#39;m specifically concerned with immutable maps (such as the one<br>
 &gt; that<br> &gt; &gt; &gt; &gt; &gt; &gt; would have been returned by Collections.singletonMap), and with<br> &gt; &gt; &gt; &gt; &gt; &gt; collections of maps (such as those obtained via a &quot;from&quot;...&quot;<br>
 &gt; clause).<br> &gt; &gt; &gt; &gt; &gt; &gt; I need to insert immutable maps as facts; I understand that the<br> &gt; items<br> &gt; &gt; &gt; &gt; &gt; &gt; returned by &quot;from&quot; aren&#39;t inserted as facts.<br>
 &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt; &gt; - Godmar<br> &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt; &gt; On Feb 19, 2008 3:11 PM, Edson Tirelli &lt;<a href="mailto:tirelli@post.com">tirelli@post.com</a>&gt; wrote:<br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;Drools tries to create the ShadowProxy. The reason is that it<br> &gt; &gt; &gt; does<br> &gt; &gt; &gt; &gt; &gt; not<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; know about the implementation... it just knows it is a Map and<br>
 &gt; as<br> &gt; &gt; &gt; so, it<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; must be shadowed. Problem is that SingletonMap is either&nbsp;&nbsp;final<br> &gt; or<br> &gt; &gt; &gt; does<br> &gt; &gt; &gt; &gt; &gt; not<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; have a default constructor.<br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; My recommendation, besides opening a JIRA for this, is avoid<br> &gt; &gt; &gt; &gt; &gt; inserting<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; collections/maps directly as facts. The semantic for such facts<br>
 &gt; is<br> &gt; &gt; &gt; not<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; clearly defined and it may cause undesired behavior.<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;[]s<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;Edson<br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; 2008/2/19, Godmar Back &lt;<a href="mailto:godmar@gmail.com">godmar@gmail.com</a>&gt;:<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; Hi,<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; usings Drools 4.0.4 and MVEL 1.4, this simple rule:<br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; ---<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; package test;<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; import java.util.Collections;<br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; dialect &quot;mvel&quot;<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; rule &quot;Rule #1&quot;<br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; when<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; then<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; insert(Collections.singletonMap(&quot;content&quot;, &quot;hello&quot;));<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; end<br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; --<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; produces:<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; java.lang.IllegalAccessError: class<br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; org.drools.shadow.java.util.Collections$SingletonMapShadowProxy<br> &gt; &gt; &gt; cannot<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; access its superclass java.util.Collections$SingletonMap<br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.lang.ClassLoader.defineClass1(Native Method)<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at<br> &gt; java.lang.ClassLoader.defineClass(ClassLoader.java:620)<br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt;<br> &gt; org.drools.rule.MapBackedClassLoader.fastFindClass(MapBackedClassLoader.java:60)<br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt;<br> &gt; org.drools.rule.MapBackedClassLoader.loadClass(MapBackedClassLoader.java:79)<br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at<br> &gt; java.lang.ClassLoader.loadClass(ClassLoader.java:251)<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt;<br>
 &gt; &gt; &gt;<br> &gt; org.drools.reteoo.Rete$ClassObjectTypeConf.loadOrGenerateProxy(Rete.java:547)<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt;<br>
 &gt; &gt; &gt;<br> &gt; org.drools.reteoo.Rete$ClassObjectTypeConf.defineShadowProxyData(Rete.java:494)<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; org.drools.reteoo.Rete$ClassObjectTypeConf.&lt;init&gt;(Rete.java:461)<br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.drools.reteoo.Rete.assertObject(Rete.java:152)<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)<br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt;<br> &gt; org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:71)<br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt;<br> &gt; org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:909)<br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt;<br> &gt; org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:881)<br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt;<br> &gt; org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:67)<br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt;<br> &gt; org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:61)<br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; It&#39;s not clear to me why Drools creates Proxies for such<br> &gt; classes<br> &gt; &gt; &gt; as<br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; java.util.Collections, or does MVEL do it?<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; - Godmar<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; _______________________________________________<br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; rules-users mailing list<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; --<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp; Edson Tirelli<br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp; JBoss Drools Core Development<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;Office: +55 11 3529-6000<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp; Mobile: +55 11 9287-5646<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp; JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt; _______________________________________________<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; rules-users mailing list<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
 &gt; &gt; &gt; &gt; &gt; &gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br> &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
 &gt; &gt; &gt; &gt; &gt; &gt; _______________________________________________<br> &gt; &gt; &gt; &gt; &gt; &gt; rules-users mailing list<br> &gt; &gt; &gt; &gt; &gt; &gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
 &gt; &gt; &gt; &gt; &gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br> &gt; &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt;<br>
 &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt; --<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp; Edson Tirelli<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp; JBoss Drools Core Development<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp; Office: +55 11 3529-6000<br>
 &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp; Mobile: +55 11 9287-5646<br> &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp; JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br> &gt; &gt; &gt; &gt; &gt; _______________________________________________<br>
 &gt; &gt; &gt; &gt; &gt; rules-users mailing list<br> &gt; &gt; &gt; &gt; &gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br> &gt; &gt; &gt; &gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
 &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt; &gt; _______________________________________________<br> &gt; &gt; &gt; &gt; rules-users mailing list<br> &gt; &gt; &gt; &gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
 &gt; &gt; &gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br> &gt; &gt; &gt; &gt;<br> &gt; &gt; &gt;<br> &gt; &gt; &gt;<br> &gt; &gt; &gt;<br>
 &gt; &gt; &gt;<br> &gt; &gt; &gt; --<br> &gt; &gt; &gt;&nbsp;&nbsp; Edson Tirelli<br> &gt; &gt; &gt;&nbsp;&nbsp; JBoss Drools Core Development<br> &gt; &gt; &gt;&nbsp;&nbsp; Office: +55 11 3529-6000<br> &gt; &gt; &gt;&nbsp;&nbsp; Mobile: +55 11 9287-5646<br> &gt; &gt; &gt;&nbsp;&nbsp; JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>
 &gt; &gt; &gt; _______________________________________________<br> &gt; &gt; &gt; rules-users mailing list<br> &gt; &gt; &gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br> &gt; &gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
 &gt; &gt; &gt;<br> &gt; &gt; &gt;<br> &gt; &gt; _______________________________________________<br> &gt; &gt; rules-users mailing list<br> &gt; &gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
 &gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br> &gt; &gt;<br> &gt;<br> &gt;<br> &gt;<br> &gt; --<br> &gt;&nbsp;&nbsp; Edson Tirelli<br> &gt;&nbsp;&nbsp; JBoss Drools Core Development<br>
 &gt;&nbsp;&nbsp; Office: +55 11 3529-6000<br> &gt;&nbsp;&nbsp; Mobile: +55 11 9287-5646<br> &gt;&nbsp;&nbsp; JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br> &gt; _______________________________________________<br> &gt; rules-users mailing list<br>
 &gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br> &gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br> &gt;<br>
 &gt;<br> _______________________________________________<br> rules-users mailing list<br> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br> <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
 </blockquote></div><br><br clear="all"><br>-- <br>&nbsp;&nbsp;Edson Tirelli<br>&nbsp;&nbsp;JBoss Drools Core Development<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>