alibaba / alibaba/arthas

jad反编译经过byte-buddy增强后的类信息不正确

Open
#1,964 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
37.5k
Forks
7.6k
Avg merge
1d 22h
Merged PRs (30d)
4

Description

- [x] 我已经在 [issues](https://github.com/alibaba/arthas/issues) 里搜索,没有重复的issue。

### 环境信息

* `arthas-boot.jar` 或者 `as.sh` 的版本:
* Arthas 版本: 3.5.4
* 操作系统版本: mac os BigSur 11.2.3
* 目标进程的JVM版本: 1.8.0_261
* 执行`arthas-boot`的版本: xxx

### 重现问题的步骤

被增强的目标方法
```java
int id = 1;

@RequestMapping("throwable")
public String testThrowable() {
id++;
if (id % 2 == 0) {
throw new IllegalArgumentException("illegal argument");
} else {
return "normal";
}
}
```
byte-buddy增强的逻辑

```java
public class ThrowableInterceptor {

@Advice.OnMethodExit(onThrowable = Throwable.class)
public static void onMethodExit(@Advice.Thrown Throwable throwable) throws Throwable {
if (throwable != null) {
System.out.println("Inner:" + throwable.getMessage());
}
}
}
```

### 期望的结果

使用byte-buddy导出增强后的方法是
```java
@RequestMapping({"throwable"})
public String testThrowable() {
TtlTestController var1 = this;

Throwable var2;
String var5;
label29: {
String var10000;
try {
++var1.id;
if (var1.id % 2 == 0) {
throw new IllegalArgumentException("illegal argument");
}

var10000 = "normal";
} catch (Throwable var4) {
var2 = var4;
var5 = null;
break label29;
}

var5 = var10000;
var2 = null;
}

if (var2 != null) {
System.out.println("Inner:" + var2.getMessage());
}

if (var2 != null) {
throw var2;
} else {
return var5;
}
}

static {
ClassLoader.getSystemClassLoader().loadClass("net.bytebuddy.dynamic.Nexus").getMethod("initialize", Class.class, Integer.TYPE).invoke((Object)null, TtlTestController.class, 1749305575);
}
```

### 实际运行的结果

通过jad查看当前类的源码如下,没有正确的展示出增强的代码
```java
@RequestMapping(value={"throwable"})
public String testThrowable() {
Object object = this;
try {
/*65*/ ++((TtlTestController)object).id;
/*66*/ if (((TtlTestController)object).id % 2 == 0) {
throw new IllegalArgumentException("illegal argument");
}
/*69*/ object = "normal";
return object;
}
finally {
Object var2_2 = null;
}
}

static {
ClassLoader.getSystemClassLoader().loadClass("net.bytebuddy.dynamic.Nexus").getMethod("initialize", Class.class, Integer.TYPE).invoke(null, TtlTestController.class, 158597040);
}
}
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the byte-buddy-enhanced Java method and inspect its output through Arthas's jad command. Compare the decompiled result with the expected try/catch, throwable rethrow, and return-flow logic; done means the enhanced method is represented accurately rather than only showing a finally block.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools, reverse-engineering
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.