[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] instance tracking example in dev notebook
|
That's a good spot, thank-you. I've updated the chapter in CVS.
Guess that's the problem with documenting code that you can't compile and
test yet!
-- Adrian
Adrian_Colyer@xxxxxxxxxx
Tim Peierls <tim@xxxxxxxxxxx>
Sent by: aspectj-users-admin@xxxxxxxxxxx
14/12/2004 22:51
Please respond to
aspectj-users@xxxxxxxxxxx
To
aspectj-users@xxxxxxxxxxx
cc
Subject
[aspectj-users] instance tracking example in dev notebook
The instance tracking example in the developer's notebook at
http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspectj-home/doc/ajdk15notebook/pertypewithin.html
is very cool, but it should use WeakHashMap<T, Boolean> internally rather
than
Set<WeakReference<T>>. As it stands, null references will hang around
forever.
I know it's just an illustration, but I bet lots of folks will copy it
blindly.
public aspect InstanceTracking<T> pertypewithin(org.xyz..*) {
private Map<T, Boolean> instances = new WeakHashMap<T, Boolean>();
after() returning(T t) : execution(new(..)) {
instances.put(t, true);
}
public Set<T> getInstances() {
return instances.keySet();
}
}
--tim
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users