public
Created

  • Download Gist
ClassCache.java
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
protected Class<T> defineClass(ClassGenerator classGenerator) {
// attempt to load from classloaders
String className = classGenerator.name();
Class contents = null;
try {
contents = getClassLoader().loadClass(className);
if (RubyInstanceConfig.JIT_LOADING_DEBUG) {
System.err.println("found jitted code in classloader: " + className);
}
} catch (ClassNotFoundException cnfe) {
if (RubyInstanceConfig.JIT_LOADING_DEBUG) {
System.err.println("no jitted code in classloader for method " + classGenerator + " at class: " + className);
}
// proceed to define in-memory
}
OneShotClassLoader oneShotCL = new OneShotClassLoader(getClassLoader());
classGenerator.generate();
contents = oneShotCL.defineClass(classGenerator.name(), classGenerator.bytecode());
classLoadCount.incrementAndGet();
 
return contents;
}
Ruby.java
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
 
// FIXME: duplicated from ClassCache
Class contents;
try {
contents = jrubyClassLoader.loadClass(className);
if (RubyInstanceConfig.JIT_LOADING_DEBUG) {
System.err.println("found jitted code for " + filename + " at class: " + className);
}
script = (Script)contents.newInstance();
readStream = new ByteArrayInputStream(buffer);
} catch (ClassNotFoundException cnfe) {
if (RubyInstanceConfig.JIT_LOADING_DEBUG) {
System.err.println("no jitted code in classloader for file " + filename + " at class: " + className);
}
} catch (InstantiationException ie) {
if (RubyInstanceConfig.JIT_LOADING_DEBUG) {
System.err.println("jitted code could not be instantiated for file " + filename + " at class: " + className);
}
} catch (IllegalAccessException iae) {
if (RubyInstanceConfig.JIT_LOADING_DEBUG) {
System.err.println("jitted code could not be instantiated for file " + filename + " at class: " + className);
}
}
} catch (IOException ioe) {
// TODO: log something?
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.