[英]Bytecode instrumentation system classes in Java with ASM
My javaagent, run via -javagent, instruments classes with callbacks to static methods on one of my classes. 我的javaagent,通过-javagent运行,在我的一个类上使用回调调用类到静态方法。 This works great, apart from on system classes, eg java/lang, java/util, which throw ClassDefNotFounderror at the point when the method is called (with INVOKESTATIC). 除了系统类之外,这很有用,例如java / lang,java / util,它在调用方法时使用INVOKESTATIC抛出ClassDefNotFounderror。 So it appears they are instrumented, because the method call is attempted, but have an access or visibility issue that my user classes don't have. 因此看起来它们是检测的,因为尝试了方法调用,但是具有我的用户类没有的访问或可见性问题。 My callback class and its methods are all public. 我的回调类及其方法都是公开的。
I've tried adding my class to the classpath (instead of just loading via -javaagent) but that didn't help. 我已经尝试将我的类添加到类路径(而不是仅通过-javaagent加载),但这没有帮助。 Is there some protection of system classes I need to override? 我需要覆盖一些系统类保护吗?
It sounds like you're explicitly looking for classes to instrument. 听起来你明确地在寻找要测试的课程。 Why aren't you using java.lang.instrument
to intercept classes that are being loaded when the target JVM executes? 为什么不使用java.lang.instrument
拦截目标JVM执行时正在加载的类? See this example 看这个例子
Can you paste your code, or the relevant parts? 您可以粘贴代码或相关部分吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.