veaven
unread,Aug 22, 2011, 9:59:18 AM8/22/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to lambdaj
Hi,
I want to use lambdaj in my project, however, I notice that lambdaj
uses several WeakReference in its code. According to my understanding,
JVM GC will automatically collect these WeakReference objects, so, it
means we could get NullPointException in the runtime if my process is
heavily loaded.
Could you please help me to understand why lambdaj uses these
WeakRefernce? can we use do not use WeakReference here? thanks.
In ArgumentsFactory class
private static final Map<InvocationSequence, Object>
PLACEHOLDER_BY_INVOCATION = new WeakHashMap<InvocationSequence,
Object>();
In ProxyArgument class
this.invocationSequence = new
WeakReference<InvocationSequence>(invocationSequence);
...
// the following code could throw NPE in the Runtime as
invocationSequence could be NULL.
public Object invoke(Object proxy, Method method, Object[] args) {
return createArgument(method.getReturnType(), new
InvocationSequence(invocationSequence.get(), new
Invocation(proxiedClass, method, args)));
}
In Invocation class.
weakArgs[i] = invokedMethod.getParameterTypes()[i].isPrimitive() ?
new StrongParameterReference(args[i]) : new
WeakParameterReference(args[i]);
David