Created
January 4, 2011 04:22
-
-
Save qmx/764386 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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