Java Bytecode Signatures

后端 未结 1 1638
迷失自我
迷失自我 2021-01-18 19:16

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

相关标签:
1条回答
  • 2021-01-18 19:56

    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:

    <T::Ljava/lang/Comparable<-TT;>;>
    

    Which would reflect:

    <T extends Comparable<T>>
    

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

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

    <T:Ljava/lang/Object;>(Ljava/util/Collection<TT;>;)TT;
    <T::Ljava/lang/Comparable;>(Ljava/util/Collection<TT;>;)TT;
    <T:Ljava/lang/Object;:Ljava/lang/Comparable;(Ljava/util/Collection<TT;>;)TT;
    

    Source

    0 讨论(0)
提交回复
热议问题