alibaba / alibaba/one-java-agent

在 addTransformer 时,不设置 canRetransform 为 true,会有一部分类不经过 ClassFileTransformer 处理

Open
#35 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
579
Forks
128
PR merge metrics
No merged PRs in 30d

Description

正常来说,一个普通的 java agent,如果是以 `-javaagent:` 方式启动,注册 ClassFileTransformer 之后,后续加载的类都会经过注册的 ClassFileTransformer 处理。

但实际发现,有部分类并不会被处理。只有注册时设置`canRetransform`为true时,才会被处理。

比如这个类:`org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory` 。

```
Instrumentation#addTransformer(ClassFileTransformer transformer, boolean canRetransform);
```

记录一下现象。

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the behavior described for org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory using a Java agent started with -javaagent:. Start by comparing Instrumentation#addTransformer(ClassFileTransformer, boolean) with registration using canRetransform set to true. Done means the observed difference is explained and the affected class is consistently handled, with a regression test if the repository provides a suitable test location.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.