如果JVMTI不是,Java的JDI跨平台如何?
所以Java的调试接口是使用JVMTI作为后端的....但是JVMTI需要在目标架构上编译,那么这些JDI使用的JVMTI函数是不是预先编译好并作为库随JDK一起提供的呢?这意味着我可以在不使用 JDI 的情况下使用那些预编译库……是吗?我假设只有少数函数已经编译,但如果我需要这些函数,那么我不需要自己编译它们的麻烦......
回答
看看Java 平台调试器架构:
/ |--------------|
/ | VM |
debuggee ----( |--------------| <------- JVM TI - Java VM Tool Interface
| back-end |
|--------------|
/ |
comm channel -( | <--------------- JDWP - Java Debug Wire Protocol
|
|--------------|
| front-end |
|--------------| <------- JDI - Java Debug Interface
| UI |
|--------------|
- JDI 工作在 JDWP 之上;
- 从JVM端来看,JDWP是由jdwp代理提供的,它使用JVM TI与JVM进行通信。
jdwp agent 是原生库,当然是针对每个平台单独编译的。该库包含在标准 JDK 包中。因此,特定于平台的部分已经由 JDK 提供。
- @Nfff3 since JVMTI is a native interface, it can be used by native software. When you follow the link given in this answer up to https://docs.oracle.com/en/java/javase/11/docs/specs/jvmti.html you get the description of this interface. This does not imply that you can use it “*without starting the application in debug mode*”. You just exchange “*in debug mode*”, i.e. “*with jdwp agent*”, with “*with my JVMTI agent*”.