Skip to content

@qmx /ClassCache.java
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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;
}
// 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?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.