@Test public void testRunWithContextClassLoaderRunnable() throws Exception { final ClassLoader aPrioriContextClassLoader = Thread.currentThread().getContextClassLoader(); try { final ClassLoader original = new URLClassLoader(new URL[0]); final ClassLoader temp = new URLClassLoader(new URL[0]); Thread.currentThread().setContextClassLoader(original); LambdaUtil.withContextClassLoader(temp, () -> assertSame(temp, Thread.currentThread().getContextClassLoader())); assertSame(original, Thread.currentThread().getContextClassLoader()); } finally { Thread.currentThread().setContextClassLoader(aPrioriContextClassLoader); } }
public static <E extends Throwable> void withContextClassLoader( final ClassLoader cl, final ThrowingRunnable<E> r) throws E { try (TemporaryClassLoaderContext tmpCl = new TemporaryClassLoaderContext(cl)) { r.run(); } }
LambdaUtil { public static <E extends Throwable> void withContextClassLoader( final ClassLoader cl, final ThrowingRunnable<E> r) throws E { try (TemporaryClassLoaderContext tmpCl = new TemporaryClassLoaderContext(cl)) { r.run(); } } }
LambdaUtil { public static <E extends Throwable> void withContextClassLoader( final ClassLoader cl, final ThrowingRunnable<E> r) throws E { try (TemporaryClassLoaderContext tmpCl = new TemporaryClassLoaderContext(cl)) { r.run(); } } private  LambdaUtil(); }
LambdaUtil { public static <E extends Throwable> void withContextClassLoader( final ClassLoader cl, final ThrowingRunnable<E> r) throws E { try (TemporaryClassLoaderContext tmpCl = new TemporaryClassLoaderContext(cl)) { r.run(); } } private  LambdaUtil(); static void applyToAllWhileSuppressingExceptions(
		Iterable<T> inputs,
		ThrowingConsumer<T, ? extends Exception> throwingConsumer); static void withContextClassLoader(
			final ClassLoader cl,
			final ThrowingRunnable<E> r); static R withContextClassLoader(
			final ClassLoader cl,
			final SupplierWithException<R, E> s); }
LambdaUtil { public static <E extends Throwable> void withContextClassLoader( final ClassLoader cl, final ThrowingRunnable<E> r) throws E { try (TemporaryClassLoaderContext tmpCl = new TemporaryClassLoaderContext(cl)) { r.run(); } } private  LambdaUtil(); static void applyToAllWhileSuppressingExceptions(
		Iterable<T> inputs,
		ThrowingConsumer<T, ? extends Exception> throwingConsumer); static void withContextClassLoader(
			final ClassLoader cl,
			final ThrowingRunnable<E> r); static R withContextClassLoader(
			final ClassLoader cl,
			final SupplierWithException<R, E> s);  }