Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add way of creating a classcache using RubyInstanceConfig settings

git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@5940 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information...
commit d2e670025099109e1ed3918b67637b4b83acf15c 1 parent 6513a36
@enebo enebo authored
View
18 src/org/jruby/javasupport/JavaEmbedUtils.java
@@ -60,6 +60,13 @@ public static Ruby initialize(List loadPaths) {
return initialize(loadPaths, null);
}
+ /**
+ * Get an instance of a JRuby runtime. Provide any loadpaths you want used at startup.
+ *
+ * @param loadPaths to specify where to look for Ruby modules.
+ * @param classCache to use as a common repository for cached classes
+ * @return an instance
+ */
public static Ruby initialize(List loadPaths, ClassCache classCache) {
RubyInstanceConfig config = new RubyInstanceConfig();
@@ -70,6 +77,17 @@ public static Ruby initialize(List loadPaths, ClassCache classCache) {
return runtime;
}
+
+ /**
+ * Generate a class cache. This will end up setting max cache size per JRuby preferences
+ * (e.g. jruby.jit.max).
+ *
+ * @param loader use the provided classloader to create the cache
+ * @return
+ */
+ public static ClassCache createClassCache(ClassLoader loader) {
+ return new ClassCache(loader, new RubyInstanceConfig().getJitMax());
+ }
public static RubyObjectAdapter newObjectAdapter() {
return new RubyObjectAdapter() {
View
3  test/org/jruby/test/TestCodeCache.java
@@ -27,8 +27,7 @@ protected void setUp() throws Exception {
System.setProperty("jruby.jit.threshold", "0");
// construct a new cache with thread's classloader and no limit
- ClassCache classCache = new ClassCache(Thread.currentThread().getContextClassLoader());
-
+ ClassCache classCache = JavaEmbedUtils.createClassCache(Thread.currentThread().getContextClassLoader());
runtime1 = JavaEmbedUtils.initialize(new ArrayList<Object>(), classCache);
runtime2 = JavaEmbedUtils.initialize(new ArrayList<Object>(), classCache);
evaler = JavaEmbedUtils.newRuntimeAdapter();
Please sign in to comment.
Something went wrong with that request. Please try again.