Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update JavaEmbedUtils to support easier use of ClassCache

git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@5910 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information...
commit 0c47cf64d5c8ba5fe33230e4ca195c35064c5142 1 parent 3c58a8a
@enebo enebo authored
View
11 src/org/jruby/javasupport/JavaEmbedUtils.java
@@ -32,6 +32,7 @@
import org.jruby.Ruby;
import org.jruby.RubyArray;
+import org.jruby.RubyInstanceConfig;
import org.jruby.RubyInteger;
import org.jruby.RubyModule;
import org.jruby.RubyObjectAdapter;
@@ -40,6 +41,7 @@
import org.jruby.runtime.Block;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
+import org.jruby.util.ClassCache;
/**
* Utility functions to help embedders out. These function consolidate logic that is
@@ -55,7 +57,14 @@
* @return an instance
*/
public static Ruby initialize(List loadPaths) {
- Ruby runtime = Ruby.newInstance();
+ return initialize(loadPaths, null);
+ }
+
+ public static Ruby initialize(List loadPaths, ClassCache classCache) {
+ RubyInstanceConfig config = new RubyInstanceConfig();
+
+ if (classCache != null) config.setClassCache(classCache);
+ Ruby runtime = Ruby.newInstance(config);
runtime.getLoadService().init(loadPaths);
runtime.getLoadService().require("java");
View
13 test/org/jruby/test/TestCodeCache.java
@@ -25,15 +25,12 @@ protected void setUp() throws Exception {
System.setProperty("jruby.compile.mode", "JIT");
System.setProperty("jruby.jit.threshold", "0");
-
- runtime1 = JavaEmbedUtils.initialize(new ArrayList<Object>());
- runtime2 = JavaEmbedUtils.initialize(new ArrayList<Object>());
- evaler = JavaEmbedUtils.newRuntimeAdapter();
-
+
ClassCache classCache = new ClassCache(Thread.currentThread().getContextClassLoader());
-
- runtime1.getInstanceConfig().setClassCache(classCache);
- runtime2.getInstanceConfig().setClassCache(classCache);
+
+ runtime1 = JavaEmbedUtils.initialize(new ArrayList<Object>(), classCache);
+ runtime2 = JavaEmbedUtils.initialize(new ArrayList<Object>(), classCache);
+ evaler = JavaEmbedUtils.newRuntimeAdapter();
super.setUp();
}
Please sign in to comment.
Something went wrong with that request. Please try again.