if (loader!=origin.get()) {
lock.readLock().unlock();
lock.writeLock().lock();
try {
final List<ExtensionModule> modules = new LinkedList<ExtensionModule>();
ExtensionModuleScanner scanner = new ExtensionModuleScanner(new ExtensionModuleScanner.ExtensionModuleListener() {
public void onModule(final ExtensionModule module) {
boolean skip = false;
for (ExtensionModule extensionModule : modules) {
if (extensionModule.getName().equals(module.getName())) {
skip = true;
break;
}
}
if (!skip) modules.add(module);
}
}, loader);
scanner.scanClasspathModules();
cachedMethods = getDGMMethods(modules);
origin = new WeakReference<ClassLoader>(loader);
lock.readLock().lock();
} finally {
lock.writeLock().unlock();