{"id":37525,"date":"2023-12-11T14:41:46","date_gmt":"2023-12-11T06:41:46","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=37525"},"modified":"2023-12-11T14:41:46","modified_gmt":"2023-12-11T06:41:46","slug":"%e8%af%b7%e6%80%bb%e7%bb%93%e4%b8%80%e4%b8%8bclass-%e6%96%87%e4%bb%b6%e7%bb%93%e6%9e%84%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/12\/11\/%e8%af%b7%e6%80%bb%e7%bb%93%e4%b8%80%e4%b8%8bclass-%e6%96%87%e4%bb%b6%e7%bb%93%e6%9e%84%ef%bc%9f\/","title":{"rendered":"\u8bf7\u603b\u7ed3\u4e00\u4e0bClass \u6587\u4ef6\u7ed3\u6784\uff1f"},"content":{"rendered":"<p>&#8220;`&#8221;                    \u6839\u636e Java \u865a\u62df\u673a\u89c4\u8303\uff0c\u7c7b\u6587\u4ef6\u7531\u5355\u4e2a ClassFile \u7ed3\u6784\u7ec4\u6210\uff1a<\/p>\n<p>&lt;pre&gt;&lt;code&gt;ClassFile {    u4             magic; \/\/Class \u6587\u4ef6\u7684\u6807\u5fd7    u2             minor_version;\/\/Class \u7684\u5c0f\u7248\u672c\u53f7    u2             major_version;\/\/Class \u7684\u5927\u7248\u672c\u53f7    u2             constant_pool_count;\/\/\u5e38\u91cf\u6c60\u7684\u6570\u91cf    cp_info        constant_pool[constant_pool_count-1];\/\/\u5e38\u91cf\u6c60    u2             access_flags;\/\/Class \u7684\u8bbf\u95ee\u6807\u8bb0    u2             this_class;\/\/\u5f53\u524d\u7c7b    u2             super_class;\/\/\u7236\u7c7b    u2             interfaces_count;\/\/\u63a5\u53e3    u2             interfaces[interfaces_count];\/\/\u4e00\u4e2a\u7c7b\u53ef\u4ee5\u5b9e\u73b0\u591a\u4e2a\u63a5\u53e3    u2             fields_count;\/\/Class \u6587\u4ef6\u7684\u5b57\u6bb5\u5c5e\u6027    field_info     fields[fields_count];\/\/\u4e00\u4e2a\u7c7b\u4f1a\u53ef\u4ee5\u6709\u4e2a\u5b57\u6bb5    u2             methods_count;\/\/Class \u6587\u4ef6\u7684\u65b9\u6cd5\u6570\u91cf    method_info    methods[methods_count];\/\/\u4e00\u4e2a\u7c7b\u53ef\u4ee5\u6709\u4e2a\u591a\u4e2a\u65b9\u6cd5    u2             attributes_count;\/\/\u6b64\u7c7b\u7684\u5c5e\u6027\u8868\u4e2d\u7684\u5c5e\u6027\u6570    attribute_info attributes[attributes_count];\/\/\u5c5e\u6027\u8868\u96c6\u5408}&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>\u4e0b\u9762\u8be6\u7ec6\u4ecb\u7ecd\u4e00\u4e0b Class \u6587\u4ef6\u7ed3\u6784\u6d89\u53ca\u5230\u7684\u4e00\u4e9b\u7ec4\u4ef6\u3002<\/p>\n<p>&lt;strong&gt;Class\u6587\u4ef6\u5b57\u8282\u7801\u7ed3\u6784\u7ec4\u7ec7\u793a\u610f\u56fe&lt;\/strong&gt; \uff08\u4e4b\u524d\u5728\u7f51\u4e0a\u4fdd\u5b58\u7684\uff0c\u975e\u5e38\u4e0d\u9519\uff0c\u539f\u51fa\u5904\u4e0d\u660e\uff09\uff1a<\/p>\n<p>&lt;img src=&quot;&quot;https:\/\/my-blog-to-use.oss-cn-beijing.aliyuncs.com\/2019-6\/%E7%B1%BB%E6%96%87%E4%BB%B6%E5%AD%97%E8%8A%82%E7%A0%81%E7%BB%93%E6%9E%84%E7%BB%84%E7%BB%87%E7%A4%BA%E6%84%8F%E5%9B%BE.png&quot;&quot; referrerpolicy=&quot;&quot;no-referrer&quot;&quot; alt=&quot;&quot;\u7c7b\u6587\u4ef6\u5b57\u8282\u7801\u7ed3\u6784\u7ec4\u7ec7\u793a\u610f\u56fe&quot;&quot; style=&quot;&quot;width: 100%;&quot;&quot;&gt;<\/p>\n<p>&lt;h3&gt;2.1 \u9b54\u6570&lt;\/h3&gt;<\/p>\n<p>&lt;pre&gt;&lt;code&gt;    u4             magic; \/\/Class \u6587\u4ef6\u7684\u6807\u5fd7&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>\u6bcf\u4e2a Class \u6587\u4ef6\u7684\u5934\u56db\u4e2a\u5b57\u8282\u79f0\u4e3a\u9b54\u6570\uff08Magic Number\uff09,\u5b83\u7684\u552f\u4e00\u4f5c\u7528\u662f&lt;strong&gt;\u786e\u5b9a\u8fd9\u4e2a\u6587\u4ef6\u662f\u5426\u4e3a\u4e00\u4e2a\u80fd\u88ab\u865a\u62df\u673a\u63a5\u6536\u7684 Class \u6587\u4ef6&lt;\/strong&gt;\u3002 <\/p>\n<p>\u7a0b\u5e8f\u8bbe\u8ba1\u8005\u5f88\u591a\u65f6\u5019\u90fd\u559c\u6b22\u7528\u4e00\u4e9b\u7279\u6b8a\u7684\u6570\u5b57\u8868\u793a\u56fa\u5b9a\u7684\u6587\u4ef6\u7c7b\u578b\u6216\u8005\u5176\u5b83\u7279\u6b8a\u7684\u542b\u4e49\u3002<\/p>\n<p>&lt;h3&gt;2.2 Class \u6587\u4ef6\u7248\u672c&lt;\/h3&gt;<\/p>\n<p>&lt;pre&gt;&lt;code&gt;    u2             minor_version;\/\/Class \u7684\u5c0f\u7248\u672c\u53f7    u2             major_version;\/\/Class \u7684\u5927\u7248\u672c\u53f7&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>\u7d27\u63a5\u7740\u9b54\u6570\u7684\u56db\u4e2a\u5b57\u8282\u5b58\u50a8\u7684\u662f Class \u6587\u4ef6\u7684\u7248\u672c\u53f7\uff1a\u7b2c\u4e94\u548c\u7b2c\u516d\u662f&lt;strong&gt;\u6b21\u7248\u672c\u53f7&lt;\/strong&gt;\uff0c\u7b2c\u4e03\u548c\u7b2c\u516b\u662f&lt;strong&gt;\u4e3b\u7248\u672c\u53f7&lt;\/strong&gt;\u3002<\/p>\n<p>\u9ad8\u7248\u672c\u7684 Java \u865a\u62df\u673a\u53ef\u4ee5\u6267\u884c\u4f4e\u7248\u672c\u7f16\u8bd1\u5668\u751f\u6210\u7684 Class \u6587\u4ef6\uff0c\u4f46\u662f\u4f4e\u7248\u672c\u7684 Java \u865a\u62df\u673a\u4e0d\u80fd\u6267\u884c\u9ad8\u7248\u672c\u7f16\u8bd1\u5668\u751f\u6210\u7684 Class \u6587\u4ef6\u3002\u6240\u4ee5\uff0c\u6211\u4eec\u5728\u5b9e\u9645\u5f00\u53d1\u7684\u65f6\u5019\u8981\u786e\u4fdd\u5f00\u53d1\u7684\u7684 JDK \u7248\u672c\u548c\u751f\u4ea7\u73af\u5883\u7684 JDK \u7248\u672c\u4fdd\u6301\u4e00\u81f4\u3002<\/p>\n<p>&lt;h3&gt;2.3 \u5e38\u91cf\u6c60&lt;\/h3&gt;<\/p>\n<p>&lt;pre&gt;&lt;code&gt;    u2             constant_pool_count;\/\/\u5e38\u91cf\u6c60\u7684\u6570\u91cf    cp_info        constant_pool[constant_pool_count-1];\/\/\u5e38\u91cf\u6c60&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>\u7d27\u63a5\u7740\u4e3b\u6b21\u7248\u672c\u53f7\u4e4b\u540e\u7684\u662f\u5e38\u91cf\u6c60\uff0c\u5e38\u91cf\u6c60\u7684\u6570\u91cf\u662f constant_pool_count-1\uff08&lt;strong&gt;\u5e38\u91cf\u6c60\u8ba1\u6570\u5668\u662f\u4ece1\u5f00\u59cb\u8ba1\u6570\u7684\uff0c\u5c06\u7b2c0\u9879\u5e38\u91cf\u7a7a\u51fa\u6765\u662f\u6709\u7279\u6b8a\u8003\u8651\u7684\uff0c\u7d22\u5f15\u503c\u4e3a0\u4ee3\u8868\u201c\u4e0d\u5f15\u7528\u4efb\u4f55\u4e00\u4e2a\u5e38\u91cf\u6c60\u9879\u201d&lt;\/strong&gt;\uff09\u3002<\/p>\n<p>\u5e38\u91cf\u6c60\u4e3b\u8981\u5b58\u653e\u4e24\u5927\u5e38\u91cf\uff1a\u5b57\u9762\u91cf\u548c\u7b26\u53f7\u5f15\u7528\u3002\u5b57\u9762\u91cf\u6bd4\u8f83\u63a5\u8fd1\u4e8e Java \u8bed\u8a00\u5c42\u9762\u7684\u7684\u5e38\u91cf\u6982\u5ff5\uff0c\u5982\u6587\u672c\u5b57\u7b26\u4e32\u3001\u58f0\u660e\u4e3a final \u7684\u5e38\u91cf\u503c\u7b49\u3002\u800c\u7b26\u53f7\u5f15\u7528\u5219\u5c5e\u4e8e\u7f16\u8bd1\u539f\u7406\u65b9\u9762\u7684\u6982\u5ff5\u3002\u5305\u62ec\u4e0b\u9762\u4e09\u7c7b\u5e38\u91cf\uff1a <\/p>\n<p>&lt;ul&gt;&lt;li&gt;\u7c7b\u548c\u63a5\u53e3\u7684\u5168\u9650\u5b9a\u540d &lt;\/li&gt;&lt;li&gt;\u5b57\u6bb5\u7684\u540d\u79f0\u548c\u63cf\u8ff0\u7b26 &lt;\/li&gt;&lt;li&gt;\u65b9\u6cd5\u7684\u540d\u79f0\u548c\u63cf\u8ff0\u7b26&lt;\/li&gt;&lt;\/ul&gt;<\/p>\n<p>\u5e38\u91cf\u6c60\u4e2d\u6bcf\u4e00\u9879\u5e38\u91cf\u90fd\u662f\u4e00\u4e2a\u8868\uff0c\u8fd914\u79cd\u8868\u6709\u4e00\u4e2a\u5171\u540c\u7684\u7279\u70b9\uff1a&lt;strong&gt;\u5f00\u59cb\u7684\u7b2c\u4e00\u4f4d\u662f\u4e00\u4e2a u1 \u7c7b\u578b\u7684\u6807\u5fd7\u4f4d -tag \u6765\u6807\u8bc6\u5e38\u91cf\u7684\u7c7b\u578b\uff0c\u4ee3\u8868\u5f53\u524d\u8fd9\u4e2a\u5e38\u91cf\u5c5e\u4e8e\u54ea\u79cd\u5e38\u91cf\u7c7b\u578b\uff0e&lt;\/strong&gt;<\/p>\n<p>&lt;figure&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;&quot;text-align:center;&quot;&quot;&gt;\u7c7b\u578b&lt;\/th&gt;&lt;th style=&quot;&quot;text-align:center;&quot;&quot;&gt;\u6807\u5fd7\uff08tag\uff09&lt;\/th&gt;&lt;th style=&quot;&quot;text-align:center;&quot;&quot;&gt;\u63cf\u8ff0&lt;\/th&gt;&lt;\/tr&gt;&lt;\/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;CONSTANT_utf8_info&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;1&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;UTF-8\u7f16\u7801\u7684\u5b57\u7b26\u4e32&lt;\/td&gt;&lt;\/tr&gt;&lt;tr&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;CONSTANT_Integer_info&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;3&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;\u6574\u5f62\u5b57\u9762\u91cf&lt;\/td&gt;&lt;\/tr&gt;&lt;tr&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;CONSTANT_Float_info&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;4&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;\u6d6e\u70b9\u578b\u5b57\u9762\u91cf&lt;\/td&gt;&lt;\/tr&gt;&lt;tr&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;CONSTANT_Long_info&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;\uff15&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;\u957f\u6574\u578b\u5b57\u9762\u91cf&lt;\/td&gt;&lt;\/tr&gt;&lt;tr&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;CONSTANT_Double_info&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;\uff16&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;\u53cc\u7cbe\u5ea6\u6d6e\u70b9\u578b\u5b57\u9762\u91cf&lt;\/td&gt;&lt;\/tr&gt;&lt;tr&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;CONSTANT_Class_info&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;\uff17&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;\u7c7b\u6216\u63a5\u53e3\u7684\u7b26\u53f7\u5f15\u7528&lt;\/td&gt;&lt;\/tr&gt;&lt;tr&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;CONSTANT_String_info&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;\uff18&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;\u5b57\u7b26\u4e32\u7c7b\u578b\u5b57\u9762\u91cf&lt;\/td&gt;&lt;\/tr&gt;&lt;tr&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;CONSTANT_Fieldref_info&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;\uff19&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;\u5b57\u6bb5\u7684\u7b26\u53f7\u5f15\u7528&lt;\/td&gt;&lt;\/tr&gt;&lt;tr&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;CONSTANT_Methodref_info&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;10&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;\u7c7b\u4e2d\u65b9\u6cd5\u7684\u7b26\u53f7\u5f15\u7528&lt;\/td&gt;&lt;\/tr&gt;&lt;tr&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;CONSTANT_InterfaceMethodref_info&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;11&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;\u63a5\u53e3\u4e2d\u65b9\u6cd5\u7684\u7b26\u53f7\u5f15\u7528&lt;\/td&gt;&lt;\/tr&gt;&lt;tr&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;CONSTANT_NameAndType_info&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;12&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;\u5b57\u6bb5\u6216\u65b9\u6cd5\u7684\u7b26\u53f7\u5f15\u7528&lt;\/td&gt;&lt;\/tr&gt;&lt;tr&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;CONSTANT_MothodType_info&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;16&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;\u6807\u5fd7\u65b9\u6cd5\u7c7b\u578b&lt;\/td&gt;&lt;\/tr&gt;&lt;tr&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;CONSTANT_MethodHandle_info&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;15&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;\u8868\u793a\u65b9\u6cd5\u53e5\u67c4&lt;\/td&gt;&lt;\/tr&gt;&lt;tr&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;CONSTANT_InvokeDynamic_info&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;18&lt;\/td&gt;&lt;td style=&quot;&quot;text-align:center;&quot;&quot;&gt;\u8868\u793a\u4e00\u4e2a\u52a8\u6001\u65b9\u6cd5\u8c03\u7528\u70b9&lt;\/td&gt;&lt;\/tr&gt;&lt;\/tbody&gt;&lt;\/table&gt;&lt;\/figure&gt;<\/p>\n<p>&lt;code&gt;.class&lt;\/code&gt; \u6587\u4ef6\u53ef\u4ee5\u901a\u8fc7&lt;code&gt;javap &lt;span style=&quot;&quot;font-family:&quot;Open Sans&quot;, &quot;Clear Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif&quot;&quot;&gt;-&lt;\/span&gt;v class\u7c7b\u540d&lt;\/code&gt; \u6307\u4ee4\u6765\u770b\u4e00\u4e0b\u5176\u5e38\u91cf\u6c60\u4e2d\u7684\u4fe1\u606f(&lt;code&gt;javap &lt;span style=&quot;&quot;font-family:&quot;Open Sans&quot;, &quot;Clear Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif&quot;&quot;&gt;-&lt;\/span&gt;v  class\u7c7b\u540d&lt;span style=&quot;&quot;font-family:&quot;Open Sans&quot;, &quot;Clear Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif&quot;&quot;&gt;-&lt;\/span&gt;&gt; temp.txt&lt;\/code&gt; \uff1a\u5c06\u7ed3\u679c\u8f93\u51fa\u5230 temp.txt \u6587\u4ef6)\u3002<\/p>\n<p>&lt;h3&gt;2.4 \u8bbf\u95ee\u6807\u5fd7&lt;\/h3&gt;<\/p>\n<p>\u5728\u5e38\u91cf\u6c60\u7ed3\u675f\u4e4b\u540e\uff0c\u7d27\u63a5\u7740\u7684\u4e24\u4e2a\u5b57\u8282\u4ee3\u8868\u8bbf\u95ee\u6807\u5fd7\uff0c\u8fd9\u4e2a\u6807\u5fd7\u7528\u4e8e\u8bc6\u522b\u4e00\u4e9b\u7c7b\u6216\u8005\u63a5\u53e3\u5c42\u6b21\u7684\u8bbf\u95ee\u4fe1\u606f\uff0c\u5305\u62ec\uff1a\u8fd9\u4e2a Class \u662f\u7c7b\u8fd8\u662f\u63a5\u53e3\uff0c\u662f\u5426\u4e3a public \u6216\u8005 abstract \u7c7b\u578b\uff0c\u5982\u679c\u662f\u7c7b\u7684\u8bdd\u662f\u5426\u58f0\u660e\u4e3a final \u7b49\u7b49\u3002<\/p>\n<p>\u7c7b\u8bbf\u95ee\u548c\u5c5e\u6027\u4fee\u9970\u7b26:<\/p>\n<p>&lt;img src=&quot;&quot;https:\/\/my-blog-to-use.oss-cn-beijing.aliyuncs.com\/2019-6\/%E8%AE%BF%E9%97%AE%E6%A0%87%E5%BF%97.png&quot;&quot; referrerpolicy=&quot;&quot;no-referrer&quot;&quot; alt=&quot;&quot;\u7c7b\u8bbf\u95ee\u548c\u5c5e\u6027\u4fee\u9970\u7b26&quot;&quot; style=&quot;&quot;width: 100%;&quot;&quot;&gt;<\/p>\n<p>\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a Employee \u7c7b<\/p>\n<p>&lt;pre&gt;&lt;code&gt;package top.snailclimb.bean;public class Employee {   &#8230;}&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>\u901a\u8fc7&lt;code&gt;javap &lt;span style=&quot;&quot;font-family:&quot;Open Sans&quot;, &quot;Clear Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif&quot;&quot;&gt;-&lt;\/span&gt;v class\u7c7b\u540d&lt;\/code&gt; \u6307\u4ee4\u6765\u770b\u4e00\u4e0b\u7c7b\u7684\u8bbf\u95ee\u6807\u5fd7\u3002<\/p>\n<p>&lt;img src=&quot;&quot;https:\/\/my-blog-to-use.oss-cn-beijing.aliyuncs.com\/2019-6\/%E6%9F%A5%E7%9C%8B%E7%B1%BB%E7%9A%84%E8%AE%BF%E9%97%AE%E6%A0%87%E5%BF%97.png&quot;&quot; referrerpolicy=&quot;&quot;no-referrer&quot;&quot; alt=&quot;&quot;\u67e5\u770b\u7c7b\u7684\u8bbf\u95ee\u6807\u5fd7&quot;&quot; style=&quot;&quot;width: 100%;&quot;&quot;&gt;<\/p>\n<p>&lt;h3&gt;2.5 \u5f53\u524d\u7c7b\u7d22\u5f15,\u7236\u7c7b\u7d22\u5f15\u4e0e\u63a5\u53e3\u7d22\u5f15\u96c6\u5408&lt;\/h3&gt;<\/p>\n<p>&lt;pre&gt;&lt;code&gt;    u2             this_class;\/\/\u5f53\u524d\u7c7b    u2             super_class;\/\/\u7236\u7c7b    u2             interfaces_count;\/\/\u63a5\u53e3    u2             interfaces[interfaces_count];\/\/\u4e00\u4e2a\u96f7\u53ef\u4ee5\u5b9e\u73b0\u591a\u4e2a\u63a5\u53e3&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>&lt;strong&gt;\u7c7b\u7d22\u5f15\u7528\u4e8e\u786e\u5b9a\u8fd9\u4e2a\u7c7b\u7684\u5168\u9650\u5b9a\u540d\uff0c\u7236\u7c7b\u7d22\u5f15\u7528\u4e8e\u786e\u5b9a\u8fd9\u4e2a\u7c7b\u7684\u7236\u7c7b\u7684\u5168\u9650\u5b9a\u540d\uff0c\u7531\u4e8e Java \u8bed\u8a00\u7684\u5355\u7ee7\u627f\uff0c\u6240\u4ee5\u7236\u7c7b\u7d22\u5f15\u53ea\u6709\u4e00\u4e2a\uff0c\u9664\u4e86 &lt;code&gt;java.lang.Object&lt;\/code&gt; \u4e4b\u5916\uff0c\u6240\u6709\u7684 java \u7c7b\u90fd\u6709\u7236\u7c7b\uff0c\u56e0\u6b64\u9664\u4e86 &lt;code&gt;java.lang.Object&lt;\/code&gt; \u5916\uff0c\u6240\u6709 Java \u7c7b\u7684\u7236\u7c7b\u7d22\u5f15\u90fd\u4e0d\u4e3a 0\u3002&lt;\/strong&gt;<\/p>\n<p>&lt;strong&gt;\u63a5\u53e3\u7d22\u5f15\u96c6\u5408\u7528\u6765\u63cf\u8ff0\u8fd9\u4e2a\u7c7b\u5b9e\u73b0\u4e86\u90a3\u4e9b\u63a5\u53e3\uff0c\u8fd9\u4e9b\u88ab\u5b9e\u73b0\u7684\u63a5\u53e3\u5c06\u6309&lt;code&gt;implents&lt;\/code&gt;(\u5982\u679c\u8fd9\u4e2a\u7c7b\u672c\u8eab\u662f\u63a5\u53e3\u7684\u8bdd\u5219\u662f&lt;code&gt;extends&lt;\/code&gt;) \u540e\u7684\u63a5\u53e3\u987a\u5e8f\u4ece\u5de6\u5230\u53f3\u6392\u5217\u5728\u63a5\u53e3\u7d22\u5f15\u96c6\u5408\u4e2d\u3002&lt;\/strong&gt;<\/p>\n<p>&lt;h3&gt;2.6 \u5b57\u6bb5\u8868\u96c6\u5408&lt;\/h3&gt;<\/p>\n<p>&lt;pre&gt;&lt;code&gt;    u2             fields_count;\/\/Class \u6587\u4ef6\u7684\u5b57\u6bb5\u7684\u4e2a\u6570    field_info     fields[fields_count];\/\/\u4e00\u4e2a\u7c7b\u4f1a\u53ef\u4ee5\u6709\u4e2a\u5b57\u6bb5&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>\u5b57\u6bb5\u8868\uff08field info\uff09\u7528\u4e8e\u63cf\u8ff0\u63a5\u53e3\u6216\u7c7b\u4e2d\u58f0\u660e\u7684\u53d8\u91cf\u3002\u5b57\u6bb5\u5305\u62ec\u7c7b\u7ea7\u53d8\u91cf\u4ee5\u53ca\u5b9e\u4f8b\u53d8\u91cf\uff0c\u4f46\u4e0d\u5305\u62ec\u5728\u65b9\u6cd5\u5185\u90e8\u58f0\u660e\u7684\u5c40\u90e8\u53d8\u91cf\u3002<\/p>\n<p>&lt;strong&gt;field info(\u5b57\u6bb5\u8868) \u7684\u7ed3\u6784:&lt;\/strong&gt;<\/p>\n<p>&lt;img src=&quot;&quot;https:\/\/my-blog-to-use.oss-cn-beijing.aliyuncs.com\/2019-6\/%E5%AD%97%E6%AE%B5%E8%A1%A8%E7%9A%84%E7%BB%93%E6%9E%84.png&quot;&quot; referrerpolicy=&quot;&quot;no-referrer&quot;&quot; alt=&quot;&quot;\u5b57\u6bb5\u8868\u7684\u7ed3\u6784 &quot;&quot;&gt;<\/p>\n<p>&lt;ul&gt;&lt;li&gt;&lt;strong&gt;access_flags:&lt;\/strong&gt;  \u5b57\u6bb5\u7684\u4f5c\u7528\u57df\uff08&lt;code&gt;public&lt;\/code&gt; ,&lt;code&gt;private&lt;\/code&gt;,&lt;code&gt;protected&lt;\/code&gt;\u4fee\u9970\u7b26\uff09\uff0c\u662f\u5b9e\u4f8b\u53d8\u91cf\u8fd8\u662f\u7c7b\u53d8\u91cf\uff08&lt;code&gt;static&lt;\/code&gt;\u4fee\u9970\u7b26\uff09,\u53ef\u5426\u88ab\u5e8f\u5217\u5316\uff08transient \u4fee\u9970\u7b26\uff09,\u53ef\u53d8\u6027\uff08final\uff09,\u53ef\u89c1\u6027\uff08volatile \u4fee\u9970\u7b26\uff0c\u662f\u5426\u5f3a\u5236\u4ece\u4e3b\u5185\u5b58\u8bfb\u5199\uff09\u3002&lt;\/li&gt;&lt;li&gt;&lt;strong&gt;name_index:&lt;\/strong&gt; \u5bf9\u5e38\u91cf\u6c60\u7684\u5f15\u7528\uff0c\u8868\u793a\u7684\u5b57\u6bb5\u7684\u540d\u79f0\uff1b&lt;\/li&gt;&lt;li&gt;&lt;strong&gt;descriptor_index:&lt;\/strong&gt; \u5bf9\u5e38\u91cf\u6c60\u7684\u5f15\u7528\uff0c\u8868\u793a\u5b57\u6bb5\u548c\u65b9\u6cd5\u7684\u63cf\u8ff0\u7b26\uff1b&lt;\/li&gt;&lt;li&gt;&lt;strong&gt;attributes_count:&lt;\/strong&gt; \u4e00\u4e2a\u5b57\u6bb5\u8fd8\u4f1a\u62e5\u6709\u4e00\u4e9b\u989d\u5916\u7684\u5c5e\u6027\uff0cattributes_count \u5b58\u653e\u5c5e\u6027\u7684\u4e2a\u6570\uff1b&lt;\/li&gt;&lt;li&gt;&lt;strong&gt;attributes[attributes_count]:&lt;\/strong&gt; \u5b58\u653e\u5177\u4f53\u5c5e\u6027\u5177\u4f53\u5185\u5bb9\u3002&lt;\/li&gt;&lt;\/ul&gt;<\/p>\n<p>\u4e0a\u8ff0\u8fd9\u4e9b\u4fe1\u606f\u4e2d\uff0c\u5404\u4e2a\u4fee\u9970\u7b26\u90fd\u662f\u5e03\u5c14\u503c\uff0c\u8981\u4e48\u6709\u67d0\u4e2a\u4fee\u9970\u7b26\uff0c\u8981\u4e48\u6ca1\u6709\uff0c\u5f88\u9002\u5408\u4f7f\u7528\u6807\u5fd7\u4f4d\u6765\u8868\u793a\u3002\u800c\u5b57\u6bb5\u53eb\u4ec0\u4e48\u540d\u5b57\u3001\u5b57\u6bb5\u88ab\u5b9a\u4e49\u4e3a\u4ec0\u4e48\u6570\u636e\u7c7b\u578b\u8fd9\u4e9b\u90fd\u662f\u65e0\u6cd5\u56fa\u5b9a\u7684\uff0c\u53ea\u80fd\u5f15\u7528\u5e38\u91cf\u6c60\u4e2d\u5e38\u91cf\u6765\u63cf\u8ff0\u3002<\/p>\n<p>&lt;strong&gt;\u5b57\u6bb5\u7684 access_flags \u7684\u53d6\u503c:&lt;\/strong&gt;<\/p>\n<p>&lt;img src=&quot;&quot;https:\/\/my-blog-to-use.oss-cn-beijing.aliyuncs.com\/2019-6\/%E5%AD%97%E6%AE%B5%E7%9A%84access_flags%E7%9A%84%E5%8F%96%E5%80%BC.png&quot;&quot; referrerpolicy=&quot;&quot;no-referrer&quot;&quot; alt=&quot;&quot;\u5b57\u6bb5\u7684access_flags\u7684\u53d6\u503c&quot;&quot; style=&quot;&quot;width: 100%;&quot;&quot;&gt;<\/p>\n<p>&lt;h3&gt;2.7 \u65b9\u6cd5\u8868\u96c6\u5408&lt;\/h3&gt;<\/p>\n<p>&lt;pre&gt;&lt;code&gt;    u2             methods_count;\/\/Class \u6587\u4ef6\u7684\u65b9\u6cd5\u7684\u6570\u91cf    method_info    methods[methods_count];\/\/\u4e00\u4e2a\u7c7b\u53ef\u4ee5\u6709\u4e2a\u591a\u4e2a\u65b9\u6cd5&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>methods_count \u8868\u793a\u65b9\u6cd5\u7684\u6570\u91cf\uff0c\u800c method_info \u8868\u793a\u7684\u65b9\u6cd5\u8868\u3002<\/p>\n<p>Class \u6587\u4ef6\u5b58\u50a8\u683c\u5f0f\u4e2d\u5bf9\u65b9\u6cd5\u7684\u63cf\u8ff0\u4e0e\u5bf9\u5b57\u6bb5\u7684\u63cf\u8ff0\u51e0\u4e4e\u91c7\u7528\u4e86\u5b8c\u5168\u4e00\u81f4\u7684\u65b9\u5f0f\u3002\u65b9\u6cd5\u8868\u7684\u7ed3\u6784\u5982\u540c\u5b57\u6bb5\u8868\u4e00\u6837\uff0c\u4f9d\u6b21\u5305\u62ec\u4e86\u8bbf\u95ee\u6807\u5fd7\u3001\u540d\u79f0\u7d22\u5f15\u3001\u63cf\u8ff0\u7b26\u7d22\u5f15\u3001\u5c5e\u6027\u8868\u96c6\u5408\u51e0\u9879\u3002<\/p>\n<p>&lt;strong&gt;method_info(\u65b9\u6cd5\u8868\u7684) \u7ed3\u6784:&lt;\/strong&gt;<\/p>\n<p>&lt;img src=&quot;&quot;https:\/\/my-blog-to-use.oss-cn-beijing.aliyuncs.com\/2019-6\/%E6%96%B9%E6%B3%95%E8%A1%A8%E7%9A%84%E7%BB%93%E6%9E%84.png&quot;&quot; referrerpolicy=&quot;&quot;no-referrer&quot;&quot; alt=&quot;&quot;\u65b9\u6cd5\u8868\u7684\u7ed3\u6784&quot;&quot;&gt;<\/p>\n<p>&lt;strong&gt;\u65b9\u6cd5\u8868\u7684 access_flag \u53d6\u503c\uff1a&lt;\/strong&gt;<\/p>\n<p>&lt;img src=&quot;&quot;https:\/\/my-blog-to-use.oss-cn-beijing.aliyuncs.com\/2019-6\/%E6%96%B9%E6%B3%95%E8%A1%A8%E7%9A%84access_flag%E7%9A%84%E6%89%80%E6%9C%89%E6%A0%87%E5%BF%97%E4%BD%8D.png&quot;&quot; referrerpolicy=&quot;&quot;no-referrer&quot;&quot; alt=&quot;&quot;\u65b9\u6cd5\u8868\u7684 access_flag \u53d6\u503c&quot;&quot; style=&quot;&quot;width: 100%;&quot;&quot;&gt;<\/p>\n<p>\u6ce8\u610f\uff1a\u56e0\u4e3a&lt;code&gt;volatile&lt;\/code&gt;\u4fee\u9970\u7b26\u548c&lt;code&gt;transient&lt;\/code&gt;\u4fee\u9970\u7b26\u4e0d\u53ef\u4ee5\u4fee\u9970\u65b9\u6cd5\uff0c\u6240\u4ee5\u65b9\u6cd5\u8868\u7684\u8bbf\u95ee\u6807\u5fd7\u4e2d\u6ca1\u6709\u8fd9\u4e24\u4e2a\u5bf9\u5e94\u7684\u6807\u5fd7\uff0c\u4f46\u662f\u589e\u52a0\u4e86&lt;code&gt;synchronized&lt;\/code&gt;\u3001&lt;code&gt;native&lt;\/code&gt;\u3001&lt;code&gt;abstract&lt;\/code&gt;\u7b49\u5173\u952e\u5b57\u4fee\u9970\u65b9\u6cd5\uff0c\u6240\u4ee5\u4e5f\u5c31\u591a\u4e86\u8fd9\u4e9b\u5173\u952e\u5b57\u5bf9\u5e94\u7684\u6807\u5fd7\u3002<\/p>\n<p>&lt;h3&gt;2.8 \u5c5e\u6027\u8868\u96c6\u5408&lt;\/h3&gt;<\/p>\n<p>&lt;pre&gt;&lt;code&gt;   u2             attributes_count;\/\/\u6b64\u7c7b\u7684\u5c5e\u6027\u8868\u4e2d\u7684\u5c5e\u6027\u6570   attribute_info attributes[attributes_count];\/\/\u5c5e\u6027\u8868\u96c6\u5408&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>\u5728 Class \u6587\u4ef6\uff0c\u5b57\u6bb5\u8868\uff0c\u65b9\u6cd5\u8868\u4e2d\u90fd\u53ef\u4ee5\u643a\u5e26\u81ea\u5df1\u7684\u5c5e\u6027\u8868\u96c6\u5408\uff0c\u4ee5\u7528\u4e8e\u63cf\u8ff0\u67d0\u4e9b\u573a\u666f\u4e13\u6709\u7684\u4fe1\u606f\u3002\u4e0e Class \u6587\u4ef6\u4e2d\u5176\u5b83\u7684\u6570\u636e\u9879\u76ee\u8981\u6c42\u7684\u987a\u5e8f\u3001\u957f\u5ea6\u548c\u5185\u5bb9\u4e0d\u540c\uff0c\u5c5e\u6027\u8868\u96c6\u5408\u7684\u9650\u5236\u7a0d\u5fae\u5bbd\u677e\u4e00\u4e9b\uff0c\u4e0d\u518d\u8981\u6c42\u5404\u4e2a\u5c5e\u6027\u8868\u5177\u6709\u4e25\u683c\u7684\u987a\u5e8f\uff0c\u5e76\u4e14\u53ea\u8981\u4e0d\u4e0e\u5df2\u6709\u7684\u5c5e\u6027\u540d\u91cd\u590d\uff0c\u4efb\u4f55\u4eba\u5b9e\u73b0\u7684\u7f16\u8bd1\u5668\u90fd\u53ef\u4ee5\u5411\u5c5e\u6027\u8868\u4e2d\u5199 \u5165\u81ea\u5df1\u5b9a\u4e49\u7684\u5c5e\u6027\u4fe1\u606f\uff0cJava \u865a\u62df\u673a\u8fd0\u884c\u65f6\u4f1a\u5ffd\u7565\u6389\u5b83\u4e0d\u8ba4\u8bc6\u7684\u5c5e\u6027\u3002<\/p>\n<p>&lt;h2&gt;\u53c2\u8003&lt;\/h2&gt;<\/p>\n<p>&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;&quot;https:\/\/docs.oracle.com\/javase\/specs\/jvms\/se7\/html\/jvms-4.html&quot;&quot; target=&quot;&quot;_blank&quot;&quot; class=&quot;&quot;url&quot;&quot;&gt;https:\/\/docs.oracle.com\/javase\/specs\/jvms\/se7\/html\/jvms-4.html&lt;\/a&gt;&lt;\/li&gt;&lt;li&gt;&lt;a href=&quot;&quot;https:\/\/coolshell.cn\/articles\/9229.html&quot;&quot; target=&quot;&quot;_blank&quot;&quot; class=&quot;&quot;url&quot;&quot;&gt;https:\/\/coolshell.cn\/articles\/9229.html&lt;\/a&gt;&lt;\/li&gt;&lt;li&gt;&lt;a href=&quot;&quot;https:\/\/blog.csdn.net\/luanlouis\/article\/details\/39960815&quot;&quot; target=&quot;&quot;_blank&quot;&quot; class=&quot;&quot;url&quot;&quot;&gt;https:\/\/blog.csdn.net\/luanlouis\/article\/details\/39960815&lt;\/a&gt;&lt;\/li&gt;&lt;li&gt;\u300a\u5b9e\u6218 Java \u865a\u62df\u673a\u300b&lt;\/li&gt;&lt;\/ul&gt;<\/p>\n<p>&lt;pre&gt;&lt;code&gt;            &quot;&#8220;`<br \/>\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;`&#8221; \u6839\u636e Java \u865a\u62df\u673a\u89c4\u8303\uff0c\u7c7b\u6587\u4ef6\u7531\u5355\u4e2a ClassFile \u7ed3\u6784\u7ec4\u6210\uff1a &#038;l [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-37525","post","type-post","status-publish","format-standard","hentry","category-c"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/37525","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/comments?post=37525"}],"version-history":[{"count":1,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/37525\/revisions"}],"predecessor-version":[{"id":37526,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/37525\/revisions\/37526"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=37525"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=37525"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=37525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}