Source:
<code>private Plugin loadPlugin(String name, File srcJar, FileSnapshot snapshot) throws IOException, ClassNotFoundException, InvalidPluginException { File tmp; FileInputStream in = new FileInputStream(srcJar); try { tmp = asTemp(in, tempNameFor(name), ".jar", tmpDir); } finally { in.close(); } JarFile jarFile = new JarFile(tmp); boolean keep = false; try { Manifest manifest = jarFile.getManifest(); Plugin.ApiType type = Plugin.getApiType(manifest); Attributes main = manifest.getMainAttributes(); String sysName = main.getValue("Gerrit-Module"); String sshName = main.getValue("Gerrit-SshModule"); String httpName = main.getValue("Gerrit-HttpModule"); <START> String actionName = main.getValue("Gerrit-ActionModule"); <END> if (!Strings.isNullOrEmpty(sshName) && type != Plugin.ApiType.PLUGIN) { throw new InvalidPluginException(String.format( "Using Gerrit-SshModule requires Gerrit-ApiType: %s", Plugin.ApiType.PLUGIN)); } URL[] urls = {tmp.toURI().toURL()}; ClassLoader parentLoader = parentFor(type); ClassLoader pluginLoader = new URLClassLoader(urls, parentLoader); final CleanupHandle cleanupHandle = new CleanupHandle(tmp, jarFile, pluginLoader, cleanupQueue); cleanupHandle.enqueue(); cleanupHandles.put(cleanupHandle, Boolean.TRUE); Class<? extends Module> sysModule = load(sysName, pluginLoader); Class<? extends Module> sshModule = load(sshName, pluginLoader); Class<? extends Module> httpModule = load(httpName, pluginLoader); Class<? extends Module> actionModule = load(actionName, pluginLoader); keep = true; return new Plugin(name, srcJar, snapshot, jarFile, manifest, new File(dataDir, name), type, pluginLoader, sysModule, sshModule, httpModule, actionModule); } finally { if (!keep) { jarFile.close(); } } }</code><technical_language>Bind in system module, aka Gerrit-Module. complexity for deal with</technical_language>

Target:
private Plugin loadPlugin(String name, File srcJar, FileSnapshot snapshot) throws IOException, ClassNotFoundException, InvalidPluginException { File tmp; FileInputStream in = new FileInputStream(srcJar); try { tmp = asTemp(in, tempNameFor(name), ".jar", tmpDir); } finally { in.close(); } JarFile jarFile = new JarFile(tmp); boolean keep = false; try { Manifest manifest = jarFile.getManifest(); Plugin.ApiType type = Plugin.getApiType(manifest); Attributes main = manifest.getMainAttributes(); String sysName = main.getValue("Gerrit-Module"); String sshName = main.getValue("Gerrit-SshModule"); String httpName = main.getValue("Gerrit-HttpModule"); String actionName = main.getValue("Gerrit-ActionModule"); if (!Strings.isNullOrEmpty(sshName) && type != Plugin.ApiType.PLUGIN) { throw new InvalidPluginException(String.format( "Using Gerrit-SshModule requires Gerrit-ApiType: %s", Plugin.ApiType.PLUGIN)); } URL[] urls = {tmp.toURI().toURL()}; ClassLoader parentLoader = parentFor(type); ClassLoader pluginLoader = new URLClassLoader(urls, parentLoader); Class<? extends Module> sysModule = load(sysName, pluginLoader); Class<? extends Module> sshModule = load(sshName, pluginLoader); Class<? extends Module> httpModule = load(httpName, pluginLoader); Class<? extends Module> actionModule = load(actionName, pluginLoader); Plugin plugin = new Plugin(name, pluginUserFactory.create(name), srcJar, snapshot, jarFile, manifest, new File(dataDir, name), type, pluginLoader, sysModule, sshModule, httpModule, actionModule); cleanupHandles.put(plugin, new CleanupHandle(tmp, jarFile)); keep = true; return plugin; } finally { if (!keep) { jarFile.close(); } } }