Hi!
I worked on AR-JDBC recently. assert_queries in abstract_unit.rb
doesn't work in JRuby. The reason is that 'execute' method is aliased.
After debug, I find removeCachedMethod in CacheSite isn't invoked
(remove in CacheMap) when method is aliased. I can't give the exact
reason because some code works.
The attached file is the patch for this bug. I know CacheSite is used
for CallAdapter which is for performance currently. I'm not sure
whether the patch impacts performance.
Ye Zheng
--
Everything is simple!
Index: src/org/jruby/runtime/CacheMap.java
===================================================================
--- src/org/jruby/runtime/CacheMap.java (revision 4193)
+++ src/org/jruby/runtime/CacheMap.java (working copy)
@@ -31,7 +31,6 @@
import java.util.Iterator;
import java.util.Map;
-import org.jruby.RubyModule;
import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.util.WeakIdentityHashMap;
@@ -63,12 +62,12 @@
* @param method which is cached
* @param module which is caching method
*/
- public void add(DynamicMethod method, CacheSite site) {
- Map classList = (Map) mappings.get(method);
+ public void add(String name, CacheSite site) {
+ Map classList = (Map) mappings.get(name);
if (classList == null) {
classList = new WeakIdentityHashMap();
- mappings.put(method, classList);
+ mappings.put(name, classList);
}
classList.put(site,null);
@@ -83,7 +82,7 @@
* @param method to remove all caches of
*/
public void remove(String name, DynamicMethod method) {
- Map classList = (Map) mappings.remove(method);
+ Map classList = (Map) mappings.remove(name);
// Removed method has never been used so it has not been cached
if (classList == null) {
Index: src/org/jruby/runtime/CallAdapter.java
===================================================================
--- src/org/jruby/runtime/CallAdapter.java (revision 4193)
+++ src/org/jruby/runtime/CallAdapter.java (working copy)
@@ -33,7 +33,6 @@
import org.jruby.RubyObject;
import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.runtime.builtin.IRubyObject;
-import org.jruby.util.MethodCache;
/**
*
@@ -163,7 +162,7 @@
cachedType = selfType;
cachedTable = table;
- selfType.getRuntime().getCacheMap().add(method, this);
+ selfType.getRuntime().getCacheMap().add(this.methodName, this);
return method.call(context, self, selfType, methodName, args,
block);
} catch (StackOverflowError soe) {
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email