public int run(String launcherVersion, String launcherMd5, ServerUrlGenerator urlGenerator, Map<String, String> environmentVariables, Map context) { String agentProcessParentClassName = JarUtil.getManifestKey(Downloader.AGENT_BINARY_JAR, GO_AGENT_BOOTSTRAP_CLASS); String tempDirSuffix = new BigInteger(64, new SecureRandom()).toString(16) + "-" + Downloader.AGENT_BINARY_JAR; File tempDir = new File(FileUtil.TMP_PARENT_DIR, "deps-" + tempDirSuffix); try { try (URLClassLoader urlClassLoader = JarUtil.getClassLoaderFromJar(Downloader.AGENT_BINARY_JAR, jarEntryFilter(), tempDir, this.getClass().getClassLoader())) { Class<?> aClass = urlClassLoader.loadClass(agentProcessParentClassName); AgentProcessParent agentProcessParent = (AgentProcessParent) aClass.getDeclaredConstructor().newInstance(); return agentProcessParent.run(launcherVersion, launcherMd5, urlGenerator, environmentVariables, context); } catch (ReflectiveOperationException | IOException e) { throw new RuntimeException(e); } } finally { FileUtils.deleteQuietly(tempDir); } }