<div dir="ltr"><div dir="ltr"><span style="font-size:0.875rem">On Tue, Mar 10, 2020 at 9:07 AM Matej Novotny &lt;<a href="mailto:manovotn@redhat.com">manovotn@redhat.com</a>&gt; wrote:</span><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">first and foremost, these are purely internal mechanics. There is no guarantee in CDI spec or Weld docs on how the proxies should look like.<br></blockquote><div><br></div><div>Yep; I completely understand.  (That&#39;s why I&#39;m writing on the weld-dev list instead of the cdi-dev list.)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">So, looking at the method, the &quot;middle&quot; part of the name seems to be good, there is sorting done.<br>
See <a href="https://github.com/weld/core/blob/master/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java#L280" rel="noreferrer" target="_blank">https://github.com/weld/core/blob/master/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java#L280</a></blockquote><div><br></div><div>Right; if I implement <font face="monospace">Cloneable</font> and <font face="monospace">Serializable</font>, their simple names are sorted so that <font face="monospace">Cloneable</font> comes before <font face="monospace">Serializable</font>.  (They aren&#39;t sorted on their full type names; if they were then <font face="monospace">Serializable</font> would come first.)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">What seems to be inconsistent is the proxy prefix - the package. The set in TypeInfo isn&#39;t sorted anyhow.<br></blockquote><div><br></div><div>That&#39;s right.  The package is computed before the simple class names are sorted.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
However, within one application run, I don&#39;t think you can realistically end up having two proxies for the same bean, since you can hardly invoke this method for the same bean and pass it its bean type set ordered differently.<br></blockquote><div><br></div><div>And that&#39;s fine; I&#39;m just trying to understand the code.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">&gt; proxyName contains &quot; java.io.Cloneable$Serializable$$Proxy$ &quot;. Is that by<br>
&gt; design? Or is the &quot; java.io.Cloneable &quot; part a mistake?<br>
<br>
For proxy purposes, it doesn&#39;t really matter if the proxy will be &quot;java.io.Cloneable$Serializable$$Proxy$&quot; or &quot;java.lang.Cloneable$Serializable$$Proxy$&quot;.<br></blockquote><div><br></div><div>I agree that the name is internal and no one should care.  I care only because I am working to understand everything about proxies that I can in Weld.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">&gt; And are the double dollar signs ( $$ ) in this case intentional as well?<br>
&gt; (There are certainly paths through this method that won&#39;t result in double<br>
&gt; dollar signs, so I&#39;m not sure if this is a bug or a feature.)<br>
<br>
The code path that doesn&#39;t produce this is when you use a bean class (non-Object) and instead of type closure use empty set. In such case, it would leave out the second dollar sign, at least from what I gathered.<br></blockquote><div><br></div><div>Right; I think there&#39;s just a missing &quot;<font face="monospace">if (iterator.hasNext())</font>&quot; in there somewhere.  No problem, just wanted to know if this was intentional or a small oversight.  It looks like it wasn&#39;t intentional and it just doesn&#39;t matter very much.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
I don&#39;t think there is a strong argument for having one/two dollar signs but consistency is a nice behavioral pattern to stick with so we could align that. I cannot really imagine a justification for having different number of dollar<br>
signs for proxies with certain type set.<br></blockquote><div><br></div><div>Right; me neither.</div><div><br></div><div>I think it&#39;s also worth pointing out that the proxy name is not actually finished when this method completes.</div><div><br></div><div>So once we end up with <font face="monospace">java.io.Cloneable$Serializable$$Proxy$</font>, that gets passed to <font face="monospace">getProxyClass()</font> and this comes into play: <a href="https://github.com/weld/core/blob/10a1d11af8c815a2a4a8fc5a4061698215e602b0/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java#L353-L360">https://github.com/weld/core/blob/10a1d11af8c815a2a4a8fc5a4061698215e602b0/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java#L353-L360</a></div><div><br></div><div>So the final proxy class name in this case would be <font face="monospace">org.jboss.weld.io.Serializable$$Cloneable$Proxy$_$$_Weld$Proxy$</font>.</div><div><br></div><div>(Also somewhat weirdly, something starting with <font face="monospace">javax</font> would get turned into <font face="monospace">org.jboss.weldx</font>.)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Last but not least, this class (ProxyFactory) is mostly used for subclasses used for interceptor/decorator logic, there could be something similar in ClientProxyFactory which is what handles actual bean proxies.<br></blockquote><div><br></div><div>Yep; haven&#39;t gotten that far in my code reading yet.  :-)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">If you want, go ahead and create a Weld issue so this doesn&#39;t get forgotten again :)<br></blockquote><div><br></div><div>OK; sure.</div><div><br></div><div>I think my own personal takeaway from all this is:</div><div><ul><li>A best effort is made to make proxy names unique.</li><li>Proxy names are opaque and their format can obviously change at any time since they aren&#39;t specified by the CDI specification.</li><li>Proxy names are (as of this writing) not deterministic since <font face="monospace">TypeInfo</font> constructs are not sorted.</li><li>There isn&#39;t really a lot of logic around what all the dollar signs mean (sometimes they&#39;re doubled, sometimes they&#39;re not; they just sort of separate things in the otherwise opaque name).</li></ul></div><div><span style="font-size:0.875rem">Best,</span><br></div><div>Laird</div></div></div>