java签名的作用,Java字节码签名

As part of the compiler for the programming language I am working on, I came across generic signatures in the bytecode, which I am trying to parse and convert to an AST. The parsing algorithm mostly works, but there seems to be a special case in which the format of these signatures behaves a bit strangely. Here are a few of these cases:

java.util.Arrays#parallelSort: <:ljava>;>([TT;)V

java.util.Arrays#parallelSort: <:ljava>;>([TT;II)V

java.lang.Class#getAnnotation: <:ljava>(Ljava/lang/Class;)TA;

java.lang.Class#getAnnotationsByType: <:ljava>(Ljava/lang/Class;)[TA;

java.lang.Class#getDeclaredAnnotation: <:ljava>(Ljava/lang/Class;)TA;

java.lang.Class#getDeclaredAnnotationsByType: <:ljava>(Ljava/lang/Class;)[TA;

java.util.Arrays#parallelSort: <:ljava>;>([TT;)V

java.util.Arrays#parallelSort: <:ljava>;>([TT;II)V

java.util.Collections#sort: <:ljava>;>(Ljava/util/List;)V

Out of all the methods in these classes, these are the only ones that have :: in their signature. My question is what this token does and why it exists.

Edit

I know about the :: operator in the Java Language, but this is something on the Bytecode level.

解决方案

There is a defined syntax that changed as of JSR 14 to specify the bounds of a generic type.

variable_name:class_type_bound:interface_type_bounds

So for your example of:

<:ljava>;>

Which would reflect:

>

The variable name is T, there is no class type bound so it was omitted, and there was an interface bound of type Comparable.

All your example follow this, but there any many different forms:

(Ljava/util/Collection;)TT;

<:ljava>(Ljava/util/Collection;)TT;

;)TT;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值