void (JavaParameters parameters, @Nullable Project project) { if (AsyncStacksUtils.isAgentEnabled()) { String prefix = "-javaagent:"; ParametersList parametersList = parameters.getVMParametersList(); if (!ContainerUtil.exists(parametersList.getParameters(), p -> p.startsWith(prefix) && p.contains(AGENT_JAR_NAME))) { Sdk jdk = parameters.getJdk(); if (jdk != null) { JavaSdkVersion sdkVersion = JavaSdk.getInstance().getVersion(jdk); if (sdkVersion != null && sdkVersion.isAtLeast(JavaSdkVersion.JDK_1_7)) { Path agentArtifactPath; Path classesRoot = Path.of(PathUtil.getJarPathForClass(DebuggerManagerImpl.class)); // isDirectory(classesRoot) is used instead of `PluginManagerCore.isRunningFromSources()` // because we want to use installer's layout when running "IDEA (dev build)" run configuration // where the layout is quite the same as in installers. // but `PluginManagerCore.isRunningFromSources()` still returns `true` in this case if (Files.isDirectory(classesRoot)) { // Code runs from IDEA run configuration (code from .class file in out/ directory) try { // The agent file must have a fixed name (AGENT_JAR_NAME) which is mentioned in MANIFEST.MF inside Path debuggerAgentDir = FileUtil.createTempDirectory(new File(PathManager.getTempPath()), "debugger-agent", "", true).toPath(); agentArtifactPath = debuggerAgentDir.resolve(AGENT_JAR_NAME); Path communityRoot = Path.of(PathManager.getCommunityHomePath()); Path iml = BuildDependenciesJps.getProjectModule(communityRoot, "intellij.java.debugger.agent.holder"); Path downloadedAgent = BuildDependenciesJps.getModuleLibrarySingleRoot( iml, "debugger-agent", BuildDependenciesConstants.INTELLIJ_DEPENDENCIES_URL, new BuildDependenciesCommunityRoot(Path.of(PathManager.getCommunityHomePath()))); Files.copy(downloadedAgent, agentArtifactPath); } catch (IOException e) { throw new RuntimeException(e); } } else { agentArtifactPath = classesRoot.resolveSibling("rt").resolve(AGENT_JAR_NAME); } if (Files.exists(agentArtifactPath)) { String agentPath = JavaExecutionUtil.handleSpacesInAgentPath(agentArtifactPath.toAbsolutePath().toString(), "captureAgent", null, f -> f.getName().startsWith("debugger-agent")); if (agentPath != null) { try (AccessToken ignore = SlowOperations.knownIssue("IDEA-307303, EA-835503")) { parametersList.add(prefix + agentPath + generateAgentSettings(project)); } } } else { LOG.error("Capture agent not found: " + agentArtifactPath); } } else { LOG.warn("Capture agent is not supported for JRE " + sdkVersion); } } } } }