public static class ProxyFactory.CacheKey
extends java.lang.Object
If all the above criteria match between two keys, the keys are equivalent; else they are not.
Instances of this class are used in a cache, to ensure redundant proxy classes are not assembled and loaded. TODO: Since these cache keys rely in part on the proxies' parent classes and interfaces, their presence in the cache will prevent these parent classes and interfaces from being unloaded and garbage collected. This constitutes a potential memory leak, which should be resolved.
| Modifier and Type | Field and Description |
|---|---|
private boolean |
declaredOnly
Flag indicating only declared methods of interfaces are proxied
|
private static java.util.Map<java.lang.Object,java.lang.Integer> |
DO_NOT_PROXY_HASH_CODES
Hash code for the
doNotProxy arrays. |
private java.lang.reflect.Method[] |
doNotProxy
Methods which are not to be proxied
|
private int |
hashCode
Hash code for this key
|
private java.lang.Class<?>[] |
interfaces
Interfaces implemented by proxy class
|
private java.lang.Class<?> |
parent
Parent class of proxy class
|
| Constructor and Description |
|---|
CacheKey(java.lang.Class<?> parent,
java.lang.Class<?>[] interfaces,
boolean declaredOnly,
java.lang.reflect.Method[] doNotProxy)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object o)
Determine whether this object is equivalent to the given object.
|
int |
hashCode()
Return a well-distributed hash code which is consistent with this
class' implementation of
equals(Object). |
java.lang.String |
toString()
Method used to create a string representation of
ProxyFactory.CacheKey,
which is also used for mapping to names of pre-generated Proxy classes. |
private static final java.util.Map<java.lang.Object,java.lang.Integer> DO_NOT_PROXY_HASH_CODES
doNotProxy arrays.private final java.lang.Class<?> parent
private final java.lang.Class<?>[] interfaces
private final boolean declaredOnly
private final java.lang.reflect.Method[] doNotProxy
private final int hashCode
public CacheKey(java.lang.Class<?> parent,
java.lang.Class<?>[] interfaces,
boolean declaredOnly,
java.lang.reflect.Method[] doNotProxy)
parent - Parent class of proxy class.interfaces - Interfaces implemented by proxy class.declaredOnly - Flag indicating only declared methods of interfaces are
proxied.doNotProxy - Methods which are not to be proxied. May be an empty array,
but must not be null.public int hashCode()
equals(Object).hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object o)
Two cache keys are considered equivalent if their various fields are equivalent.
equals in class java.lang.Objecto - Another object to test for equivalence with this one.true if o is another instance of
this class with equivalent fields, else false.public java.lang.String toString()
ProxyFactory.CacheKey,
which is also used for mapping to names of pre-generated Proxy classes.
So there should be a balance in how unique this methods result is,
and how efficient this method is.toString in class java.lang.Object