<i id='GVK74'><tr id='GVK74'><dt id='GVK74'><q id='GVK74'><span id='GVK74'><b id='GVK74'><form id='GVK74'><ins id='GVK74'></ins><ul id='GVK74'></ul><sub id='GVK74'></sub></form><legend id='GVK74'></legend><bdo id='GVK74'><pre id='GVK74'><center id='GVK74'></center></pre></bdo></b><th id='GVK74'></th></span></q></dt></tr></i><div id='GVK74'><tfoot id='GVK74'></tfoot><dl id='GVK74'><fieldset id='GVK74'></fieldset></dl></div>

  1. <legend id='GVK74'><style id='GVK74'><dir id='GVK74'><q id='GVK74'></q></dir></style></legend>

      • <bdo id='GVK74'></bdo><ul id='GVK74'></ul>
      <tfoot id='GVK74'></tfoot>

      <small id='GVK74'></small><noframes id='GVK74'>

      泛型类型存储在 java 类文件中的什么位置?

      时间:2023-08-25
      <legend id='wlxiJ'><style id='wlxiJ'><dir id='wlxiJ'><q id='wlxiJ'></q></dir></style></legend>
      1. <small id='wlxiJ'></small><noframes id='wlxiJ'>

        <tfoot id='wlxiJ'></tfoot>

        <i id='wlxiJ'><tr id='wlxiJ'><dt id='wlxiJ'><q id='wlxiJ'><span id='wlxiJ'><b id='wlxiJ'><form id='wlxiJ'><ins id='wlxiJ'></ins><ul id='wlxiJ'></ul><sub id='wlxiJ'></sub></form><legend id='wlxiJ'></legend><bdo id='wlxiJ'><pre id='wlxiJ'><center id='wlxiJ'></center></pre></bdo></b><th id='wlxiJ'></th></span></q></dt></tr></i><div id='wlxiJ'><tfoot id='wlxiJ'></tfoot><dl id='wlxiJ'><fieldset id='wlxiJ'></fieldset></dl></div>

              <tbody id='wlxiJ'></tbody>

              <bdo id='wlxiJ'></bdo><ul id='wlxiJ'></ul>

                本文介绍了泛型类型存储在 java 类文件中的什么位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我很清楚泛型类型在编译时会从 Java 代码中删除.1.5+ JVM 使用什么信息(属性?)来实现 getGenericType 等?

                I am well aware that generic types are erased from Java code when it is compiled. What information (attributes?) do 1.5+ JVMs use to implement getGenericType , etc. ?

                推荐答案

                它们存储在 Signature 属性中;请参阅 更新的 Java 虚拟机规范,以及第 4.4.4 节中关于字段类型签名的格式.

                They are stored in Signature attributes; see section 4.8.8 of the updated Java Virtual Machine Specification, as well as section 4.4.4 for the format of the field type signature.

                这是一个使用 javap -verbose java.util.Map 的示例:

                Here's an example using javap -verbose java.util.Map:

                public interface java.util.Map
                  SourceFile: "Map.java"
                  Signature: length = 0x2
                   00 1E 
                  [other attributes omitted]
                

                此处的 Signature 属性指定(如果您将其解读为大端序,就像 JVM 类文件格式中的所有整数数量一样)常量池值 #30 (30 = 0x1E).那么让我们看看那里:

                The Signature attribute here specifies (if you read this as big-endian, like all integer quantities in the JVM class file format are) constant pool value #30 (30 = 0x1E). So let's have a look there:

                const #30 = Asciz       <K:Ljava/lang/Object;V:Ljava/lang/Object;>Ljava/lang/Object;;
                

                在 4.4.4 中指定的语法上下文中阅读此内容.因此,这使用了两个类型参数,K extends java.lang.ObjectV extends java.lang.Object.类型本身(Map)也扩展类java.lang.Object,并且没有接口.

                Read this in the context of the grammar specified in 4.4.4. So, this uses two type parameters, K extends java.lang.Object and V extends java.lang.Object. The type itself (Map) also extends class java.lang.Object, and no interfaces.

                这篇关于泛型类型存储在 java 类文件中的什么位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:字符串 s = 新字符串(“xyz").这行代码执行后生成了多少个对象? 下一篇:如何为从 Eclipse 运行的程序指定默认 JVM 参数?

                相关文章

                  <bdo id='3DtAj'></bdo><ul id='3DtAj'></ul>
                <legend id='3DtAj'><style id='3DtAj'><dir id='3DtAj'><q id='3DtAj'></q></dir></style></legend>

                  <tfoot id='3DtAj'></tfoot>
                  1. <i id='3DtAj'><tr id='3DtAj'><dt id='3DtAj'><q id='3DtAj'><span id='3DtAj'><b id='3DtAj'><form id='3DtAj'><ins id='3DtAj'></ins><ul id='3DtAj'></ul><sub id='3DtAj'></sub></form><legend id='3DtAj'></legend><bdo id='3DtAj'><pre id='3DtAj'><center id='3DtAj'></center></pre></bdo></b><th id='3DtAj'></th></span></q></dt></tr></i><div id='3DtAj'><tfoot id='3DtAj'></tfoot><dl id='3DtAj'><fieldset id='3DtAj'></fieldset></dl></div>

                    <small id='3DtAj'></small><noframes id='3DtAj'>