分析与检测 - Java
基本问题:JVM 提供了 JVMTI,它是用于分析和调试 JVM 的本机 API。 JVM 检测也执行相同的操作(正确吗?)。如果是,两者有什么区别?
Basic question: JVM provides JVMTI which native API for profiling and debugging JVM. JVM instrumentation also does the same (is that correct?). If yes, what is difference between the both?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不认为 Instrumentation 是 JVMTI 是 Instrumentation 的超集..因为这两者都可以独立使用。
JVMTI 基于事件,在事件处理程序中我们可以捕获有关 JVM 的所需信息。
检测是指我们修改字节码,然后在运行时在类中的所需位置添加额外的代码,然后再将其加载到 JVM 中。这段额外的代码在执行时将有助于收集分析器所需的信息。
可以借助 ASM 等各种第三方 jar 来实现检测。
根据我的知识和经验,这两个都是用于 Java 分析而不是 Native 分析。
可能需要阅读更多文档并尝试不同的示例才能更好地理解。
I dont think that Instrumentation is JVMTI is Superset of Instrumentation.. as Both of these can be used independently.
JVMTI is based on events and in the event handlers we can capture required information about the JVM.
Instrumentation is Something in which we modify the Bytecode and hence in turn add extra piece of code at runtime at required location in the class before it loads in the JVM. this extra piece of code when executed, will help gather required information for the profiler.
Instrumentation can be achieved with the help of various third party jar's like ASM.
As per my knowledge and experience Both of these are for Java profiling and not for Native profiling.
Probably need to read more documents and tryout different samples for better understanding.
JVMTI 提供了调试器所需的所有功能,但是如果您想要的功能超出 JVMTI 提供的功能,则需要使用 Instrumentation。
JVMTI gives all the functionality the debugger needs, however if you want to more than what the JVMTI provides you need to use Instrumentation.
JVMTI 是提供各种事件以进行调试、分析等的基本功能。它提供的功能之一是访问拦截(和重新定义)类。 java.lang.instrument 是 JVMTI 之上的 Java 包装器,它提供了一种很好的、简单的、可访问的方式来获取类加载事件。
将 JVMTI 视为 java.lang.instrument 的纯超集,但要求用户编写 C 代码。
JVMTI is base functionality that provides all sorts of events for debugging, profiling, etc... One of the areas it provides is access to intercept (and redefine) classes. java.lang.instrument is a Java wrapper on top of JVMTI that provides a nice, easy, accessible way of getting at the class loading events.
Think of JVMTI as a pure superset of java.lang.instrument, but requires the user to write C code.