@Override protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { return Class.forName(desc.getName(), true, runtime.getJRubyClassLoader()); } }
@Override protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { return Class.forName(desc.getName(), true, runtime.getJRubyClassLoader()); } }
protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { String name = desc.getName(); try { return Class.forName(name, false, runtime.getJRubyClassLoader()); } catch (ClassNotFoundException ex) { return super.resolveClass(desc); } } }
protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { String name = desc.getName(); try { return Class.forName(name, false, runtime.getJRubyClassLoader()); } catch (ClassNotFoundException ex) { return super.resolveClass(desc); } } }
public static URL getResourceURL(Ruby runtime, String location) { if (location.startsWith(URI_CLASSLOADER)) { return runtime.getJRubyClassLoader().getResource(location.substring(URI_CLASSLOADER.length() + 1)); } try { return new URL(location.replaceFirst("^" + URI, "")); } catch (MalformedURLException e) { throw new AssertionError("BUG in " + URLResource.class, e); } }
public static URL getResourceURL(Ruby runtime, String location) { if (location.startsWith(URI_CLASSLOADER)) { return runtime.getJRubyClassLoader().getResource(location.substring(URI_CLASSLOADER.length() + 1)); } try { return new URL(location.replaceFirst("^" + URI, "")); } catch (MalformedURLException e) { throw new AssertionError("BUG in " + URLResource.class, e); } }
public Class loadJavaClass(String className) throws ClassNotFoundException { Class primitiveClass; if ((primitiveClass = PRIMITIVE_CLASSES.get(className)) == null) { if (!Ruby.isSecurityRestricted()) { return Class.forName(className, true, runtime.getJRubyClassLoader()); } return Class.forName(className); } return primitiveClass; }
public Class loadJavaClass(String className) throws ClassNotFoundException { Class primitiveClass; if ((primitiveClass = PRIMITIVE_CLASSES.get(className)) == null) { if (!Ruby.isSecurityRestricted()) { return Class.forName(className, true, runtime.getJRubyClassLoader()); } return Class.forName(className); } return primitiveClass; }
/** * @return the configured {@link org.jruby.runtime.profile.ProfilingService} class. */ @SuppressWarnings( "unchecked" ) private Class<? extends ProfilingService> loadServiceClass() { ClassLoader cl = getRuntime().getJRubyClassLoader(); try { return (Class<? extends ProfilingService>) cl.loadClass( getServiceClassName() ); } catch (ClassNotFoundException e) { throw new RuntimeException( "Can't load service service class. " + e.getClass().getSimpleName() + ": " + e.getMessage() ); } }
public static JavaProxyClass getProxyClass(Ruby runtime, Class superClass, Class[] interfaces, Set names) throws InvocationTargetException { Ruby save = runtimeTLS.get(); runtimeTLS.set(runtime); try { ClassLoader loader = runtime.getJRubyClassLoader(); return runtime.getJavaProxyClassFactory().newProxyClass(runtime, loader, null, superClass, interfaces, names); } finally { runtimeTLS.set(save); } }
public void defineAnnotatedMethod(Class clazz, String name) { // FIXME: This is probably not very efficient, since it loads all methods for each call boolean foundMethod = false; for (Method method : clazz.getDeclaredMethods()) { if (method.getName().equals(name) && defineAnnotatedMethod(method, MethodFactory.createFactory(getRuntime().getJRubyClassLoader()))) { foundMethod = true; } } if (!foundMethod) { throw new RuntimeException("No JRubyMethod present for method " + name + "on class " + clazz.getName()); } }
public void defineAnnotatedMethod(Class clazz, String name) { // FIXME: This is probably not very efficient, since it loads all methods for each call boolean foundMethod = false; for (Method method : clazz.getDeclaredMethods()) { if (method.getName().equals(name) && defineAnnotatedMethod(method, MethodFactory.createFactory(getRuntime().getJRubyClassLoader()))) { foundMethod = true; } } if (!foundMethod) { throw new RuntimeException("No JRubyMethod present for method " + name + "on class " + clazz.getName()); } }
private void doSetContextClassLoader(Ruby runtime) { // set thread context JRuby classloader here, for the main thread try { Thread.currentThread().setContextClassLoader(runtime.getJRubyClassLoader()); } catch (SecurityException se) { // can't set TC classloader if (runtime.getInstanceConfig().isVerbose()) { config.getError().println("WARNING: Security restrictions disallowed setting context classloader for main thread."); } } }
private void doSetContextClassLoader(Ruby runtime) { // set thread context JRuby classloader here, for the main thread try { Thread.currentThread().setContextClassLoader(runtime.getJRubyClassLoader()); } catch (SecurityException se) { // can't set TC classloader if (runtime.getInstanceConfig().isVerbose()) { config.getError().println("WARNING: Security restrictions disallowed setting context classloader for main thread."); } } }
@JRubyMethod(module = true, rest = true, optional = 1) // (loader = JRuby.runtime.jruby_class_loader) public static IRubyObject set_context_class_loader(ThreadContext context, IRubyObject recv, IRubyObject[] args) { final ClassLoader loader; if (args.length == 0 || args[0] == context.nil) { loader = context.runtime.getJRubyClassLoader(); } else { loader = JavaUtil.unwrapJavaObject(args[0]); } java.lang.Thread.currentThread().setContextClassLoader(loader); return Java.wrapJavaObject(context.runtime, loader); // reference0 }
/** * Try to compile the code associated with the given Node, returning an * instance of the successfully-compiled Script or null if the script could * not be compiled. * * @param node The node to attempt to compiled * @return an instance of the successfully-compiled Script, or null. */ public Script tryCompile(Node node) { return tryCompile(node, null, new JRubyClassLoader(getJRubyClassLoader()), false); }
/** * Try to compile the code associated with the given Node, returning an * instance of the successfully-compiled Script or null if the script could * not be compiled. * * @param node The node to attempt to compiled * @return an instance of the successfully-compiled Script, or null. */ public Script tryCompile(Node node) { return tryCompile((RootNode) node, new ClassDefiningJRubyClassLoader(getJRubyClassLoader())).script(); }
public void load(Ruby runtime, boolean wrap) { try { URL jarFile = resource.getURL(); // Make Java class files in the jar reachable from Ruby runtime.getJRubyClassLoader().addURL(jarFile); } catch (IOException e) { throw runtime.newIOErrorFromException(e); } } }
public void load(Ruby runtime, boolean wrap) { try { URL jarFile = resource.getURL(); // Make Java class files in the jar reachable from Ruby runtime.getJRubyClassLoader().addURL(jarFile); } catch (IOException e) { throw runtime.newIOErrorFromException(e); } } }
@JRubyMethod public IRubyObject each(Block block) { final ThreadContext context = getRuntime().getCurrentContext(); URL[] urls = context.runtime.getJRubyClassLoader().getURLs(); for(int i=0,j=urls.length;i<j;i++) { block.yield(context, context.runtime.newString(urls[i].toString())); } return context.nil; }