luckybilly / luckybilly/AutoRegister
实现类收集成功,注入失败
Nobody has claimed this yet.
- Dominant language
- Groovy
- Stars
- 1.1k
- Forks
- 171
- PR merge metrics
- No merged PRs in 30d
Description
在使用时发现了一个问题:
在管理类中,使用静态代码注入的方式时,如果持有实现类的引用不进行初始化,虽然可以收集到实现类,但是注入会失败。如:
可以注入成功的写法
```
public class TestManager {
private static List testList = new ArrayList<>();
private static void inject(IInit baseTest) {
if (baseTest != null) {
testList.add(baseTest);
}
}
}
//构建成功后查看源码,可以看到插入的静态代码块
```
注入失败的写法:
```
public class TestManager {
private static List testList;
private static void inject(IInit baseTest) {
if (baseTest != null) {
if (testList == null) {
testList = new ArrayList<>();
}
testList.add(baseTest);
}
}
}
//构建成功后查看源码,没有插入的静态代码块
```
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source files or tests are named. Start by tracing the bytecode-instrumentation or Gradle entry point that discovers implementation classes and generates manager injection code, then reproduce both manager field forms from the issue. Done means the uninitialized static list case is collected and injected successfully, with a regression test covering both examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, groovy, java
- Domain
- build-system, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100