From de848fbd16c3a991e499f90885697e094c26bd77 Mon Sep 17 00:00:00 2001 From: Victoria Ostrovskaya Date: Tue, 9 Sep 2025 16:47:13 +0300 Subject: [PATCH 1/3] feat: add ThreadingAssertions markers and ByteBuddy compatibility --- .../agent/ThreadingHighlighterAgent.java | 17 ++++++++ .../highlighter/common/marker/Markers.java | 40 ++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/agent/src/main/java/io/github/vicitori/threading/highlighter/agent/ThreadingHighlighterAgent.java b/agent/src/main/java/io/github/vicitori/threading/highlighter/agent/ThreadingHighlighterAgent.java index 835afd0..429cb9a 100644 --- a/agent/src/main/java/io/github/vicitori/threading/highlighter/agent/ThreadingHighlighterAgent.java +++ b/agent/src/main/java/io/github/vicitori/threading/highlighter/agent/ThreadingHighlighterAgent.java @@ -35,12 +35,23 @@ public static void agentmain(String agentArgs, Instrumentation inst) { install(inst); } + // Byte Buddy refuses class file versions newer than it officially knows (e.g. the + // Java 25 bytecode shipped by the latest JBR) unless experimental mode is enabled. + // Turning it on keeps the agent working on bleeding-edge IDE platforms instead of + // failing every instrumentation with IllegalArgumentException. The literal is + // relocated by the shadow jar together with the rest of net.bytebuddy, so it + // matches the property name Byte Buddy actually reads at runtime. + private static final String BYTE_BUDDY_EXPERIMENTAL_PROPERTY = "net.bytebuddy.experimental"; + private static void install(Instrumentation inst) { if (!INSTALLED.compareAndSet(false, true)) { AgentLog.info("Agent already installed, skipping duplicate initialization"); return; } + // must run before any Byte Buddy class file version probing below + enableByteBuddyExperimentalIfUnset(); + MarkerAdvice.setWriter(new TraceWriter()); AgentBuilder agent = configureAgent(); List markers = Markers.getAll(); @@ -50,6 +61,12 @@ private static void install(Instrumentation inst) { } } + private static void enableByteBuddyExperimentalIfUnset() { + if (System.getProperty(BYTE_BUDDY_EXPERIMENTAL_PROPERTY) == null) { + System.setProperty(BYTE_BUDDY_EXPERIMENTAL_PROPERTY, "true"); + } + } + private static void instrumentMarker(AgentBuilder agent, MarkerInfo marker, Instrumentation inst) { agent.type(ElementMatchers.named(marker.getClassFqn())) .transform((builder, typeDescription, classLoader, module, protectionDomain) -> diff --git a/common/src/main/java/io/github/vicitori/threading/highlighter/common/marker/Markers.java b/common/src/main/java/io/github/vicitori/threading/highlighter/common/marker/Markers.java index 03ad385..0e51b54 100644 --- a/common/src/main/java/io/github/vicitori/threading/highlighter/common/marker/Markers.java +++ b/common/src/main/java/io/github/vicitori/threading/highlighter/common/marker/Markers.java @@ -23,9 +23,16 @@ * recurse into itself or instrument non-assertion code. Extending coverage is a * matter of adding an entry here (the agent, filter, trace format and plugin are * all marker-agnostic). + * + *

Since platform build ~233 the internal calling code increasingly calls + * {@code ThreadingAssertions} directly instead of going through + * {@code ApplicationImpl}. Both classes are instrumented so the agent captures + * markers regardless of which path the platform takes. */ public final class Markers { + // --- ApplicationImpl markers (legacy path, still used by plugin code) --- + public static final MarkerInfo SLOW_OPERATION = new MarkerInfo( "com.intellij.util.SlowOperations", "assertSlowOperationsAreAllowed", @@ -56,7 +63,38 @@ public final class Markers { "Write Access", "This code requires write access and must run inside a write action on the EDT (see Application.runWriteAction())."); - private static final List ALL = List.of(SLOW_OPERATION, NON_EDT, EDT, READ_ACCESS, WRITE_ACCESS); + // --- ThreadingAssertions markers (direct path used by platform internals) --- + + private static final String THREADING_ASSERTIONS_CLASS = + "com.intellij.util.concurrency.ThreadingAssertions"; + + public static final MarkerInfo EDT_DIRECT = new MarkerInfo( + THREADING_ASSERTIONS_CLASS, + "assertEventDispatchThread", + "EDT Thread", + "This code must run on the EDT (Event Dispatch Thread). UI operations are allowed."); + + public static final MarkerInfo NON_EDT_DIRECT = new MarkerInfo( + THREADING_ASSERTIONS_CLASS, + "assertBackgroundThread", + "Non-EDT Thread", + "This code must NOT run on the EDT. Background/pooled thread required."); + + public static final MarkerInfo READ_ACCESS_DIRECT = new MarkerInfo( + THREADING_ASSERTIONS_CLASS, + "assertReadAccess", + "Read Access", + "This code requires read access and must run inside a read action (see Application.runReadAction())."); + + public static final MarkerInfo WRITE_ACCESS_DIRECT = new MarkerInfo( + THREADING_ASSERTIONS_CLASS, + "assertWriteAccess", + "Write Access", + "This code requires write access and must run inside a write action on the EDT (see Application.runWriteAction())."); + + private static final List ALL = List.of( + SLOW_OPERATION, NON_EDT, EDT, READ_ACCESS, WRITE_ACCESS, + EDT_DIRECT, NON_EDT_DIRECT, READ_ACCESS_DIRECT, WRITE_ACCESS_DIRECT); public static List getAll() { return ALL; From b9c6ff7dc25d347130639d1ae835aafe1cc52560 Mon Sep 17 00:00:00 2001 From: Victoria Ostrovskaya Date: Tue, 9 Sep 2025 17:12:41 +0300 Subject: [PATCH 2/3] build: target IntelliJ IDEA Ultimate 2025.3.1 --- plugin/build.gradle.kts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index 3e5d78e..3549e58 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -17,8 +17,7 @@ repositories { dependencies { implementation(project(":common")) intellijPlatform { - // Target the local test IDE (IntelliJ IDEA Community 2025.1, build 251) - intellijIdeaCommunity("2025.1.1.1") + intellijIdeaUltimate("2025.3.1") bundledPlugin("org.jetbrains.kotlin") } @@ -35,8 +34,8 @@ dependencies { intellijPlatform { pluginConfiguration { ideaVersion { - sinceBuild = "251" - untilBuild = "251.*" + sinceBuild = "253" + untilBuild = "253.*" } } From cc62b91473c03522a5c7fa650fa696d97bc4f398 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2026 23:04:39 +0000 Subject: [PATCH 3/3] build(deps): bump org.junit:junit-bom from 5.11.3 to 6.1.3 Bumps [org.junit:junit-bom](https://github.com/junit-team/junit-framework) from 5.11.3 to 6.1.3. - [Release notes](https://github.com/junit-team/junit-framework/releases) - [Commits](https://github.com/junit-team/junit-framework/compare/r5.11.3...r6.1.3) --- updated-dependencies: - dependency-name: org.junit:junit-bom dependency-version: 6.1.3 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- agent/build.gradle.kts | 2 +- common/build.gradle.kts | 2 +- plugin/build.gradle.kts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/agent/build.gradle.kts b/agent/build.gradle.kts index f27ed86..46eab17 100644 --- a/agent/build.gradle.kts +++ b/agent/build.gradle.kts @@ -17,7 +17,7 @@ dependencies { // on it keeps the agent's classpath isolated from the host IDE. implementation(project(":common")) - testImplementation(platform("org.junit:junit-bom:5.11.3")) + testImplementation(platform("org.junit:junit-bom:6.1.3")) testImplementation("org.junit.jupiter:junit-jupiter") testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/common/build.gradle.kts b/common/build.gradle.kts index dbea04d..e465872 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -9,7 +9,7 @@ java { } dependencies { - testImplementation(platform("org.junit:junit-bom:5.11.3")) + testImplementation(platform("org.junit:junit-bom:6.1.3")) testImplementation("org.junit.jupiter:junit-jupiter") testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index 3549e58..73804d1 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -22,7 +22,7 @@ dependencies { } // Pure-logic unit tests (no platform runtime needed) - testImplementation(platform("org.junit:junit-bom:5.11.3")) + testImplementation(platform("org.junit:junit-bom:6.1.3")) testImplementation("org.junit.jupiter:junit-jupiter") testRuntimeOnly("org.junit.platform:junit-platform-launcher") // IntelliJ Platform test harness expects JUnit 4 on the classpath; the vintage