Pradeep Simha
Pradeep Simha

Reputation: 18133

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:

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?

Upvotes: 12

Views: 2694

Answers (1)

Ren&#233; Link
Ren&#233; Link

Reputation: 51473

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, page 68.

Upvotes: 14

Related Questions