дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-30 06:12:33 +02:00
Adds a Memory tab to the Debug tool window for JVM sessions: loaded classes with instance counts and shallow sizes (with deltas between refreshes), read over the HotSpot attach listener (`GC.class_histogram`), falling back to counting reachable objects through the debugger on JDKs that cannot answer while suspended. While paused, a class's instances, an instance's fields and its referrers are listed through a JDWP link (the Kotlin adapter's path, and a jdtls bundle `java/jvm-inspect` for java-debug). Debug launches started by the IDE get `-XX:+StartAttachListener` unless the user's VM options decide otherwise (not on Windows). New crates: ide-jdwp, ide-jvm-attach, ide-jvm-inspect. The bundled jar rebuilds byte-for-byte from build.py against the pinned JDT LS plugins. Co-authored-by: ntbang0901 <[email protected]>
51 рядки
2.4 KiB
TypeScript
51 рядки
2.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { formatJvmValue, objectRef, refKey } from "../memory/values";
|
|
|
|
describe("formatJvmValue", () => {
|
|
it("formats values without calling toString", () => {
|
|
expect(formatJvmValue({ kind: "object", id: 12, typeName: "com.x.Order" })).toBe("Order@12");
|
|
expect(formatJvmValue({ kind: "array", id: 3, typeName: "java.lang.String[][]", length: 2 })).toBe("String[][2]");
|
|
expect(formatJvmValue({ kind: "string", id: 4, text: 'a"b', length: 3 })).toBe('"a\\"b"');
|
|
expect(formatJvmValue({ kind: "string", id: 5, text: null, length: 50000000 })).toBe("String (50,000,000 chars)");
|
|
expect(formatJvmValue({ kind: "boxed", id: 6, typeName: "java.lang.Integer", text: "42" })).toBe("42");
|
|
});
|
|
|
|
it("shows null and primitives as their text", () => {
|
|
expect(formatJvmValue({ kind: "null" })).toBe("null");
|
|
expect(formatJvmValue({ kind: "primitive", typeName: "int", text: "7" })).toBe("7");
|
|
});
|
|
|
|
it("keeps the nested-class marker and names a default-package class as is", () => {
|
|
expect(formatJvmValue({ kind: "object", id: 1, typeName: "com.x.Outer$Inner" })).toBe("Outer$Inner@1");
|
|
expect(formatJvmValue({ kind: "object", id: 2, typeName: "Main" })).toBe("Main@2");
|
|
});
|
|
|
|
it("writes an array's length after its element type", () => {
|
|
expect(formatJvmValue({ kind: "array", id: 3, typeName: "int[]", length: 3 })).toBe("int[3]");
|
|
expect(formatJvmValue({ kind: "array", id: 3, typeName: "int[]", length: 0 })).toBe("int[0]");
|
|
});
|
|
});
|
|
|
|
describe("objectRef", () => {
|
|
it("pairs the generation with the id of a value that has one", () => {
|
|
expect(objectRef(2, { kind: "object", id: 7, typeName: "a.B" })).toEqual({ generation: 2, id: 7 });
|
|
expect(objectRef(2, { kind: "string", id: 8, text: "x", length: 1 })).toEqual({ generation: 2, id: 8 });
|
|
expect(objectRef(2, { kind: "boxed", id: 9, typeName: "java.lang.Long", text: "1" })).toEqual({
|
|
generation: 2,
|
|
id: 9,
|
|
});
|
|
expect(objectRef(2, { kind: "array", id: 10, typeName: "int[]", length: 1 })).toEqual({ generation: 2, id: 10 });
|
|
});
|
|
|
|
it("has no reference for null and primitives", () => {
|
|
expect(objectRef(2, { kind: "null" })).toBeNull();
|
|
expect(objectRef(2, { kind: "primitive", typeName: "int", text: "1" })).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe("refKey", () => {
|
|
it("joins generation and id", () => {
|
|
expect(refKey({ generation: 2, id: 7 })).toBe("2:7");
|
|
});
|
|
});
|