public ClassLoader run() throws IOException { Thread currentThread = Thread.currentThread(); ClassLoader context = currentThread.getContextClassLoader(); try { currentThread.setContextClassLoader(parent); return ClassLoading.getClassLoader(path); } finally { if (context != null) currentThread.setContextClassLoader(context); } } }
public static String getClassAnnotation(Class clas){ try { return ClassLoading.getClassAnnotation(clas); } catch (NoSuchMethodError e){ // Ignore, earlier version of River. } return RMIClassLoader.getClassAnnotation(clas); }
Object readResolve() throws IOException, ClassNotFoundException { return getProvider(read.defaultLoader).resolve(bootstrapProxy, serviceProxy, read.defaultLoader, read.verifierLoader, context); }
/** * Converts this descriptor to a Class instance, loading from codebase * * @param codebase String the codebase to load the class from * @return Class the class this descriptor represents */ public Class toClass(String codebase) throws IOException, ClassNotFoundException { if (name.charAt(0) != ';') { return ClassLoading.loadClass( codebase, name, null, integrity, null); } StringTokenizer st = new StringTokenizer(name, ";"); String[] ifs = new String[st.countTokens()]; for (int i = 0; i < ifs.length; i++) { ifs[i] = st.nextToken(); } return ClassLoading.loadProxyClass( codebase, ifs, null, integrity, null); }
public static Class loadClass(String codebase, String name, ClassLoader defaultLoader, boolean verifyCodebaseIntegrity, ClassLoader verifierLoader) throws MalformedURLException, ClassNotFoundException { try { return ClassLoading.loadClass(codebase, name, defaultLoader, verifyCodebaseIntegrity, verifierLoader); } catch (NoSuchMethodError e){ // Ignore, earlier version of River. } return RMIClassLoader.loadClass(codebase, name, defaultLoader); }
public static Class loadProxyClass(String codebase, String[] interfaceNames, ClassLoader defaultLoader, boolean verifyCodebaseIntegrity, ClassLoader verifierLoader) throws MalformedURLException, ClassNotFoundException { try { return ClassLoading.loadProxyClass(codebase, interfaceNames, defaultLoader, verifyCodebaseIntegrity, verifierLoader); } catch (NoSuchMethodError e){ // Ignore, earlier version of River. } return RMIClassLoader.loadProxyClass(codebase, interfaceNames, defaultLoader); } }
(classObjs[i] = LoadClass.forName(interfaces[i], false, loader)); ClassLoader current = getClassLoader(cl); if (logger.isLoggable(Level.FINEST)) { logger.logp(Level.FINEST,
@Override public S next() throws ServiceConfigurationError { if (!hasNext()) { throw new NoSuchElementException(); } String cn = nextName; nextName = null; try { Class<S> c = LoadClass.forName(cn, true, loader); if (!service.isAssignableFrom(c)) { log.severe("service classloader is " + service.getClass().getClassLoader() + ", provider loader is " + loader); fail(service, "Provider " + cn + " is of incorrect type"); } return c.newInstance(); } catch (ClassNotFoundException x) { fail(service, "Provider " + cn + " not found"); } catch (Exception x) { fail(service, "Provider " + cn + " could not be instantiated: " + x); } return null; /* This cannot happen */ }
if (verifyCodebaseIntegrity && codebase != null) { try { verifyIntegrity(codebase, verifierLoader); } catch (SecurityException e) { verifyException = e;
public static Object create(DynamicProxyCodebaseAccessor proxy, ClassLoader streamLoader, Collection context) throws IOException { Class proxyClass = proxy.getClass(); if (proxy instanceof RemoteMethodControl //JERI && Proxy.isProxyClass(proxyClass) && getProvider(streamLoader).substitute(proxyClass, streamLoader) ) { // REMIND: InvocationHandler must be available locally, for now // it must be an instance of BasicInvocationHandler. InvocationHandler h = Proxy.getInvocationHandler(proxy); return new ProxySerializer( (CodebaseAccessor) Proxy.newProxyInstance(getProxyLoader(proxyClass), BOOTSTRAP_PROXY_INTERFACES, h ), proxy, context ); } return proxy; }
/** * Installs a new RMIClassLoaderSpi provider with the ClassLoader * provided. * * @param providerName fully defined class name of the provider, if null, * a new provider instance will be determined by system properties. * @param providerLoader The class loader to be used to load * provider-configuration files and provider classes, or null if the * system class loader (or, failing that, the bootstrap class loader) * is to be used. * @return true if successful. * @throws SecurityException if caller doesn't have RuntimePermission "getFactory" */ public static boolean installNewProvider( String providerName, ClassLoader providerLoader) { permission.checkGuard(null); synchronized (lock){ return provider(providerName, providerLoader); } }
public Class toClass(String codebase) throws IOException, ClassNotFoundException { Class cls = ClassLoading.loadClass(codebase, name, null, integrity, null); EntryClass local; try { local = ClassMapper.toEntryClassBase(cls).eclass; } catch (MarshalException e) { throw new UnmarshalException("problem obtaining local version of " + toString(), e); } if (hash != local.hash) throw new UnmarshalException("incoming entry type: " + toString() + " is not assignable to the local" + " version of the type: " + local); return cls; }
String codebase = usingCodebaseAnnotations ? annotation : null; return ClassLoading.loadProxyClass(codebase, interfaceNames, defaultLoader,
/** * Annotates the stream descriptor for the class <code>cl</code>. * * <p><code>MarshalOutputStream</code> implements this method as * follows: * * <p>This method invokes {@link RMIClassLoaderSpi#getClassAnnotation * RMIClassLoaderSpi.getClassAnnotation} with <code>cl</code> to get * the appropriate class annotation string value (possibly * <code>null</code>), and then it invokes this stream's {@link * #writeAnnotation writeAnnotation} method with that string to * record the annotation. * * @param cl the class to annotate * * @throws IOException if <code>writeAnnotation</code> throws an * <code>IOException</code> * * @throws NullPointerException if <code>cl</code> is * <code>null</code> **/ @Override protected void annotateClass(Class cl) throws IOException { writeAnnotation(ClassLoading.getClassAnnotation(cl)); }
@Override public Object run() { ClassLoader bcl = base.getClassLoader(); if (bcl == null) { return null; } ClassLoader pcl = bcl.getParent(); Thread t = Thread.currentThread(); ClassLoader ccl = t.getContextClassLoader(); boolean proper = false; try { t.setContextClassLoader(pcl); proper = (ClassLoading.getClassLoader(bcb) == bcl); } catch (MalformedURLException e) { } finally { t.setContextClassLoader(ccl); } if (proper) { try { return Proxy.newProxyInstance( pcl, new Class[]{ProxyTrust.class, RemoteMethodControl.class}, ih); } catch (IllegalArgumentException e) { } } return null; } });
Class result = LoadClass.forName(name, false, cl); Class c = result; do {
public static Object create(ProxyAccessor svc, ClassLoader streamLoader, Collection context) throws IOException{ Object proxy = svc.getProxy(); Class proxyClass = proxy != null ? proxy.getClass() : null; if (proxyClass == null ) LOGGER.log(Level.FINE, "Warning Proxy was null for {0}", svc.getClass()); if (proxy instanceof RemoteMethodControl //JERI && proxy instanceof CodebaseAccessor && Proxy.isProxyClass(proxyClass) && getProvider(streamLoader).substitute(proxyClass, streamLoader) ) { // REMIND: InvocationHandler must be available locally, for now // it must be an instance of BasicInvocationHandler. InvocationHandler h = Proxy.getInvocationHandler(proxy); return new ProxySerializer( (CodebaseAccessor) Proxy.newProxyInstance(getProxyLoader(proxyClass), BOOTSTRAP_PROXY_INTERFACES, h ), svc, context ); } return svc; }
String codebase = usingCodebaseAnnotations ? annotation : null; return ClassLoading.loadProxyClass(codebase, interfaceNames, defaultLoader,
/** * Annotates the stream descriptor for the proxy class * <code>cl</code>. * * <p><code>MarshalOutputStream</code> implements this method as * follows: * * <p>This method invokes {@link RMIClassLoaderSpi#getClassAnnotation * RMIClassLoaderSpi.getClassAnnotation} with <code>cl</code> to get * the appropriate class annotation string value (possibly * <code>null</code>), and then it invokes this stream's {@link * #writeAnnotation writeAnnotation} method with that string to * record the annotation. * * @param cl the proxy class to annotate * * @throws IOException if <code>writeAnnotation</code> throws an * <code>IOException</code> * * @throws NullPointerException if <code>cl</code> is * <code>null</code> **/ @Override protected void annotateProxyClass(Class cl) throws IOException { writeAnnotation(ClassLoading.getClassAnnotation(cl)); }
private void writeAnnotation(final Class c) throws IOException { String cb = ClassLoading.getClassAnnotation(c); writeObject(cb); if (bcb.equals(cb)) { AccessController.doPrivileged(new PrivilegedAction() { @Override public Object run() { if (c.getClassLoader() != bcl) { replace = true; } return null; } }); } } }