Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bytecode analysis in Java

I am working on a Bytecode analysis project, for which I am using ASM. Everything is going good, I am able to parse, get class and method informations successfully.

But I am stuck in understanding bytecode representation for Generics. Here is the one example from java.util.list when I use visitMethod from ClassVisitor to print the information, this is what I am getting for one of the method's signature:

(ILjava/util/Collection<+TE;>;)Z

Here I am trying to disassemble one by one and understanding the arguments of the method:

  • I stands for int
  • Ljava/util/Collection stands for it's an argument of type Collection

But I am stuck at generics type ie <+TE> etc. Can anyone guide me? I tried to search but not got enough information. If anyone has list of bytecode names can you please share me?

like image 528
Pradeep Simha Avatar asked Oct 28 '13 10:10

Pradeep Simha


Video Answer


1 Answers

The + stands for the generic extends while the TE means that there is a type var E

Thus in the source code it will look like:

 Collection<? extends E>   -> Ljava/util/Collection<+TE;>

Take a look at the asm user guide section 4.1.1 Generics -> Metadata

like image 74
René Link Avatar answered Oct 11 '22 02:10

René Link