[debugger] IJPL-240834 Class memory agent proxy class loading

- agent in a separate module
- caller module loads classses

GitOrigin-RevId: b240eebaffd1558b253edddb63fc895e7d52478a
This commit is contained in:
Maksim Zuev
2026-04-28 20:53:01 +00:00
committed by intellij-monorepo-bot
parent ab6ee27cc7
commit 52deb0f79b
11 changed files with 25 additions and 25 deletions
@@ -1,5 +1,5 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.debugger.memory.agent.extractor
// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.debugger.memory.agent
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.util.io.FileUtilRt
@@ -17,7 +17,7 @@ object AgentExtractor {
if (!::extractedFile.isInitialized || !extractedFile.exists() || extractedFile.lastModified() != lastModified) {
val agentFileName = "${agentType.prefix}memory_agent${agentType.suffix}"
val file = FileUtilRt.createTempFile(directory.toFile(), "${agentType.prefix}memory_agent", agentType.suffix, true)
val inputStream = AgentExtractor::class.java.classLoader.getResourceAsStream("bin/$agentFileName") ?: throw FileNotFoundException(agentFileName)
val inputStream = classFromAgentJar().classLoader.getResourceAsStream("bin/$agentFileName") ?: throw FileNotFoundException(agentFileName)
inputStream.use { input ->
Files.newOutputStream(file.toPath()).use { output ->
FileUtil.copy(input, output)
@@ -10,7 +10,6 @@ import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
import com.intellij.debugger.impl.ClassLoadingUtils;
import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.debugger.memory.agent.extractor.ProxyExtractor;
import com.intellij.debugger.memory.agent.parsers.BooleanParser;
import com.intellij.debugger.memory.agent.parsers.ErrorCodeParser;
import com.intellij.debugger.memory.agent.parsers.GcRootsPathsParser;
@@ -408,7 +407,7 @@ public class IdeaNativeAgentProxyMirror {
}
private static byte @NotNull [] readUtilityClass() {
return new ProxyExtractor().extractProxy();
return ProxyExtractorKt.extractProxy();
}
private static @Nullable ReferenceType loadUtilityClass(@NotNull EvaluationContextImpl evaluationContext) throws EvaluateException {
@@ -3,7 +3,6 @@ package com.intellij.debugger.memory.agent;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
import com.intellij.debugger.memory.agent.extractor.AgentExtractor;
import com.intellij.debugger.memory.ui.JavaReferenceInfo;
import com.intellij.debugger.memory.ui.SizedReferenceInfo;
import com.intellij.execution.JavaExecutionUtil;
@@ -0,0 +1,14 @@
// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.debugger.memory.agent
internal fun classFromAgentJar(): Class<*> {
return com.intellij.memory.agent.MemoryAgent::class.java
}
internal fun extractProxy(): ByteArray {
val resourcePath = "com/intellij/memory/agent/IdeaNativeAgentProxy.class"
val stream = classFromAgentJar().classLoader.getResourceAsStream(resourcePath)
?: error("Cannot load memory agent proxy class $resourcePath")
return stream.use { it.readAllBytes() }
}
+3 -4
View File
@@ -14,11 +14,10 @@ jvm_library(
srcs = glob(["src/**/*.kt", "src/**/*.java", "src/**/*.form"], allow_empty = True),
resources = [":java-debugger-memory-agent_resources"],
deps = [
"//platform/util",
"//platform/backend",
"@lib//:java-debugger-memory-agent-debugger-memory-agent",
"@lib//:kotlin-stdlib",
]
],
exports = ["@lib//:java-debugger-memory-agent-debugger-memory-agent"]
)
jvm_library(
@@ -26,9 +25,9 @@ jvm_library(
module_name = "intellij.java.debugger.memory.agent",
visibility = ["//visibility:public"],
srcs = glob([], allow_empty = True),
exports = ["@lib//:java-debugger-memory-agent-debugger-memory-agent"],
runtime_deps = [
":java-debugger-memory-agent",
"//platform/util:util_test_lib",
"//platform/backend:backend_test_lib",
]
)
@@ -8,9 +8,8 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="intellij.platform.util" />
<orderEntry type="module" module-name="intellij.platform.backend" />
<orderEntry type="module-library">
<orderEntry type="module-library" exported="">
<library name="debugger-memory-agent" type="repository">
<properties maven-id="org.jetbrains.intellij.deps:debugger-memory-agent:1.0.51">
<verification>
@@ -28,6 +27,5 @@
</SOURCES>
</library>
</orderEntry>
<orderEntry type="library" name="kotlin-stdlib" level="project" />
</component>
</module>
@@ -1,7 +0,0 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.debugger.memory.agent.extractor
class ProxyExtractor {
fun extractProxy(): ByteArray =
ProxyExtractor::class.java.classLoader.getResourceAsStream("com/intellij/memory/agent/IdeaNativeAgentProxy.class")!!.readAllBytes()
}
@@ -0,0 +1,3 @@
package com.intellij.memory.agent;
/* this file is added as a workaround for IJPL-103 */
-3
View File
@@ -45,7 +45,6 @@ jvm_library(
"//java/execution/impl",
"//java/debugger/impl",
"//java/debugger/backend",
"//java/debugger/memory-agent:java-debugger-memory-agent",
"//uast/uast-java-ide:java-uast-ide",
"@community//build:dependency-graph",
],
@@ -85,7 +84,6 @@ jvm_library(
"//java/execution/impl",
"//java/debugger/impl",
"//java/debugger/backend",
"//java/debugger/memory-agent:java-debugger-memory-agent",
"//uast/uast-java-ide:java-uast-ide",
"@community//build:dependency-graph",
"//platform/backend",
@@ -134,7 +132,6 @@ jvm_library(
"//java/execution/impl:impl_test_lib",
"//java/debugger/impl:impl_test_lib",
"//java/debugger/backend:backend_test_lib",
"//java/debugger/memory-agent:java-debugger-memory-agent_test_lib",
"//uast/uast-java-ide:java-uast-ide_test_lib",
"@community//build:dependency-graph_test_lib",
"//platform/backend:backend_test_lib",
@@ -43,7 +43,6 @@
<orderEntry type="module" module-name="intellij.java.execution.impl" exported="" scope="RUNTIME" />
<orderEntry type="module" module-name="intellij.java.debugger.impl" exported="" scope="RUNTIME" />
<orderEntry type="module" module-name="intellij.java.debugger.impl.backend" exported="" scope="RUNTIME" />
<orderEntry type="module" module-name="intellij.java.debugger.memory.agent" exported="" scope="RUNTIME" />
<orderEntry type="module" module-name="intellij.java.uast.ide" exported="" scope="RUNTIME" />
<orderEntry type="module" module-name="intellij.platform.jps.build.dependencyGraph" exported="" scope="RUNTIME" />
<orderEntry type="module" module-name="intellij.platform.backend" scope="RUNTIME" />
@@ -29,7 +29,6 @@
<module name="intellij.java.debugger"/>
<module name="intellij.java.debugger.impl"/>
<module name="intellij.java.debugger.impl.backend"/>
<module name="intellij.java.debugger.memory.agent"/>
<module name="intellij.java.execution"/>
<module name="intellij.java.execution.impl"/>
<module name="intellij.java.impl"/>