作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试从 jvmti 中的 jobject 获取类名,我尝试了 get
(*jvmti)->GetClassSignature(jvmti, object_klass, &signature, &generic);
对于这样的代码
public static void main(String arg[]) throws Exception {
Set<String> names = new HashSet<>();
names.add("foo");
names.add("bar");
System.out.println(names);
}
我正在跟踪 jvmti 中对象的所有分配,我没有得到 java.util.HashSet
在这个钩子(Hook)中
我得到了一堆
Ljava/lang/String; Ljava/lang/Object;Ljava/io/Serializable;Ljava/lang/Comparable<Ljava/lang/String;>;Ljava/lang/CharSequence;
Ljava/lang/reflect/Method; (null)
和其他一些类(class),但我没有看到 new HashSet<>
初始化
最佳答案
我想你正在尝试 VMObjectAlloc JVMTI 通知。对于 Java 代码中进行的分配,不会发送此通知。 JVMTI 规范中描述了此行为:
<小时/>Sent when ... the allocation is not detectable by other intrumentation mechanisms. Generally object allocation should be detected by instrumenting the bytecodes of allocating methods.
...
Cases where this event would not be generated:
- Allocation due to bytecodes - for example, the new and newarray VM instructions
- Allocation due to JNI function calls - for example, AllocObject
- Allocations during VM initialization
- VM internal objects
This answer解释如何在 Java 中跟踪对象分配。
关于java - 如何从 jvmti 中的 jobject 获取类名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36070397/
我是一名优秀的程序员,十分优秀!