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;