Hello; it's me again, deep/close reading ProxyFactory.java to understand everything I can about proxies in Weld.
I think the proxy name produced by getProxyName() is based on the (quite possibly indeterminate) ordering of the Set of types that happens to be passed to it. This would mean that even subsequent calls to this method with the same Set might yield different and surprising results. Is this correct?
For example, in a test that I wrote to further understand how proxy names are constructed:
final Method getProxyName = ProxyFactory.class.getDeclaredMethod("getProxyName", String.class, Class.class, Set.class, Bean.class);
getProxyName.setAccessible(true);
final Set<Type> typeSet = new LinkedHashSet<>();
// Let's add two disparate interfaces in an arbitrary, but predictable, order.
typeSet.add(Serializable.class);
typeSet.add(Cloneable.class);
final String proxyName = (String)getProxyName.invoke(null, null, Object.class, typeSet, null);
assertEquals("java.io.Cloneable$Serializable$$Proxy$", proxyName); // ?! Whoa. Not what I expected.
proxyName contains "java.io.Cloneable$Serializable$$Proxy$". Is that by design? Or is the "java.io.Cloneable" part a mistake?
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 proxyName to contain "java.lang.Cloneable$Serializable$Proxy$".
Best,
Laird