English 中文(简体)
用于寻找具体类型型的ASM转换
原标题:ASM transformation to find concrete class type

我正在研究一个项目,该项目将追踪方法电话从一个包内的某个类别到任何其他类别。重要的是,我必须能够确定具体类型,我更愿意拥有最低限度的跟踪管理管理费。对于何时触发探测器没有限制;它可以在一种方法被调用之前或之后。

ASM目前使用,但不需要。 系统正在从AspecitJ移动, 以便允许动态附加, 从而退出 。

以下为当前情况。 Tracer enum/ singleton 接收探测( int) 并处理呼叫。 只需从具体类型到引用类型找到呼叫即可 。

@Override
void visitMethodInsn(final int opcode, final String owner, final String name, final String desc) {
    Integer probeID = Tracer.INSTANCE.probes.createProbeIDAt(new Call(owner, name, desc))

    super.visitFieldInsn(GETSTATIC, "org/flightofstairs/honours/capture/agent/Tracer", "INSTANCE", "Lorg/flightofstairs/honours/capture/agent/Tracer;");
    super.visitLdcInsn(probeID)
    super.visitMethodInsn(INVOKEVIRTUAL, "org/flightofstairs/honours/capture/agent/Tracer", "probe", "(Ljava/lang/Integer;)V")

    super.visitMethodInsn(opcode, owner, name, desc);
}

我更进一步的想法是找到一个引用的类的引用, 并调用 GetClass () 来检索混凝土类型。 如果堆叠中包含 INVOKEINTELECE 的顶部天体ref, 那么这将微不足道, 但是任何所谓的方法参数都放在上面 。

鉴于参数数已知,计算对象引用的堆叠位置不会造成问题,但 Java 无法从堆叠下方复制引用。

有什么建议吗?

欢呼声。

最佳回答

解决方案是记录跨行期间的 IVNOKEINTELEFACS 。 最终, ASMS 分析器可以用来查找将对象折叠到堆叠上的指令, 从那里可以简单添加 Class () 和追踪代码 。

在此显示一个解决方案 。 < a href="https://gist.github.com/2795738" rel=“ no follow” >https://gist.github.com/2795738

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签