Skip to content

fix: return null from TransformerManager when no transformer changes the class - #3285

Merged
hengyunabc merged 1 commit into
alibaba:masterfrom
adityaanikam:fix-3283-transformer-return-null
Nov 4, 2026
Merged

hengyunabc merged 1 commit into
alibaba:masterfrom
adityaanikam:fix-3283-transformer-return-null

Conversation

@adityaanikam

Copy link
Copy Markdown
Contributor

Fixes #3283

The transformers that TransformerManager registers returned the input classfileBuffer when no transformer had changed the class. For a retransform-capable agent, HotSpot treats a non-null return as a modification and keeps a copy of the original class bytes (JvmtiClassFileLoadHookPoster::post_to_env), so every loaded class kept an extra copy in native memory. Both the retransform-capable and the lazy transformer now return null when nothing changed.

Added TransformerManagerTest. The three cases that expect null fail without the change. I could not run the core module build on Windows because arthas-vmtool needs a native compile, so I ran the new test class against the same sources with JDK 21 and --release 8.

Copilot AI balanced review requested due to automatic review settings November 3, 2026 11:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@hengyunabc
hengyunabc merged commit 6d97217 into alibaba:master Nov 4, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TransformerManager 在无增强时仍返回 classfileBuffer,导致 JVM 为每个类常驻缓存一份原始字节码

3 participants