<div dir="ltr">Hello; it&#39;s me again, deep/close reading <font face="monospace">ProxyFactory.java</font> to understand everything I can about proxies in Weld.<div><br></div><div>I think the proxy name produced by <font face="monospace">getProxyName()</font> is based on the (quite possibly indeterminate) ordering of the <font face="monospace">Set</font> of types that happens to be passed to it.  This would mean that even subsequent calls to this method with the same <font face="monospace">Set</font> might yield different and surprising results.  Is this correct?</div><div><br></div><div>For example, in a test that I wrote to further understand how proxy names are constructed:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="monospace">final Method getProxyName = ProxyFactory.class.getDeclaredMethod(&quot;getProxyName&quot;, String.class, Class.class, Set.class, Bean.class);</font></div><div><font face="monospace">getProxyName.setAccessible(true);</font></div><div><font face="monospace">final Set&lt;Type&gt; typeSet = new LinkedHashSet&lt;&gt;();</font></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="monospace">// Let&#39;s add two disparate interfaces in an arbitrary, but predictable, order.</font></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="monospace">typeSet.add(Serializable.class);</font></div><div><font face="monospace">typeSet.add(Cloneable.class);</font></div><div><font face="monospace">final String proxyName = (String)getProxyName.invoke(null, null, Object.class, typeSet, null);</font></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="monospace">assertEquals(&quot;java.io.Cloneable$Serializable$$Proxy$&quot;, proxyName); // ?!  Whoa.  Not what I expected.</font></div></blockquote><div><br></div><div><font face="monospace">proxyName</font> contains &quot;<font face="monospace">java.io.Cloneable$Serializable$$Proxy$</font>&quot;.  Is that by design?  Or is the &quot;<font face="monospace">java.io.Cloneable</font>&quot; part a mistake?</div><div><br></div><div>And are the double dollar signs (<font face="monospace">$$</font>) in this case intentional as well?  (There are certainly paths through this method that won&#39;t result in double dollar signs, so I&#39;m not sure if this is a bug or a feature.)  <span style="font-size:0.875rem">To my eyes, this is suspicious: <a href="https://github.com/weld/core/blob/10a1d11af8c815a2a4a8fc5a4061698215e602b0/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java#L283">https://github.com/weld/core/blob/10a1d11af8c815a2a4a8fc5a4061698215e602b0/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java#L283</a>  Shouldn&#39;t that happen only if there aren&#39;t any more interface names to add?  So are the two dollar signs just a symptom of a bug?</span></div><div><br></div><div>By contrast, in case it matters, my naïve expectation, following what seems to me the intended logic of the method, would have been for <font face="monospace">proxyName</font> to contain &quot;<font face="monospace">java.lang.Cloneable$Serializable$Proxy$</font>&quot;.</div><div><br></div><div>Best,</div><div>Laird</div><div><br></div></div>