+ public static <V> V withClassLoaderAndLock(final ClassLoader cls, final Lock lock, final Callable<V> function) throws Exception {
+ checkNotNull(lock, "Lock should not be null");
+
+ lock.lock();
+ try {
+ return withClassLoader(cls, function);
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ /**
+ * @deprecated Use one of the other utility methods.
+ */
+ @Deprecated
+ public static <V> V withClassLoaderAndLock(final ClassLoader cls, final Optional<Lock> lock, final Callable<V> function) throws Exception {
+ if (lock.isPresent()) {
+ return withClassLoaderAndLock(cls, lock.get(), function);
+ } else {
+ return withClassLoader(cls, function);
+ }
+ }
+
+ public static Object construct(final Constructor<? extends Object> constructor, final List<Object> objects)