| Article: |
Memoization in Java Using Dynamic Proxy Classes | |
| Subject: | Methods as Keys | |
| Date: | 2003-08-21 23:47:57 | |
| From: | anonymous2 | |
|
Nice article. It's a very nice use of dynamic proxies to separate concerns. One thing you may wish to consider as part of your "fully featured version of Memoizer" is a WeakHashMap for your top-level map that maps Method instances to value caches. Using a "standard" map implementation will prevent the JVM from unloading any class that has a method as a key in your top-level map.
|
||
Showing messages 1 through 1 of 1.




Using a WeakHashMap is a good idea, and probably the best way to go. By "mangling" a method name, do you mean including the method's parameter types (a bit like the toString() on Method)? The drawback with this approach is that you have to reconstruct (or retrieve from a cache) the Method each time it is invoked.
Tom