【发布时间】:2020-11-18 01:13:16
【问题描述】:
为什么不能从静态嵌套类创建代理? 我没有收到错误或任何东西,程序只是没有运行,所以很难说出了什么问题。
package sfjl;
import java.lang.instrument.Instrumentation;
public final class SFJL_Profiler {
private SFJL_Profiler() {}
//
static public final class SFJL_Profiler_Agent {
private static Instrumentation instrumentation;
public static void premain(String args, Instrumentation inst) {
instrumentation = inst;
}
public static long sizeof(Object o) {
return instrumentation.getObjectSize(o);
}
}
//
static public final class SFJL_Profiler_Console_Printer {
}
}
清单:
Manifest-Version: 1.0
Premain-Class: sfjl.SFJL_Profiler.SFJL_Profiler_Agent
Agent-Class: sfjl.SFJL_Profiler.SFJL_Profiler_Agent
Can-Redefine-Classes: true
Can-Retransform-Classes: true
这是一个正在工作的非嵌套代理:
【问题讨论】: