Search code examples
javaassemblyinstrumentationjava-bytecode-asm

instrumenting an "import" using java asm library


I'm using the asm library for java instrumentation and I want to instrument an "import" instruction. so that by using visitMethodInsn and INVOKEVIRTUAL i would be able to call a function from my package. I'm aware that when I have a bytecode the linkage stage is over so I might have trouble doing so. any solution/detour?


Solution

  • byte code uses full package.class names. There is no "import" equivelents at the byte code level. If you want to import a class, just use its fully qualified name.