Permalink
Browse files

Allow java proxy class to be overriden for Android support

  • Loading branch information...
enebo authored and Prathamesh Sonpatki committed Sep 13, 2012
1 parent 5276cd5 commit ffa26ea9b39c08a8538443e5ca2cc83ca24dc5de
View
@@ -164,6 +164,7 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.regex.Pattern;
+import org.jruby.javasupport.proxy.JavaProxyClassFactory;
/**
* The Ruby object represents the top-level of a JRuby "instance" in a given VM.
@@ -2695,6 +2696,15 @@ public void addBoundMethod(String className, String methodName, String rubyName)
return boundMethods;
}
+ public void setJavaProxyClassFactory(JavaProxyClassFactory factory) {
+ this.javaProxyClassFactory = factory;
+ }
+
+ public JavaProxyClassFactory getJavaProxyClassFactory() {
+ return javaProxyClassFactory;
+ }
+
+
public class CallTraceFuncHook extends EventHook {
private RubyProc traceFunc;
@@ -4463,4 +4473,6 @@ public void secure(int level) {
private ThreadLocal<Boolean> inRecursiveListOperation = new ThreadLocal<Boolean>();
private FFI ffi;
+
+ private JavaProxyClassFactory javaProxyClassFactory;
}
@@ -54,6 +54,8 @@
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.jruby.MetaClass;
import org.jruby.Ruby;
@@ -98,6 +100,7 @@
import org.jruby.java.proxies.InterfaceJavaProxy;
import org.jruby.java.proxies.JavaProxy;
import org.jruby.java.proxies.RubyObjectHolderProxy;
+import org.jruby.javasupport.proxy.JavaProxyClassFactory;
import org.jruby.util.ClassCache.OneShotClassLoader;
import org.jruby.util.cli.Options;
@@ -120,6 +123,8 @@ public void load(Ruby runtime, boolean wrap) throws IOException {
ajp.includeModule(runtime.getEnumerable());
RubyClassPathVariable.createClassPathVariable(runtime);
+
+ runtime.setJavaProxyClassFactory(JavaProxyClassFactory.createFactory());
// modify ENV_JAVA to be a read/write version
Map systemProps = new SystemPropertiesMap();
@@ -118,8 +118,8 @@ public static JavaProxyClass getProxyClass(Ruby runtime, Class superClass,
runtimeTLS.set(runtime);
try {
ClassLoader loader = runtime.getJRubyClassLoader();
-
- return JavaProxyClassFactory.newProxyClass(runtime, loader, null, superClass, interfaces, names);
+
+ return runtime.getJavaProxyClassFactory().newProxyClass(runtime, loader, null, superClass, interfaces, names);
} finally {
runtimeTLS.set(save);
}
Oops, something went wrong.

0 comments on commit ffa26ea

Please sign in to comment.