{"id":859,"date":"2018-07-20T08:58:55","date_gmt":"2018-07-20T00:58:55","guid":{"rendered":"https:\/\/blog.jsjs.org\/?p=859"},"modified":"2018-07-20T08:58:55","modified_gmt":"2018-07-20T00:58:55","slug":"%e3%80%90jvm%e3%80%91jvm%e7%b3%bb%e5%88%97%e4%b9%8bclass%e6%96%87%e4%bb%b6%ef%bc%88%e4%b8%89%ef%bc%89","status":"publish","type":"post","link":"https:\/\/blog.jsjs.org\/?p=859","title":{"rendered":"\u3010JVM\u3011JVM\u7cfb\u5217\u4e4bClass\u6587\u4ef6\uff08\u4e09\uff09"},"content":{"rendered":"<p><strong>\u4e00\u3001\u524d\u8a00<\/strong><\/p>\n<p>\u968f\u7740\u6211\u4eec\u5b66\u4e60\u7684\u4e0d\u65ad\u6df1\u5165\uff0c\u6211\u76f8\u4fe1\u8bfb\u8005\u5bf9class\u6587\u4ef6\u5f88\u611f\u5174\u8da3\uff0cclass\u6587\u4ef6\u662f\u7528\u6237\u7f16\u5199\u7a0b\u5e8f\u4e0e\u865a\u62df\u673a\u4e4b\u524d\u7684\u6865\u6881\uff0c\u7a0b\u5e8f\u901a\u8fc7\u7f16\u8bd1\u5f62\u6210class\u6587\u4ef6\uff0cclass\u6587\u4ef6\u4e4b\u540e\u4f1a\u8f7d\u5165\u865a\u62df\u673a\uff0c\u88ab\u865a\u62df\u673a\u6267\u884c\uff0c\u4e0b\u9762\u6211\u4e48\u6765\u4e00\u8d77\u63ed\u5f00class\u6587\u4ef6\u7684\u795e\u79d8\u9762\u7eb1\u3002<\/p>\n<p><strong>\u4e8c\u3001\u4ec0\u4e48\u662fclass\u6587\u4ef6<\/strong><\/p>\n<p>class\u6587\u4ef6\u662f\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u901a\u5e38\u662f\u4ee5.class\u6587\u4ef6\u7ed3\u5c3e\u7684\u6587\u4ef6\uff0c\u5b83\u662f\u4ee58\u4f4d\u5b57\u8282\u4e3a\u57fa\u7840\u5355\u4f4d\u7684\u4e8c\u8fdb\u5236\u6d41\uff0c\u5404\u4e2a\u6570\u636e\u9879\u7d27\u5bc6\u6392\u5217\u5728class\u6587\u4ef6\u4e2d\uff0c\u6570\u636e\u9879\u7684\u57fa\u672c\u7c7b\u578b\u4e3au1,u2,u4,u8\uff0c\u5206\u522b\u8868\u793a\u4e00\u4e2a\u5b57\u8282\uff0c\u4e24\u4e2a\u5b57\u8282\uff0c\u56db\u4e2a\u5b57\u8282,\u516b\u4e2a\u5b57\u8282\u7684\u65e0\u7b26\u53f7\u6570\u3002<\/p>\n<p><strong>\u4e09\u3001class\u6587\u4ef6\u6570\u636e\u7ed3\u6784<\/strong><\/p>\n<p>\u5176\u5b9e\u5bf9\u4e8eclass\u6587\u4ef6\u800c\u8a00\uff0c\u603b\u4f53\u7684\u6570\u636e\u7ed3\u6784\u770b\u4e0a\u53bb\u5f88\u89c4\u6574\uff0c\u5177\u4f53\u7684\u7ed3\u6784\u5982\u4e0b\u56fe\u6240\u793a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160310213644600-1619234754.png\" alt=\"\" \/><\/p>\n<p>\u4e0b\u9762\u6211\u4eec\u5c06\u7528\u4e00\u4e2a\u4f8b\u5b50\u8be6\u7ec6\u8bb2\u89e3class\u6587\u4ef6\u7684\u5404\u4e2a\u90e8\u5206\u3002<\/p>\n<p><strong>\u56db\u3001\u793a\u4f8b<\/strong><\/p>\n<div class=\"cnblogs_code\"><img decoding=\"async\" id=\"code_img_opened_e30dea02-71f2-4a8d-82c4-2102a2dd0b4b\" class=\"code_img_opened\" src=\"https:\/\/images.cnblogs.com\/OutliningIndicators\/ExpandedBlockStart.gif\" alt=\"\" \/><\/p>\n<div id=\"cnblogs_code_open_e30dea02-71f2-4a8d-82c4-2102a2dd0b4b\" class=\"cnblogs_code_hide\">\n<div class=\"cnblogs_code_toolbar\"><span class=\"cnblogs_code_copy\"><a title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/span><\/div>\n<pre>public class Test implements Cloneable {\n    private String name;\n    public Test() {\n\n    }\n\n    public Test(String name) {\n        this.name = name;\n    }\n\n    public void setName(String name) {\n        this.name = name;\n    }\n\n    public String getName() {\n        return name;\n    }\n}<\/pre>\n<div class=\"cnblogs_code_toolbar\"><span class=\"cnblogs_code_copy\"><a title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/span><\/div>\n<\/div>\n<\/div>\n<p>\u8bf4\u660e\uff1a\u4ee5\u4e0a\u662f\u4e00\u4e2a\u5f88\u7b80\u5355\u548c\u901a\u7528\u7684\u7c7b\uff0c\u4e0b\u9762\u6211\u4eec\u7684\u5206\u6790\u90fd\u5c06\u57fa\u4e8e\u8fd9\u4e2a\u7c7b\u3002<\/p>\n<p>\u7ecf\u8fc7\u7f16\u8bd1\u540e\uff0c\u5f97\u5230class\u6587\u4ef6\uff0c\u4f7f\u7528WinHex\u6253\u5f00\uff0cclass\u6587\u4ef6\u5185\u5bb9\u5982\u4e0b<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160310214438538-1775905015.png\" alt=\"\" \/><\/p>\n<p>\u4e0b\u9762\u6211\u4eec\u5c06\u4ece\u8fd9\u4e2a\u6587\u4ef6\u7684\u5185\u5bb9\u5165\u624b\uff0c\u6162\u6162\u5206\u6790class\u6587\u4ef6\u5404\u4e2a\u90e8\u5206\u3002<\/p>\n<p><strong>\u4e94\u3001class\u5185\u5bb9\u8be6\u89e3<\/strong><\/p>\n<p>5.1 magic<\/p>\n<p>class\u6587\u4ef6\u7684\u6700\u5f00\u59cb4\u4e2a\u5b57\u8282\u4e3amagic\uff08\u9b54\u6570\uff09\uff0c\u7528\u6765\u786e\u5b9a\u8be5class\u6587\u4ef6\u80fd\u591f\u88ab\u865a\u62df\u673a\u63a5\u53d7\u3002\u800c\u5728\u6211\u4eec\u7684class\u6587\u4ef6\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u6700\u5f00\u59cb4\u4e2a\u5b57\u8282\u662fCAFEBABE\u3002\u6240\u6709\u7684class\u6587\u4ef6\u7684\u5f00\u59cb4\u4e2a\u5b57\u8282\u90fd\u662fCAFEBABE\u3002<\/p>\n<p>5.2 minor_version &amp;&amp; major_version<\/p>\n<p>\u4e3b\u6b21\u7248\u672c\u53f7\uff0c\u4f1a\u968f\u7740Java\u6280\u672f\u7684\u53d1\u5c55\u800c\u53d8\u5316\uff0c\u8868\u793a\u865a\u62df\u673a\u80fd\u591f\u5904\u7406\u7684\u7248\u672c\u53f7\u3002\u5728magic\u4e4b\u540e\u7684minor_version\u548cmajor_version\u5206\u522b\u662f0\u548c52\uff0852 = 3 * 16 + 4\uff09\u3002<\/p>\n<p>5.3 constant_pool_count &amp;&amp; constant_pool<\/p>\n<p>\u5e38\u91cf\u6c60\u4e2d\u5e38\u91cf\u8868\u7684\u6570\u91cf\u548c\u5e38\u91cf\u8868\uff0c\u5e38\u91cf\u6c60\u4e2d\u7684\u6bcf\u4e00\u9879\u662f\u5e38\u91cf\u8868\uff0c\u5177\u4f53\u7684\u5e38\u91cf\u8868\u5305\u542b\u7c7b\u548c\u63a5\u53e3\u76f8\u5173\u7684\u5e38\u91cf\uff0c\u5b58\u4e86\u5f88\u591a\u5b57\u9762\u91cf\u548c\u7b26\u53f7\u5f15\u7528\u3002\u5b57\u9762\u91cf\u4e3b\u8981\u5305\u62ec\u4e86\u6587\u672c\u5b57\u7b26\u4e32\u548cfinal\u5e38\u91cf\u3002\u7b26\u53f7\u5f15\u7528\u5305\u62ec\uff1a1. \u7c7b\u548c\u63a5\u53e3\u7684\u5168\u9650\u5b9a\u540d 2. \u5b57\u6bb5\u7684\u540d\u79f0\u548c\u63cf\u8ff0\u7b26 3. \u65b9\u6cd5\u7684\u540d\u79f0\u548c\u63cf\u8ff0\u7b26\u3002<\/p>\n<p>\u5e38\u91cf\u6c60\u4e2d\u7684\u9879\u76ee\u5305\u542b\u5982\u4e0b\u7c7b\u578b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160310221949054-2064309213.png\" alt=\"\" \/><\/p>\n<p>\u4ece\u4e0a\u9762\u7684\u56fe\u4e2d\u6211\u4eec\u53ef\u4ee5\u77e5\u9053\uff0c\u5e38\u91cf\u6c60\u4e2d\u5e38\u91cf\u9879\uff08\u5e38\u91cf\u9879\u90fd\u5bf9\u5e94\u4e00\u4e2a\u8868\uff09\u4e3a23\uff0823 = 1 * 16 + 7\uff09\uff0c\u503c\u5f97\u6ce8\u610f\u7684\u662f\u5e38\u91cf\u9879\u7684\u7d22\u5f15\u503c\u4ece1\u5f00\u59cb\uff0c\u523022\uff0c\u603b\u517122\u9879\uff0c\u7d22\u5f15\u503c\u4e3a0\u7684\u9879\u9884\u7559\u51fa\u6765\uff0c\u6682\u65f6\u8fd8\u672a\u4f7f\u7528\u3002\u7d27\u63a5\u7740\u5c31\u662f\u5e38\u91cf\u9879\uff0c\u6bcf\u4e2a\u5e38\u91cf\u9879\u7684\u7b2c\u4e00\u4e2a\u5b57\u8282u1\u8868\u793a\u6807\u5fd7(tag)\uff0c\u6807\u5fd7(tag)\u8868\u793a\u662f\u4ec0\u4e48\u7c7b\u578b\u7684\u9879\u76ee\uff0c\u6807\u5fd7\u7684\u503c\u4e3a\u4e0a\u8868\u7ed9\u51fa\u7684\u503c\uff0c\u5982\u6807\u5fd7\u4e3a1(tag = 1)\uff0c\u8868\u793aCONSTANT_Utf8_info\u9879\u76ee\u3002\u4e0a\u56fe\u4e2d\u7684\u7b2c\u4e00\u4e2a\u5e38\u91cf\u9879\u4e3a\u7684\u6807\u5fd7tag\u7684\u503c\u4e3a10\uff0810 = 0 * 16 + A\uff09\uff0c\u4e3aCONSTANT_Methodreef_info\u8868\uff0c\u8868\u793a\u7c7b\u4e2d\u65b9\u6cd5\u7684\u7b26\u53f7\u5f15\u7528\u3002\u5176\u4e2dCONSTANT_Methodref_info\u8868\u7684\u7ed3\u6784\u5982\u4e0b<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160311093136632-916523880.png\" alt=\"\" \/><\/p>\n<p>\u63a5\u7740\uff0c\u5728tag\u540e\u9762\u662fu2\u7c7b\u578b\u7684index\u9879\u76ee\uff0c\u4e3a4\uff084 = 0 * 16 + 4\uff09\uff0c\u8868\u793a\u6307\u5411\u5e38\u91cf\u6c60\u7684\u7b2c\u56db\u9879\uff0c\u7531\u63cf\u8ff0\u53ef\u77e5\uff0c\u7b2c\u56db\u9879\u5e94\u8be5\u662fCONSTANT_Class_info\u9879\uff0c\u63a5\u7740\uff0c\u53c8\u662fu2\u7c7b\u578b\u7684index\u9879\u76ee\uff0c\u4e3a18\uff0818 = 1 * 16 + 2\uff09\uff0c\u8868\u793a\u6307\u5411\u5e38\u91cf\u6c60\u7684\u7b2c18\u9879\uff0c\u7531\u8868\u7684\u63cf\u8ff0\u53ef\u77e5\uff0c\u7b2c\u5341\u516b\u9879\u5e94\u8be5\u662fCONSTANT_NameAndType_info\u9879\uff0c\u6b63\u786e\u6027\u6211\u4eec\u4e4b\u540e\u8fdb\u884c\u9a8c\u8bc1\u3002\u7b2c\u4e00\u4e2a\u5e38\u91cf\u9879CONSTANT_Methodref_info\u5c31\u5b8c\u4e86\u3002<\/p>\n<p>\u7d27\u63a5\u7740\u7b2c\u4e00\u4e2a\u5e38\u91cf\u9879\u662f\u7b2c\u4e8c\u4e2a\u5e38\u91cf\u9879\uff0ctag\u4e3a9\uff080 * 16 + 9\uff09\uff0c\u8868\u793aCONSTANT_Fieldref_info\u8868\uff0c\u8868\u793a\u5b57\u6bb5\u7684\u7b26\u53f7\u5f15\u7528\u3002CONSTANT_Field_info\u7684\u8868\u7ed3\u6784\u5982\u4e0b<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160311093145585-462607895.png\" alt=\"\" \/><\/p>\n<p>\u63a5\u7740\uff0c\u5728tag\u540e\u9762\u7684\u662fu2\u7c7b\u578b\u7684index\u9879\u76ee\uff0c\u4e3a3\uff080 * 16 + 3\uff09\uff0c\u8868\u793a\u6307\u5411\u5e38\u91cf\u6c60\u7684\u7b2c\u4e09\u9879\uff0c\u5e94\u8be5\u4e3aCONSTANT_Class_info\u9879\uff0c\u7d27\u63a5\u7740\u662findex\u9879\u76ee\uff0c\u4e3a19\uff081 * 16 + 3\uff09\uff0c\u8868\u793a\u6307\u5411\u5e38\u91cf\u6c60\u7684\u7b2c19\u9879\uff0c\u5e94\u8be5\u662fCONSTANT_NameAndType_info\u9879\u3002<\/p>\n<p>\u63a5\u7740\uff0c\u662f\u7b2c\u4e09\u9879\u5e38\u91cf\uff0ctag\u4e3a7\uff080 * 16 + 7\uff09\uff0c\u8868\u793aCONSTANT_Class_info\u8868\uff0c\u5176\u4e2d\uff0c\u5176\u8868\u7ed3\u6784\u5982\u4e0b<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160311093938725-906425801.png\" alt=\"\" \/><\/p>\n<p>\u63a5\u7740tag\u7684\u4e3a\u7c7b\u578b\u4e3au2\u7684index\uff0c\u4e3a20\uff081 * 16 + 4\uff09\uff0c\u8868\u793a\u6307\u5411\u5e38\u91cf\u6c60\u7684\u7b2c\u4e8c\u5341\u9879\uff0c\u8868\u793a\u5168\u9650\u5b9a\u540d\u3002<\/p>\n<p>\u63a5\u7740\u7b2c\u56db\u9879\u5e38\u91cf\uff0ctag\u4e3a7(0 * 16 + 7)\uff0c\u8868\u793aCONSTANT_Class_info\u8868\uff0c\u8868\u7ed3\u6784\u5df2\u7ecf\u4ecb\u7ecd\u4e86\uff0c\u63a5\u7740\u662fu2\u7684index\uff0c\u4e3a21\uff081 * 16 + 5\uff09\uff0c\u8868\u793a\u6307\u5411\u5168\u9650\u5b9a\u540d\u3002<\/p>\n<p>\u63a5\u7740\u7b2c\u4e94\u9879\u5e38\u91cf\uff0ctag\u4e3a7\uff0cu2\u7684\u7c7b\u578b\u7684index\u4e3a22\uff081 * 16 + 6\uff09\uff0c\u8868\u793a\u6307\u5411\u5168\u9650\u5b9a\u540d\u3002<\/p>\n<p>\u540c\u7406\uff0c\u6309\u7167\u8fd9\u6837\u7684\u65b9\u6cd5\u8fdb\u884c\u5206\u6790\uff0c\u6700\u540e\u7ed9\u51fa\u4e00\u4e2a\u603b\u7684\u5e38\u91cf\u6c60\u8868\u5982\u4e0b\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160311101644460-1109447947.png\" alt=\"\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>\u8bf4\u660e\uff1a#\u8868\u793a\u5e38\u91cf\u9879\u7684\u7d22\u5f15\uff0cUtf8\u8868\u4e2d\u5b58\u653e\u7684\u662f\u5177\u4f53\u7684\u5b57\u7b26\u4e32\u3002\u5982#6\u4e2d\u5b58\u653e\u7684\u5c31\u662f\u5b57\u7b26\u4e32name\uff0c#10\u4e2d\u5b58\u653e\u7684\u5c31\u662f\u5b57\u7b26\u4e32Code\uff0c\u5173\u4e8e\u8868\u793a\u7684\u5177\u4f53\u542b\u4e49\uff0c\u6211\u4eec\u7a0d\u540e\u4f1a\u8fdb\u884c\u89e3\u91ca\u3002<\/p>\n<p>\u9664\u53bb\u6211\u4eec\u4e4b\u524d\u4ecb\u7ecd\u7684\u5e38\u91cf\u8868\u7ed3\u6784\uff0c\u5e38\u91cf\u6c60\u4e2d\u5176\u4ed6\u5e38\u91cf\u8868\u7684\u7ed3\u6784\u5206\u522b\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160311104521538-1970162952.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160311104604179-1189853257.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160311104653288-790751167.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160311105520288-2143520183.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160311105531616-1046741443.png\" alt=\"\" \/><\/p>\n<p>\u8bf4\u660e\uff1a\u63cf\u8ff0\u7b26\u5206\u4e3a\u5b57\u6bb5\u63cf\u8ff0\u7b26\u548c\u65b9\u6cd5\u63cf\u8ff0\u7b26\uff0c\u5b57\u6bb5\u63cf\u8ff0\u7b26\u7528\u6765\u63cf\u8ff0\u5b57\u6bb5\u7684\u6570\u636e\u7c7b\u578b\uff0c\u65b9\u6cd5\u7684\u63cf\u8ff0\u7b26\u7528\u6765\u63cf\u8ff0\u65b9\u6cd5\u7684\u53c2\u6570\u5217\u8868\uff08\u5305\u62ec\u6570\u91cf\u3001\u7c7b\u578b\u3001\u987a\u5e8f\uff09\u548c\u8fd4\u56de\u503c\u3002\u57fa\u672c\u7c7b\u578b\u548c\u5bf9\u8c61\u7684\u63cf\u8ff0\u7b26\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160311111039710-206649907.png\" alt=\"\" \/><\/p>\n<p>\u8bf4\u660e\uff1a\u4e0a\u8868\u4e2d\u5e76\u6ca1\u6709\u6307\u51fa\u51fa\u73b0\u6570\u7ec4\u4e86\u5982\u4f55\u63cf\u8ff0\uff0c\u6bcf\u4e00\u4e2a\u7ef4\u5ea6\u4f7f\u7528\u4e00\u4e2a\u524d\u7f6e\u7684&#8221;[&#8220;\u6765\u63cf\u8ff0\uff0c\u5982int[]\u63cf\u8ff0\u4e3a[I\uff0cString[]\u63cf\u8ff0\u4e3a[Ljava\/lang\/String\uff1blong\u7c7b\u578b\u662f\u4f7f\u7528\u5b57\u7b26J\u8fdb\u884c\u6807\u8bc6\uff0c\u5bf9\u8c61\u7c7b\u578b\u662f\u4f7f\u7528L\u5b57\u7b26\u8fdb\u884c\u6807\u8bc6\u3002\u5982String\u7c7b\u578b\u63cf\u8ff0\u4e3aLjava\/lang\/String;short\u7c7b\u578b\u63cf\u8ff0\u4e3aS,\u5bf9\u4e8e\u65b9\u6cd5\u63cf\u8ff0\u7b26\u800c\u8a00\uff0c\u6309\u7167\u5148\u53c2\u6570\u5217\u8868\uff0c\u540e\u8fd4\u56de\u503c\u8fdb\u884c\u63cf\u8ff0\uff0c\u53c2\u6570\u5217\u8868\u6309\u7167\u53c2\u6570\u987a\u5e8f\u653e\u5728\u5c0f\u62ec\u53f7&#8221;()&#8221;\u5185\u90e8\uff0c\u5982void inc(int i)\u63cf\u8ff0\u4e3a(I)V\uff1bint getName()\u63cf\u8ff0\u4e3a()I\uff1bvoid setName(String name)\u63cf\u8ff0\u4e3a(Ljava\/lang\/String)V\uff1b\u65b9\u6cd5\u7684\u63cf\u8ff0\u7b26\u4e0e\u65b9\u6cd5\u540d\u79f0\u662f\u5206\u5f00\u8fdb\u884c\u7684\uff0c\u65b9\u6cd5\u63cf\u8ff0\u4e2d\u5e76\u6ca1\u6709\u5305\u542b\u65b9\u6cd5\u540d\u3002<\/p>\n<p>5.4 access_flags<\/p>\n<p>\u5e38\u91cf\u6c60\u540e\u7684\u4e24\u4e2a\u5b57\u8282\uff0c\u7528\u4e8e\u8bc6\u522b\u7c7b\u6216\u63a5\u53e3\u5c42\u6b21\u7684\u8bbf\u95ee\u4fe1\u606f\uff0c\u5982\uff0c\u8fd9\u4e2aclass\u662f\u7c7b\u6216\u8005\u662f\u63a5\u53e3\uff0c\u662f\u5426\u4e3apublic\uff0cabstract,final\u7b49\u7b49\u3002\u5177\u4f53\u7684\u6807\u5fd7\u542b\u4e49\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160311112849694-1386227498.png\" alt=\"\" \/><\/p>\n<p>\u8bf4\u660e\uff1a\u5176\u4e2dACC_INTERFACE\u4e0eACC_FINAL\u4e0d\u80fd\u540c\u65f6\u5b58\u5728\u3002<\/p>\n<p>\u4ece\u4e4b\u524d\u7684\u5b57\u8282\u7801\u4e2d\u53ef\u4ee5\u77e5\u9053\uff0caccess_flags\u4e3a0x0021\uff080x0021 = 0x0020|0x0001\uff09\uff0c\u5373\u4e3apublic\uff0c\u5e76\u4e14\u5141\u8bb8\u4f7f\u7528invokespecial\u5b57\u8282\u7801\u3002<\/p>\n<p>5.5 this_class<\/p>\n<p>\u63a5\u7740access_flags\u540e\u9762\u7684u2\u7c7b\u578b\u7684this_class\uff0c\u8868\u793a\u5bf9\u5e38\u91cf\u6c60\u7684\u7d22\u5f15\uff0c\u8be5\u7d22\u5f15\u9879\u4e3aCONSTANT_Class_info\u7c7b\u578b\uff0c\u4ece\u524d\u9762\u6211\u4eec\u77e5\u9053this_class\u4e3a0x0003\uff0c\u8868\u793a\u5bf9\u5e38\u91cf\u6c60\u7b2c\u4e09\u9879\u7684\u7d22\u5f15\uff0c\u7b2c\u4e09\u9879\u6211\u4eec\u77e5\u9053\u786e\u5b9e\u662fCONSTANT_Class_info\u7c7b\u578b\uff0c\u800c\u7b2c\u4e09\u9879\u6240\u8868\u793a\u7684\u5185\u5bb9\u4e3aTest\uff0c\u5373\u8868\u793a\u5f53\u524d\u7c7b\u3002<\/p>\n<p>5.6 super_class<\/p>\n<p>\u63a5\u7740this_class\u540e\u9762\u7684\u662fu2\u7c7b\u578b\u7684super_class\uff0c\u8868\u793a\u5bf9\u5e38\u91cf\u6c60\u7684\u7d22\u5f15\uff0c\u4ece\u524d\u9762\u6211\u4eec\u77e5\u9053super_class\u4e3a0x0004\uff0c\u8868\u793a\u5bf9\u5e38\u91cf\u6c60\u7b2c\u56db\u9879\u7684\u7d22\u5f15\uff0c\u7b2c\u56db\u9879\u6211\u4eec\u77e5\u9053\u662fCONSTANT_Class_info\u7c7b\u578b\uff0c\u800c\u7b2c\u56db\u9879\u6240\u8868\u793a\u7684\u5185\u5bb9\u4e3ajava\/lang\/Object\uff0c\u8868\u793aTest\u7684\u7236\u7c7b\u4e3aObject\u7c7b\u3002<\/p>\n<p>5.7 interfaces_count &amp;&amp; interfaces<\/p>\n<p>\u63a5\u7740super_class\u540e\u9762\u7684u2\u7c7b\u578b\u8868\u793a\u63a5\u53e3\u6570\u91cf\uff0c\u6b64\u63a5\u53e3\u6570\u91cf\u4e3a\u8be5\u7c7b\u76f4\u63a5\u5b9e\u73b0\u6216\u8005\u7531\u63a5\u53e3\u6240\u6269\u5c55\u63a5\u53e3\u7684\u6570\u91cf\u3002\u4ece\u524d\u9762\u6211\u4eec\u53ef\u4ee5\u77e5\u9053\uff0cinterfaces_count\u4e3a0x0001\uff0c\u8868\u793a\u63a5\u53e3\u6570\u91cf\u4e3a1\uff0c\u4ece\u7a0b\u5e8f\u4e2d\u6211\u4eec\u4e5f\u53ef\u4ee5\u77e5\u9053\u786e\u5b9e\u662f\u53ea\u5b9e\u73b0\u4e86Cloneable\u63a5\u53e3\u3002<\/p>\n<p>\u63a5\u7740\u5c31\u662f\u7c7b\u578b\u4e3au2\u7684interfaces,\u8868\u793a\u5bf9\u5e38\u91cf\u6c60\u7684\u7d22\u5f15\uff0c\u503c\u4e3a0x0005\uff0c\u8868\u793a\u5bf9\u7b2c\u4e94\u9879\u7684\u7d22\u5f15\uff0c\u7b2c\u4e94\u9879\u4e3aCONSTANT_Class_info\u7c7b\u578b\uff0c\u6240\u8868\u793a\u7684\u5185\u5bb9\u4e3ajava\/lang\/Cloneable\uff0c\u4ece\u6e90\u7a0b\u5e8f\u6211\u4eec\u53ef\u4ee5\u8fdb\u884c\u9a8c\u8bc1\u3002<\/p>\n<p>5.8 fields_count &amp;&amp; fields<\/p>\n<p>\u63a5\u7740interfaces\u540e\u9762\u7684\u662f\u7c7b\u578b\u4e3au2\u7684fields_count\uff08\u5305\u62ec\u7c7b\u53d8\u91cf\u548c\u5b9e\u4f8b\u53d8\u91cf\uff0c\u4e0d\u5305\u62ec\u5c40\u90e8\u53d8\u91cf\uff09\uff0c\u503c\u4e3a0x0001\uff0c\u4e3a1\uff0c\u4ece\u6e90\u7a0b\u5e8f\u6211\u4eec\u77e5\u9053\u53ea\u58f0\u660e\u4e86\u4e00\u4e2a\u5b9e\u4f8b\u53d8\u91cfname\uff0c\u6240\u4ee5\u4e3a1\u3002\u63a5\u7740fields_count\u7684\u662f\u7c7b\u578b\u4e3afields_info\u8868\uff0cfield_info\u8868\u7684\u5177\u4f53\u7ed3\u6784\u5982\u4e0b<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160311144014710-435694404.png\" alt=\"\" \/><\/p>\n<p>\u63a5\u7740fields_count\u540e\u7684\u662ffield_info\u8868\uff0c\u9996\u5148\u662fu2\u7c7b\u578b\u7684access_flags\uff0caccess_flags\u7684\u5177\u4f53\u542b\u4e49\u5982\u4e0b\u8868\u6240\u793a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160311145543163-870100703.png\" alt=\"\" \/>\u3000\u3000\u8bf4\u660e\uff1apublic\u3001private\u3001protected\u53ea\u80fd\u4f1a\u6709\u4e00\u4e2a\u6709\u6548\u3002final\u3001volatile\u53ea\u80fd\u6709\u4e00\u4e2a\u6709\u6548\u3002<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u77e5\u9053access_flags\u4e3a0x0002\uff0c\u8868\u793a\u4e3aprivate\uff0c\u7d27\u63a5\u7740\u662f\u7c7b\u578b\u4e3au2\u7684name_index\uff0c\u503c\u4e3a0x0006\uff0c\u8868\u793a\u5bf9\u5e38\u91cf\u6c60\u7b2c\u516d\u9879\u7684\u7d22\u5f15\uff0c\u5e38\u91cf\u6c60\u7b2c\u516d\u9879\u4e3aClass_Utf8_info\u7c7b\u578b\uff0c\u5185\u5bb9\u4e3aname\uff0c\u5219\u8868\u793a\u4e86\u5b57\u6bb5\u7684\u540d\u79f0\u3002\u63a5\u7740\u662f\u7c7b\u578b\u4e3au2\u7684descriptor_index\uff0c\u503c\u4e3a0x0007\uff0c\u8868\u793a\u5bf9\u5e38\u91cf\u6c60\u7b2c\u4e03\u9879\u7684\u7d22\u5f15\uff0c\u5e38\u91cf\u6c60\u7b2c\u4e03\u9879\u4e3aClass_Utf8_info\u7c7b\u578b\uff0c\u5185\u5bb9\u4e3aLjava\/lang\/String\uff0c\u7d27\u63a5\u7740\u662f\u7c7b\u578b\u4e3au2\u7684attributes_count\uff0c\u4e3a0x0000\uff0c\u8868\u793afield_info\u8868\u6ca1\u6709\u5d4c\u5957attribute_info\u8868\u3002<\/p>\n<p>\u6700\u540e\u7684field_info\u8868\u7ed3\u6784\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160312084351616-327859907.png\" alt=\"\" \/><\/p>\n<p>5.9 methods_count &amp;&amp; methods<\/p>\n<p>fields\u540e\u9762\u7684\u662f\u7c7b\u578b\u4e3au2\u7684methods_count\uff0cmethods_count\u7684\u8ba1\u6570\u53ea\u5305\u62ec\u5728\u8be5\u7c7b\u6216\u63a5\u53e3\u4e2d\u663e\u793a\u5b9a\u4e49\u7684\u65b9\u6cd5\uff0c\u4e0d\u5305\u62ec\u4ece\u8d85\u7c7b\u6216\u7236\u63a5\u53e3\u7ee7\u627f\u6765\u7684\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u77e5\u9053methods_count\u7684\u503c\u4e3a0x0004\uff0c\u8868\u793a\u6709\u56db\u4e2a\u65b9\u6cd5\uff0c\u4ece\u6e90\u7a0b\u5e8f\u6211\u4eec\u4e5f\u53ef\u4ee5\u8fdb\u884c\u9a8c\u8bc1\u3002\u7d27\u63a5\u7740methods_count\u7684\u662fmethod_info\u8868\uff0cmethod_info\u8868\u7684\u5177\u4f53\u7ed3\u6784\u5982\u4e0b\uff08\u4e0efield_info\u5b8c\u5168\u76f8\u540c\uff09<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160311151636663-1837427219.png\" alt=\"\" \/><\/p>\n<p>\u800c\u5bf9\u4e8eaccess_flags\u6807\u5fd7\u79cd\u7c7b\u5982\u4e0b<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160311152514975-2035125564.png\" alt=\"\" \/><\/p>\n<p>method_count\u4e3a4\u8868\u793a\u63a5\u4e0b\u6765\u67094\u4e2amethod_info\u8868\u3002<\/p>\n<p>\u9996\u5148\u662f\u7b2c\u4e00\u4e2amethod_info\u8868\uff0cu2\u7c7b\u578b\u7684access_flags\uff0c\u4e3a0x0001\uff0c\u8868\u793apublic\uff0c\u63a5\u7740\u662f\u7c7b\u578b\u4e3au2\u7684name_index\uff0c\u4e3a0x0008\uff0c\u8868\u793a\u5bf9\u5e38\u91cf\u6c60\u7b2c\u516b\u9879\u7684\u7d22\u5f15\uff0c\u7b2c\u516b\u9879\u4e3aClass_Utf8_info\u7c7b\u578b\uff0c\u5185\u5bb9\u4e3a&lt;init&gt;\uff0c\u8868\u793a\u5b9e\u4f8b\u521d\u59cb\u5316\u65b9\u6cd5\uff0c\u7531\u7f16\u8bd1\u5668\u4ea7\u751f\uff1b\u63a5\u7740\u662f\u7c7b\u578b\u4e3au2\u7684descriptor_index\uff0c\u4e3a0x0009\uff0c\u8868\u793a\u5bf9\u5e38\u91cf\u6c60\u7b2c\u4e5d\u9879\u7684\u7d22\u5f15\uff0c\u7b2c\u4e5d\u9879\u4e3aClass_Utf8_info\u7c7b\u578b\uff0c\u5185\u5bb9\u4e3a()V\uff0c\u8868\u793a\u53c2\u6570\u4e3a\u7a7a\uff0c\u8fd4\u56de\u503c\u4e3avoid\uff0c\u63a5\u7740\u662f\u7c7b\u578b\u4e3au2\u7684attributes_count\uff0c\u4e3a0x0001\uff0c\u8868\u793a\u6709\u4e00\u4e2a\u5c5e\u6027\u8868\uff1b\u63a5\u7740\u662fattribute_info\u8868\uff0cattribute_info\u8868\u7684\u7ed3\u6784\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160311154034022-12331292.png\" alt=\"\" \/><\/p>\n<p>\u63a5\u7740attributes_count\u7684\u662f\u7c7b\u578b\u4e3au2\u7684attribute_name_index\uff0c\u4e3a0x000A\uff0c\u6307\u5411\u5e38\u91cf\u6c60\u7b2c\u5341\u9879\u7d22\u5f15\uff0c\u7b2c\u5341\u9879\u7c7b\u578b\u4e3aClass_Utf8_info\u7c7b\u578b\uff0c\u5185\u5bb9\u4e3aCode\uff0cCode\u5c5e\u6027\u8868\u793a\u5c5e\u6027\u7684\u5177\u4f53\u7c7b\u522b\uff1b\u63a5\u7740\u662f\u7c7b\u578b\u4e3au4\u7684attribute_length\uff0c\u4e3a0x00000021\uff0c\u8868\u793a\u5c5e\u6027\u957f\u5ea6\u4e3a33\uff082 * 16 + 1\uff09\uff0c\u63a5\u7740\u5c31\u662f\u5177\u4f53\u6bcf\u4e2a\u5c5e\u6027\u7684info\u4fe1\u606f\uff0c\u5bf9\u4e8eCode\u5c5e\u6027\u800c\u8a00\uff0c\u5176\u7ed3\u6784\u5982\u4e0b<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160311155720382-2117149331.png\" alt=\"\" \/><\/p>\n<p>\u63a5\u7740attribute_length\u7684\u662f\u7c7b\u578b\u4e3au2\u7684max_stack\uff0c\u4e3a0x0001\uff0c\u8868\u793a\u64cd\u4f5c\u6570\u6808\u7684\u6700\u5927\u6df1\u5ea6\uff0c\u63a5\u7740max_stack\u7684\u662f\u7c7b\u578b\u4e3au2\u7684max_locals\uff0c\u4e3a0x0001\uff0c\u8868\u793a\u5c40\u90e8\u53d8\u91cf\u6240\u9700\u7684\u5b58\u50a8\u7a7a\u95f4\u5927\u5c0f\u4e3a1\uff0c\u5c40\u90e8\u53d8\u91cf\u8868\u7684\u5355\u4f4d\u4e3aslot\uff0c(byte\u3001char\u3001float\u3001int\u3001short\u3001boolean\u7b49\u4e0d\u8d85\u8fc732\u4e3a\u7684\u6570\u636e\u7c7b\u578b\u53ea\u5360\u636e\u4e00\u4e2aslot\uff0cdouble\u3001long64\u4e3a\u6570\u636e\u7c7b\u578b\u9700\u8981\u4e24\u4e2aslot)\uff0c\u5c40\u90e8\u53d8\u91cf\u8868\u53ef\u4ee5\u5b58\u653e\u65b9\u6cd5\u53c2\u6570\uff08\u5b9e\u4f8b\u65b9\u6cd5\u7684this\u5f15\u7528\uff09\u3001\u663e\u5f0f\u5904\u7406\u5668\u7684\u53c2\u6570catch\u4e2d\u6240\u5b9a\u4e49\u7684\u5f02\u5e38\u3001\u65b9\u6cd5\u4f53\u4e2d\u5b9a\u4e49\u7684\u5c40\u90e8\u53d8\u91cf\u3002\u63a5\u7740max_locals\u7684\u662f\u7c7b\u578b\u4e3au4\u7684code_length\uff0c\u4e3a0x00000005\uff0c\u4e3a5\uff0c\u8868\u793acode\u4ee3\u7801\u7684\u957f\u5ea6\u4e3a5\uff0c\u63a5\u7740code\u7684\u662f\u7c7b\u578b\u4e3au2\u7684exception_table_length\uff0c\u4e3a0x0000\uff0c\u8868\u793a\u4e0d\u5b58\u5728\u5f02\u5e38\u8868\uff0c\u63a5\u7740\u662f\u7c7b\u578b\u4e3au2\u7684attributes_count(exception_table_length\u4e3a0)\uff0c\u4e3a0x0001\uff0c\u4e3a1\uff0c\u8868\u793a\u5c5e\u6027\u6570\u91cf\u4e3a1\uff0c\u8868\u793a\u6709\u4e00\u4e2a\u5c5e\u6027\u8868\uff0c\u63a5\u7740\u5c31\u662fattribute_info\u8868\uff0c\u7c7b\u578b\u4e3au2\u7684attribute_name_index\uff0c\u4e3a0x000B\uff0c\u8868\u793a\u5bf9\u5e38\u91cf\u6c60\u7b2c11\u9879\u7d22\u5f15\uff0c\u7b2c11\u9879\u7c7b\u578b\u4e3aClass_Utf8_info\uff0c\u5185\u5bb9\u4e3aLineNumberTable\uff0c\u8868\u793a\u5177\u4f53\u7684\u5c5e\u6027\uff0cLineNumberTable\u7684\u5177\u4f53\u7ed3\u6784\u5982\u4e0b\u56fe\u6240\u793a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160311162413616-765936849.png\" alt=\"\" \/><\/p>\n<p>\u63a5\u7740attribute_name_index\u7684\u662f\u7c7b\u578b\u4e3au4\u7684attribute_length\uff0c\u4e3a0x0000000A\uff0c\u957f\u5ea6\u4e3a10\uff0c\u8868\u793a\u5c5e\u6027\u957f\u5ea6\u4e3a10\uff0c\u63a5\u7740attribute_length\u7684\u662f\u7c7b\u578b\u4e3au2\u7684line_number_table_length\uff0c\u4e3a0x0002\uff0c\u4e3a2\uff0c\u8868\u793a\u6709\u4e24\u4e2aline_number_info\u8868\uff0cline_number_info\u8868\u7684\u5177\u4f53\u7ed3\u6784\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160311162923741-2146004795.png\" alt=\"\" \/><\/p>\n<p>\u9996\u5148\u662f\u7b2c\u4e00\u4e2aline_number_info\u8868\uff0c\u7c7b\u578b\u4e3au2\u7684start_pc\uff0c\u4e3a0x0000\uff0c\u4e3a0\uff1b\u63a5\u7740\u662f\u7c7b\u578b\u4e3au2\u7684line_number\uff0c\u4e3a0x0003\uff0c\u4e3a3\u3002\u7b2c\u4e8c\u4e2aline_number_info\u8868\uff0c\u7c7b\u578b\u4e3au2\u7684start_pc\uff0c\u4e3a0x0004\uff0c\u4e3a4\uff0c\u63a5\u7740\u662fline_number\uff0c\u4e3a0x0005\uff0c\u4e3a5\uff1b<\/p>\n<p>\u81f3\u6b64\uff0c\u7b2c\u4e00\u4e2amethod_info\u8868\u5c31\u5df2\u7ecf\u5206\u6790\u5b8c\u4e86\uff0c\u7b2c\u4e00\u4e2amethod_info\u8868\u7684\u5305\u542b\u7ed3\u6784\u5982\u4e0b\u56fe\u6240\u793a\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160311164521241-409161990.png\" alt=\"\" \/><\/p>\n<p>\u7b2c\u4e8c\u4e2a\u3001\u7b2c\u4e09\u4e2a\u3001\u7b2c\u56db\u4e2aMethod_info\u90fd\u53ef\u4ee5\u6309\u7167\u7b2c\u4e00\u4e2aMethod_info\u8868\u7684\u65b9\u6cd5\u8fdb\u884c\u7c7b\u63a8\u3002\u6700\u540e\u76844\u4e2a\u8868\u7684\u8bf4\u660e\u5982\u4e0b<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160312083412179-1069179394.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160312083435225-272148819.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160312083631694-1784949530.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160312083641413-437391320.png\" alt=\"\" \/><\/p>\n<p>\u9664\u4e86\u4e0a\u9762\u4ecb\u7ecd\u7684\u5c5e\u6027\u8868\u4e4b\u5916\uff0c\u8fd8\u6709\u5176\u4ed6\u7684\u5c5e\u6027\u8868\uff0c\u4e0b\u9762\u8fdb\u884c\u4ecb\u7ecd\u3002<\/p>\n<p>5.10 attributes_count &amp;&amp; attributes<\/p>\n<p>\u63a5\u5728methods\u540e\u9762\u7684\u662fattributes_count\uff0cattributes_count\u4e3a0x0001\uff0c\u8868\u793a\u6709\u4e00\u4e2aattribute_info\u8868\uff0c\u63a5\u7740attribute_count\u540e\u9762\u7684\u662fattribute_name_index\uff0c\u4e3a0x0010\uff0c\u8868\u793a\u6307\u5411\u5e38\u91cf\u6c60\u7b2c16\u9879\u7684\u7d22\u5f15\uff0c\u7b2c16\u9879\u7c7b\u578b\u4e3aClass_Utf8_info\u7c7b\u578b\uff0c\u5185\u5bb9\u4e3aSourceFile\uff0c\u8868\u793a\u5c5e\u6027\u4e3aSourceFile\uff0cSourceFile\u5c5e\u6027\u7684\u5177\u4f53\u7ed3\u6784\u5982\u4e0b<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201603\/616953-20160311173814319-830364308.png\" alt=\"\" \/><\/p>\n<p>\u53ef\u4ee5\u770b\u5230attributes_count\u4e3a0x0001\uff0c\u4e3a1\uff0c\u8868\u793a\u6709\u4e00\u4e2a\u5c5e\u6027\u8868\uff0c\u7d27\u63a5\u7740\uff0cattribute_name_index\u4e3a0x0010\uff0c\u4e3a16\uff0c\u5bf9\u5e94\u5e38\u91cf\u6c60\u7b2c\u5341\u516d\u9879\uff0c\u7c7b\u578b\u4e3aClass_Utf8_info\uff0c\u5185\u5bb9\u4e3aSourceFile\uff0c\u7c7b\u578b\u4e3au4\u7684attribute_length\uff0c\u4e3a0x00000002\uff0c\u503c\u4e3a2\uff0c\u7d27\u63a5\u7740\u662f\u7c7b\u578b\u4e3au2\u7684sourcefile_index\uff0c\u4e3a0x0011\uff0c\u4e3a17\u3002<\/p>\n<p>\u81f3\u6b64\uff0c\u6574\u4e2aclass\u6587\u4ef6\u90fd\u5df2\u7ecf\u89e3\u6790\u5b8c\u6210\u4e86\uff0c\u5176\u5b9e\u7ecf\u8fc7\u5206\u6790\uff0c\u6211\u4eec\u53d1\u73b0\u5176\u5b9e\u5206\u6790class\u6587\u4ef6\u5e76\u4e0d\u56f0\u96be\uff0c\u90fd\u6709\u56fa\u5b9a\u7684\u683c\u5f0f\u3002<\/p>\n<p><strong>\u516d\u3001\u7279\u6b8a\u5b57\u7b26\u4e32<\/strong><\/p>\n<p>\u5e38\u91cf\u6c60\u5bb9\u7eb3\u7684\u7b26\u53f7\u5f15\u7528\u5305\u62ec\u4e09\u79cd\u7279\u6b8a\u7684\u5b57\u7b26\u4e32\uff1a\u5168\u9650\u5b9a\u540d\u3001\u7b80\u5355\u540d\u79f0\u3001\u63cf\u8ff0\u7b26\u3002\u5168\u9650\u5b9a\u540d\u4e3a\u7c7b\u6216\u63a5\u53e3\u7684\u5168\u9650\u5b9a\u540d\uff0c\u5982java.lang.Object\u5bf9\u8c61\u7684\u5168\u9650\u5b9a\u540d\u4e3ajava\/lang\/Object\uff0c\u7528\/\u4ee3\u66ff.\u5373\u53ef\u3002\u7b80\u5355\u540d\u79f0\u4e3a\u5b57\u6bb5\u540d\u6216\u65b9\u6cd5\u540d\u7684\u7b80\u5355\u540d\u79f0\uff0c\u5982Object\u5bf9\u8c61\u7684toString()\u65b9\u6cd5\u7684\u7b80\u5355\u540d\u79f0\u4e3atoString\uff0c\u63cf\u8ff0\u7b26\u6211\u4eec\u5728\u4e4b\u524d\u5df2\u7ecf\u4ecb\u7ecd\u8fc7\u4e86\u3002<\/p>\n<p><strong>\u4e03\u3001\u6307\u4ee4\u4ecb\u7ecd<\/strong><\/p>\n<p>7.1 \u65b9\u6cd5\u8c03\u7528\u6307\u4ee4\uff1a<\/p>\n<p>1. invokevirtual\uff0c\u7528\u4e8e\u8c03\u7528\u5bf9\u8c61\u7684\u5b9e\u4f8b\u65b9\u6cd5\uff0c\u6839\u636e\u5bf9\u8c61\u7684\u5b9e\u9645\u7c7b\u578b\u8fdb\u884c\u5206\u6d3e\u3002<\/p>\n<p>2. invokeinterface\uff0c\u7528\u4e8e\u8c03\u7528\u63a5\u53e3\u65b9\u6cd5\uff0c\u5728\u8fd0\u884c\u65f6\u641c\u7d22\u4e00\u4e2a\u5b9e\u73b0\u4e86\u8be5\u63a5\u53e3\u65b9\u6cd5\u7684\u5bf9\u8c61\uff0c\u627e\u51fa\u5408\u9002\u7684\u65b9\u6cd5\u8fdb\u884c\u8c03\u7528\u3002<\/p>\n<p>3. invokespecial\uff0c\u7528\u4e8e\u8c03\u7528\u9700\u8981\u7279\u6b8a\u5904\u7406\u7684\u5b9e\u4f8b\u65b9\u6cd5\uff0c\u5305\u62ec\u5b9e\u4f8b\u521d\u59cb\u5316\u65b9\u6cd5\u3001\u79c1\u6709\u65b9\u6cd5\u3001\u7236\u7c7b\u65b9\u6cd5\u3002<\/p>\n<p>4. invokestatic\uff0c\u7528\u4e8e\u8c03\u7528\u7c7b\u65b9\u6cd5\uff0cstatic\u65b9\u6cd5\u3002<\/p>\n<p>5. invokedynamic\uff0c\u7528\u4e8e\u5728\u8fd0\u884c\u65f6\u52a8\u6001\u89e3\u6790\u51fa\u8c03\u7528\u70b9\u9650\u5b9a\u7b26\u6240\u5f15\u7528\u7684\u65b9\u6cd5\uff0c\u5e76\u6267\u884c\u8be5\u65b9\u6cd5\u3002<\/p>\n<p>7.2 \u8fd4\u56de\u6307\u4ee4<\/p>\n<p>ireturn(boolean\u3001byte\u3001char\u3001short\u3001int)\u3001lreturn\u3001freturn\u3001dreturn\u3001areturn(\u8fd4\u56de\u4e3a\u5bf9\u8c61\u5f15\u7528\u7c7b\u578b)\u3001return(\u8fd4\u56de\u4e3avoid)<\/p>\n<p>7.3 \u540c\u6b65\u6307\u4ee4<\/p>\n<p>\u865a\u62df\u673a\u652f\u6301\u65b9\u6cd5\u7ea7\u7684\u540c\u6b65\u548c\u65b9\u6cd5\u5185\u90e8\u4e00\u6bb5\u6307\u4ee4\u5e8f\u5217\u7684\u540c\u6b65\uff0c\u90fd\u4f7f\u7528\u7ba1\u7a0b(Monitor)\u6765\u652f\u6301\u3002\u65b9\u6cd5\u7ea7(synchronized\u4fee\u9970)\u540c\u6b65\u65f6\u9690\u5f0f\u7684\uff0c\u65e0\u9700\u901a\u8fc7\u5b57\u8282\u7801\u6307\u4ee4\u6765\u63a7\u5236\uff0c\u65b9\u6cd5\u8c03\u7528\u65f6\u68c0\u67e5ACC_SYNCHRONIZED\u6807\u5fd7\u3002\u65b9\u6cd5\u5185\u90e8\u7684synchronized\u8bed\u53e5\u5757\u4f7f\u7528monitorenter\uff0cmonitorexit\u6307\u4ee4\u6765\u786e\u4fdd\u540c\u6b65\u3002<\/p>\n<p><strong>\u4e03\u3001\u603b\u7ed3<\/strong><\/p>\n<p>class\u6587\u4ef6\u770b\u4f3c\u5f88\u590d\u6742\uff0c\u5176\u5b9e\u7ecf\u8fc7\u5206\u6790\u6211\u4eec\u53d1\u73b0class\u6587\u4ef6\u5e76\u4e0d\u96be\uff0c\u901a\u8fc7\u5206\u6790class\u6587\u4ef6\uff0c\u6211\u4eec\u77e5\u9053\u4e86\u6e90\u7a0b\u5e8f\u7ecf\u8fc7\u7f16\u8bd1\u5668\u7f16\u8bd1\u4e4b\u540e\u5982\u4f55\u7ec4\u7ec7\u5728class\u6587\u4ef6\u4e2d\uff0c\u8fdb\u800c\u4e3a\u865a\u62df\u673a\u6267\u884c\u7a0b\u5e8f\u63d0\u4f9b\u642d\u8d77\u4e86\u6865\u6881\u3002\u4e5f\u76f8\u4fe1\u7ecf\u8fc7\u5206\u6790\uff0c\u8bfb\u8005\u4e5f\u80fd\u591f\u5206\u6790class\u6587\u4ef6\u4e86\uff0c\u90a3\u4e48\u6211\u4eec\u7684\u76ee\u7684\u4e5f\u5c31\u8fbe\u5230\u4e86\uff0c\u8c22\u8c22\u5404\u4f4d\u56ed\u53cb\u7684\u89c2\u770b~<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u524d\u8a00 \u968f\u7740\u6211\u4eec\u5b66\u4e60\u7684\u4e0d\u65ad\u6df1\u5165\uff0c\u6211\u76f8\u4fe1\u8bfb\u8005\u5bf9class\u6587\u4ef6\u5f88\u611f\u5174\u8da3\uff0cclass\u6587\u4ef6\u662f\u7528\u6237\u7f16\u5199\u7a0b\u5e8f\u4e0e\u865a\u62df\u673a\u4e4b\u524d\u7684\u6865\u6881\uff0c\u7a0b\u5e8f\u901a\u8fc7\u7f16\u8bd1\u5f62\u6210class\u6587\u4ef6\uff0cclass\u6587\u4ef6\u4e4b\u540e\u4f1a\u8f7d\u5165\u865a\u62df\u673a\uff0c\u88ab\u865a\u62df\u673a\u6267\u884c\uff0c\u4e0b\u9762\u6211\u4e48\u6765\u4e00\u8d77\u63ed\u5f00class\u6587\u4ef6\u7684\u795e\u79d8\u9762\u7eb1\u3002 \u4e8c\u3001\u4ec0\u4e48\u662fclass\u6587\u4ef6 class\u6587\u4ef6\u662f\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u901a\u5e38\u662f\u4ee5.class\u6587\u4ef6\u7ed3\u5c3e\u7684\u6587\u4ef6\uff0c\u5b83\u662f\u4ee58\u4f4d\u5b57\u8282\u4e3a\u57fa\u7840\u5355\u4f4d\u7684\u4e8c\u8fdb\u5236\u6d41\uff0c\u5404\u4e2a\u6570\u636e\u9879\u7d27\u5bc6\u6392\u5217\u5728class\u6587\u4ef6\u4e2d\uff0c\u6570\u636e\u9879\u7684\u57fa\u672c\u7c7b\u578b\u4e3au1,u2,u4,u8\uff0c\u5206\u522b\u8868\u793a\u4e00\u4e2a\u5b57\u8282\uff0c\u4e24\u4e2a\u5b57\u8282\uff0c\u56db\u4e2a\u5b57\u8282,\u516b\u4e2a\u5b57\u8282\u7684\u65e0\u7b26\u53f7\u6570\u3002 \u4e09\u3001class\u6587\u4ef6\u6570\u636e\u7ed3\u6784 \u5176\u5b9e\u5bf9\u4e8eclass\u6587\u4ef6\u800c\u8a00\uff0c\u603b\u4f53\u7684\u6570\u636e\u7ed3\u6784\u770b\u4e0a\u53bb\u5f88\u89c4\u6574\uff0c\u5177\u4f53\u7684\u7ed3\u6784\u5982\u4e0b\u56fe\u6240\u793a \u4e0b\u9762\u6211\u4eec\u5c06\u7528\u4e00\u4e2a\u4f8b\u5b50\u8be6\u7ec6\u8bb2\u89e3class\u6587\u4ef6\u7684\u5404\u4e2a\u90e8\u5206\u3002 \u56db\u3001\u793a\u4f8b public class Test implements Cloneable { private String name; public Test() { [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-859","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/859","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=859"}],"version-history":[{"count":0,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/859\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=859"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=859"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=859"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}