{"id":2721,"date":"2018-04-29T09:00:34","date_gmt":"2018-04-29T01:00:34","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=2721"},"modified":"2018-04-29T09:00:34","modified_gmt":"2018-04-29T01:00:34","slug":"java-classloader-%e5%ae%9e%e7%8e%b0%e5%8e%9f%e7%90%86%e5%92%8c%e5%8a%a0%e8%bd%bd%e6%9c%ba%e5%88%b6","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=2721","title":{"rendered":"Java ClassLoader \u5b9e\u73b0\u539f\u7406\u548c\u52a0\u8f7d\u673a\u5236"},"content":{"rendered":"<p>\n\tJava\u4e2d\u7684\u6240\u6709\u7c7b\uff0c\u5fc5\u987b\u88ab\u88c5\u8f7d\u5230jvm\u4e2d\u624d\u80fd\u8fd0\u884c\uff0c\u8fd9\u4e2a\u88c5\u8f7d\u5de5\u4f5c\u662f\u7531jvm\u4e2d\u7684\u7c7b\u88c5\u8f7d\u5668\u5b8c\u6210\u7684\uff0c\u7c7b\u88c5\u8f7d\u5668\u6240\u505a\u7684\u5de5\u4f5c\u5b9e\u8d28\u662f\u628a\u7c7b\u6587\u4ef6\u4ece\u786c\u76d8\u8bfb\u53d6\u5230\u5185\u5b58\u4e2d\uff0cJVM\u5728\u52a0\u8f7d\u7c7b\u7684\u65f6\u5019\uff0c\u90fd\u662f\u901a\u8fc7ClassLoader\u7684loadClass\uff08\uff09\u65b9\u6cd5\u6765\u52a0\u8f7dclass\u7684\uff0cloadClass\u4f7f\u7528\u53cc\u4eb2\u59d4\u6d3e\u6a21\u5f0f\u3002\n<\/p>\n<p>\n\t&nbsp; &nbsp; &nbsp; \u6bcf\u4e2aClassLoader\u5bf9\u8c61\u90fd\u662f\u4e00\u4e2ajava.lang.ClassLoader\u7684\u5b9e\u4f8b\u3002\u6bcf\u4e2aClass\u5bf9\u8c61\u90fd\u88ab\u8fd9\u4e9bClassLoader\u5bf9\u8c61\u6240\u52a0\u8f7d\uff0c\u901a\u8fc7\u7ee7\u627fjava.lang.ClassLoader\u53ef\u4ee5\u6269\u5c55\u51fa\u81ea\u5b9a\u4e49ClassLoader\uff0c\u5e76\u4f7f\u7528\u8fd9\u4e9b\u81ea\u5b9a\u4e49\u7684ClassLoader\u5bf9\u7c7b\u8fdb\u884c\u52a0\u8f7d\u3002\n<\/p>\n<h2>\n\t\u539f\u7406\u673a\u5236<br \/>\n<\/h2>\n<p>\n\t\u7c7b\u88c5\u8f7d\u5668ClassLoader\uff08\u4e00\u4e2a\u62bd\u8c61\u7c7b\uff09\u63cf\u8ff0\u4e00\u4e0bJVM\u52a0\u8f7dclass\u6587\u4ef6\u7684\u539f\u7406\u673a\u5236\n<\/p>\n<p>\n\t1\u3001\u88c5\u8f7d\uff1a\u67e5\u627e\u548c\u5bfc\u5165Class\u6587\u4ef6\n<\/p>\n<p>\n\t2\u3001\u94fe\u63a5\uff1a\u5176\u4e2d\u89e3\u6790\u6b65\u9aa4\u662f\u53ef\u4ee5\u9009\u62e9\u7684 \uff08a\uff09\u68c0\u67e5\uff1a\u68c0\u67e5\u8f7d\u5165\u7684class\u6587\u4ef6\u6570\u636e\u7684\u6b63\u786e\u6027 \uff08b\uff09\u51c6\u5907\uff1a\u7ed9\u7c7b\u7684\u9759\u6001\u53d8\u91cf\u5206\u914d\u5b58\u50a8\u7a7a\u95f4 \uff08c\uff09\u89e3\u6790\uff1a\u5c06\u7b26\u53f7\u5f15\u7528\u8f6c\u6210\u76f4\u63a5\u5f15\u7528\n<\/p>\n<p>\n\t3\u3001\u521d\u59cb\u5316\uff1a\u5bf9\u9759\u6001\u53d8\u91cf\uff0c\u9759\u6001\u4ee3\u7801\u5757\u6267\u884c\u521d\u59cb\u5316\u5de5\u4f5c\n<\/p>\n<ul>\n<li>\n<p>\n\t\t\t\u6839\u88c5\u8f7d\u5668\uff0cExtClassLoader(\u6269\u5c55\u7c7b\u88c5\u8f7d\u5668)\u548cAppClassLoader\uff0c\u5176\u4e2d\u6839\u88c5\u8f7d\u5668\u4e0d\u662fClassLoader\u7684\u5b50\u7c7b\uff0c\u7531C++\u7f16\u5199\uff0c\u56e0\u6b64\u5728java\u4e2d\u770b\u4e0d\u5230\u4ed6\uff0c\u8d1f\u8d23\u88c5\u8f7dJRE\u7684\u6838\u5fc3\u7c7b\u5e93\uff0c\u5982JRE\u76ee\u5f55\u4e0b\u7684rt.jar,charsets.jar\u7b49\u3002\n\t\t<\/p>\n<\/li>\n<li>\n<p>\n\t\t\tExtClassLoader\u662fClassLoder\u7684\u5b50\u7c7b\uff0c\u8d1f\u8d23\u88c5\u8f7dJRE\u6269\u5c55\u76ee\u5f55ext\u4e0b\u7684jar\u7c7b\u5305\uff1b\n\t\t<\/p>\n<\/li>\n<li>\n<p>\n\t\t\tAppClassLoader\u8d1f\u8d23\u88c5\u8f7dclasspath\u8def\u5f84\u4e0b\u7684\u7c7b\u5305\uff0c\u8fd9\u4e09\u4e2a\u7c7b\u88c5\u8f7d\u5668\u5b58\u5728\u7236\u5b50\u5c42\u7ea7\u5173\u7cfb****\uff0c\u5373\u6839\u88c5\u8f7d\u5668\u662fExtClassLoader\u7684\u7236\u88c5\u8f7d\u5668\uff0cExtClassLoader\u662fAppClassLoader\u7684\u7236\u88c5\u8f7d\u5668\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4f7f\u7528AppClassLoader\u88c5\u8f7d\u5e94\u7528\u7a0b\u5e8f\u7684\u7c7b\n\t\t<\/p>\n<\/li>\n<\/ul>\n<p>\n\tJava\u88c5\u8f7d\u7c7b\u4f7f\u7528&ldquo;\u5168\u76d8\u8d1f\u8d23\u59d4\u6258\u673a\u5236&rdquo;\u3002&ldquo;<strong>\u5168\u76d8\u8d1f\u8d23<\/strong>&rdquo;\u662f\u6307\u5f53\u4e00\u4e2aClassLoder\u88c5\u8f7d\u4e00\u4e2a\u7c7b\u65f6\uff0c\u9664\u975e\u663e\u793a\u7684\u4f7f\u7528\u53e6\u5916\u4e00\u4e2aClassLoder\uff0c\u8be5\u7c7b\u6240\u4f9d\u8d56\u53ca\u5f15\u7528\u7684\u7c7b\u4e5f\u7531\u8fd9\u4e2aClassLoder\u8f7d\u5165\uff1b&ldquo;<strong>\u59d4\u6258\u673a\u5236<\/strong>&rdquo;\u662f\u6307\u5148\u59d4\u6258\u7236\u7c7b\u88c5\u8f7d\u5668\u5bfb\u627e\u76ee\u6807\u7c7b\uff0c\u53ea\u6709\u5728\u627e\u4e0d\u5230\u7684\u60c5\u51b5\u4e0b\u624d\u4ece\u81ea\u5df1\u7684\u7c7b\u8def\u5f84\u4e2d\u67e5\u627e\u5e76\u88c5\u8f7d\u76ee\u6807\u7c7b\u3002\n<\/p>\n<h2>\n\tClassLoader\u6e90\u7801\u5206\u6790<br \/>\n<\/h2>\n<pre class=\"brush:java;\">\r\npublic abstract class ClassLoader<\/pre>\n<p>\n\tclass loader\u662f\u4e00\u4e2a\u8d1f\u8d23\u52a0\u8f7dclasses\u7684\u5bf9\u8c61\uff0cClassLoader\u7c7b\u662f\u4e00\u4e2a\u62bd\u8c61\u7c7b\uff0c\u9700\u8981\u7ed9\u51fa\u7c7b\u7684\u4e8c\u8fdb\u5236\u540d\u79f0\uff0cclass loader\u5c1d\u8bd5\u5b9a\u4f4d\u6216\u8005\u4ea7\u751f\u4e00\u4e2aclass\u7684\u6570\u636e\uff0c\u4e00\u4e2a\u5178\u578b\u7684\u7b56\u7565\u662f\u628a\u4e8c\u8fdb\u5236\u540d\u5b57\u8f6c\u6362\u6210\u6587\u4ef6\u540d\u7136\u540e\u5230\u6587\u4ef6\u7cfb\u7edf\u4e2d\u627e\u5230\u8be5\u6587\u4ef6\u3002\n<\/p>\n<p>\n\tloadClass\u65b9\u6cd5\u7684\u5b9e\u73b0\u65b9\u5f0f\uff1a\n<\/p>\n<pre class=\"brush:java;\">\r\nprotected Class&gt; loadClass(String name, boolean resolve)\r\n\tthrows ClassNotFoundException{\r\n\tsynchronized (getClassLoadingLock(name)) {\r\n\t\t\/\/ First, check if the class has already been loaded\r\n\t\tClass c = findLoadedClass(name);\r\n\t\tif (c == null) {\r\n\t\t\tlong t0 = System.nanoTime();\r\n\t\t\ttry {\r\n\t\t\t\tif (parent != null) {\r\n\t\t\t\t\tc = parent.loadClass(name, false);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tc = findBootstrapClassOrNull(name);\r\n\t\t\t\t}\r\n\t\t\t} catch (ClassNotFoundException e) {\r\n\t\t\t\t\/\/ ClassNotFoundException thrown if class not found\r\n\t\t\t\t\/\/ from the non-null parent class loader\r\n\t\t\t}\r\n\t\t\tif (c == null) {\r\n\t\t\t\t\/\/ If still not found, then invoke findClass in order\r\n\t\t\t\t\/\/ to find the class.\r\n\t\t\t\tlong t1 = System.nanoTime();\r\n\t\t\t\tc = findClass(name);\r\n\r\n\t\t\t\t\/\/ this is the defining class loader; record the stats\r\n\t\t\t\tsun.misc.PerfCounter.getParentDelegationTime().addTime(t1 - t0);\r\n\t\t\t\tsun.misc.PerfCounter.getFindClassTime().addElapsedTimeFrom(t1);\r\n\t\t\t\tsun.misc.PerfCounter.getFindClasses().increment();\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (resolve) {\r\n\t\t\tresolveClass(c);\r\n\t\t}\r\n\t\treturn c;\r\n\t}\r\n}<\/pre>\n<p>\n\t\u4f7f\u7528\u6307\u5b9a\u7684\u4e8c\u8fdb\u5236\u540d\u79f0\u6765\u52a0\u8f7d\u7c7b\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u7684\u9ed8\u8ba4\u5b9e\u73b0\u6309\u7167\u4ee5\u4e0b\u987a\u5e8f\u67e5\u627e\u7c7b\uff1a \u8c03\u7528findLoadedClass(String)\u65b9\u6cd5\u68c0\u67e5\u8fd9\u4e2a\u7c7b\u662f\u5426\u88ab\u52a0\u8f7d\u8fc7 \u4f7f\u7528\u7236\u52a0\u8f7d\u5668\u8c03\u7528loadClass(String)\u65b9\u6cd5\uff0c\u5982\u679c\u7236\u52a0\u8f7d\u5668\u4e3aNull\uff0c\u7c7b\u52a0\u8f7d\u5668\u88c5\u8f7d\u865a\u62df\u673a\u5185\u7f6e\u7684\u52a0\u8f7d\u5668\u8c03\u7528findClass(String)\u65b9\u6cd5\u88c5\u8f7d\u7c7b\uff0c \u5982\u679c\uff0c\u6309\u7167\u4ee5\u4e0a\u7684\u6b65\u9aa4\u6210\u529f\u7684\u627e\u5230\u5bf9\u5e94\u7684\u7c7b\uff0c\u5e76\u4e14\u8be5\u65b9\u6cd5\u63a5\u6536\u7684resolve\u53c2\u6570\u7684\u503c\u4e3atrue,\u90a3\u4e48\u5c31\u8c03\u7528resolveClass(Class)\u65b9\u6cd5\u6765\u5904\u7406\u7c7b\u3002 ClassLoader\u7684\u5b50\u7c7b\u6700\u597d\u8986\u76d6findClass(String)\u800c\u4e0d\u662f\u8fd9\u4e2a\u65b9\u6cd5\u3002 \u9664\u975e\u88ab\u91cd\u5199\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u9ed8\u8ba4\u5728\u6574\u4e2a\u88c5\u8f7d\u8fc7\u7a0b\u4e2d\u90fd\u662f\u540c\u6b65\u7684\uff08\u7ebf\u7a0b\u5b89\u5168\u7684\uff09\u3002\n<\/p>\n<pre class=\"brush:java;\">\r\nprotected Object getClassLoadingLock(String className) {\r\n\tObject lock = this;\r\n\tif (parallelLockMap != null) {\r\n\t\tObject newLock = new Object();\r\n\t\tlock = parallelLockMap.putIfAbsent(className, newLock);\r\n\t\tif (lock == null) {\r\n\t\t\tlock = newLock;\r\n\t\t}\r\n\t}\r\n\treturn lock;\r\n}\r\nprivate final ConcurrentHashMap parallelLockMap;\r\n\/\/\u8fd9\u4e2a\u53d8\u91cf\u7684\u521d\u59cb\u5316\u5de5\u4f5c\u5728ClassLoader\u7684\u6784\u9020\u51fd\u6570\u4e2d\r\nprivate ClassLoader(Void unused, ClassLoader parent) {\r\n\tthis.parent = parent;\r\n\tif (ParallelLoaders.isRegistered(this.getClass())) {\r\n\t\tparallelLockMap = new ConcurrentHashMap();\r\n\t\tpackage2certs = new ConcurrentHashMap();\r\n\t\tdomains =\r\n\t\t\tCollections.synchronizedSet(new HashSet());\r\n\t\tassertionLock = new Object();\r\n\t} else {\r\n\t\t\/\/ no finer-grained lock; lock on the classloader instance\r\n\t\tparallelLockMap = null;\r\n\t\tpackage2certs = new Hashtable();\r\n\t\tdomains = new HashSet();\r\n\t\tassertionLock = this;\r\n\t}\r\n}<\/pre>\n<p>\n\t\u5728ClassLoader\u7c7b\u4e2d\u6709\u4e00\u4e2a\u9759\u6001\u5185\u90e8\u7c7bParallelLoaders\uff0c\u4ed6\u4f1a\u6307\u5b9a\u7684\u7c7b\u7684\u5e76\u884c\u80fd\u529b\uff0c\u5982\u679c\u5f53\u524d\u7684\u52a0\u8f7d\u5668\u88ab\u5b9a\u4f4d\u4e3a\u5177\u6709\u5e76\u884c\u80fd\u529b\uff0c\u90a3\u4e48\u4ed6\u5c31\u7ed9parallelLockMap\u5b9a\u4e49\uff0c\u5c31\u662fnew\u4e00\u4e2a ConcurrentHashMap()\uff0c\u90a3\u4e48\u8fd9\u4e2a\u65f6\u5019\uff0c\u6211\u4eec\u77e5\u9053\u5982\u679c\u5f53\u524d\u7684\u52a0\u8f7d\u5668\u662f\u5177\u6709\u5e76\u884c\u80fd\u529b\u7684\uff0c\u90a3\u4e48parallelLockMap\u5c31\u4e0d\u662fNull\uff0c\u8fd9\u4e2a\u65f6\u5019\uff0c\u6211\u4eec\u5224\u65adparallelLockMap\u662f\u4e0d\u662fNull\uff0c\u5982\u679c\u4ed6\u662fnull\uff0c\u8bf4\u660e\u8be5\u52a0\u8f7d\u5668\u6ca1\u6709\u6ce8\u518c\u5e76\u884c\u80fd\u529b\uff0c\u90a3\u4e48\u6211\u4eec\u6ca1\u6709\u5fc5\u8981\u7ed9\u4ed6\u4e00\u4e2a\u52a0\u9501\u7684\u5bf9\u8c61\uff0cgetClassLoadingLock\u65b9\u6cd5\u76f4\u63a5\u8fd4\u56dethis,\u5c31\u662f\u5f53\u524d\u7684\u52a0\u8f7d\u5668\u7684\u4e00\u4e2a\u5b9e\u4f8b\u3002\u5982\u679c\u8fd9\u4e2aparallelLockMap\u4e0d\u662fnull\uff0c\u90a3\u5c31\u8bf4\u660e\u8be5\u52a0\u8f7d\u5668\u662f\u6709\u5e76\u884c\u80fd\u529b\u7684\uff0c\u90a3\u4e48\u5c31\u53ef\u80fd\u6709\u5e76\u884c\u60c5\u51b5\uff0c\u90a3\u5c31\u9700\u8981\u8fd4\u56de\u4e00\u4e2a\u9501\u5bf9\u8c61\u3002\u7136\u540e\u5c31\u662f\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Object\u5bf9\u8c61\uff0c\u8c03\u7528parallelLockMap\u7684putIfAbsent(className, newLock)\u65b9\u6cd5\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u7684\u4f5c\u7528\u662f\uff1a\u9996\u5148\u6839\u636e\u4f20\u8fdb\u6765\u7684className,\u68c0\u67e5\u8be5\u540d\u5b57\u662f\u5426\u5df2\u7ecf\u5173\u8054\u4e86\u4e00\u4e2avalue\u503c\uff0c\u5982\u679c\u5df2\u7ecf\u5173\u8054\u8fc7value\u503c\uff0c\u90a3\u4e48\u76f4\u63a5\u628a\u4ed6\u5173\u8054\u7684\u503c\u8fd4\u56de\uff0c\u5982\u679c\u6ca1\u6709\u5173\u8054\u8fc7\u503c\u7684\u8bdd\uff0c\u90a3\u5c31\u628a\u6211\u4eec\u4f20\u8fdb\u6765\u7684Object\u5bf9\u8c61\u4f5c\u4e3avalue\u503c\uff0cclassName\u4f5c\u4e3aKey\u503c\u7ec4\u6210\u4e00\u4e2amap\u8fd4\u56de\u3002\u7136\u540e\u65e0\u8bbaputIfAbsent\u65b9\u6cd5\u7684\u8fd4\u56de\u503c\u662f\u4ec0\u4e48\uff0c\u90fd\u628a\u5b83\u8d4b\u503c\u7ed9\u6211\u4eec\u521a\u521a\u751f\u6210\u7684\u90a3\u4e2aObject\u5bf9\u8c61\u3002 \u8fd9\u4e2a\u65f6\u5019\uff0c\u6211\u4eec\u6765\u7b80\u5355\u8bf4\u660e\u4e00\u4e0bgetClassLoadingLock(String className)\u7684\u4f5c\u7528\uff0c\u5c31\u662f\uff1a \u4e3a\u7c7b\u7684\u52a0\u8f7d\u64cd\u4f5c\u8fd4\u56de\u4e00\u4e2a\u9501\u5bf9\u8c61\u3002\u4e3a\u4e86\u5411\u540e\u517c\u5bb9\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u8fd9\u6837\u5b9e\u73b0:\u5982\u679c\u5f53\u524d\u7684classloader\u5bf9\u8c61\u6ce8\u518c\u4e86\u5e76\u884c\u80fd\u529b\uff0c\u65b9\u6cd5\u8fd4\u56de\u4e00\u4e2a\u4e0e\u6307\u5b9a\u7684\u540d\u5b57className\u76f8\u5173\u8054\u7684\u7279\u5b9a\u5bf9\u8c61\uff0c\u5426\u5219\uff0c\u76f4\u63a5\u8fd4\u56de\u5f53\u524d\u7684ClassLoader\u5bf9\u8c61\u3002<br \/>\n\tresolveClass()\u89e3\u6790\u4f5c\u7528\uff1a<br \/>\n\t\u94fe\u63a5\u6307\u5b9a\u7684\u7c7b\u3002\u8fd9\u4e2a\u65b9\u6cd5\u7ed9Classloader\u7528\u6765\u94fe\u63a5\u4e00\u4e2a\u7c7b\uff0c\u5982\u679c\u8fd9\u4e2a\u7c7b\u5df2\u7ecf\u88ab\u94fe\u63a5\u8fc7\u4e86\uff0c\u90a3\u4e48\u8fd9\u4e2a\u65b9\u6cd5\u53ea\u505a\u4e00\u4e2a\u7b80\u5355\u7684\u8fd4\u56de\u3002\u5426\u5219\uff0c\u8fd9\u4e2a\u7c7b\u5c06\u88ab\u6309\u7167 Java \u89c4\u8303\u4e2d\u7684Execution\u63cf\u8ff0\u8fdb\u884c\u94fe\u63a5\n<\/p>\n<h2>\n\t\u603b\u7ed3<br \/>\n<\/h2>\n<h3>\n\tjava\u4e2d\u7684\u7c7b\u5927\u81f4\u5206\u4e3a\u4e09\u79cd<br \/>\n<\/h3>\n<p>\n\t1.\u7cfb\u7edf\u7c7b 2.\u6269\u5c55\u7c7b 3.\u7531\u7a0b\u5e8f\u5458\u81ea\u5b9a\u4e49\u7684\u7c7b\n<\/p>\n<p>\n\t\u7c7b\u88c5\u8f7d\u65b9\u5f0f\uff0c\u6709\u4e24\u79cd:\n<\/p>\n<p>\n\t1.\u9690\u5f0f\u88c5\u8f7d\uff0c \u7a0b\u5e8f\u5728\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u5f53\u78b0\u5230\u901a\u8fc7new \u7b49\u65b9\u5f0f\u751f\u6210\u5bf9\u8c61\u65f6\uff0c\u9690\u5f0f\u8c03\u7528\u7c7b\u88c5\u8f7d\u5668\u52a0\u8f7d\u5bf9\u5e94\u7684\u7c7b\u5230jvm\u4e2d\u3002\n<\/p>\n<p>\n\t2.\u663e\u5f0f\u88c5\u8f7d\uff0c \u901a\u8fc7class.forname()\u7b49\u65b9\u6cd5\uff0c\u663e\u5f0f\u52a0\u8f7d\u9700\u8981\u7684\u7c7b\n<\/p>\n<h3>\n\t\u7c7b\u52a0\u8f7d\u7684\u52a8\u6001\u6027\u4f53\u73b0<br \/>\n<\/h3>\n<p>\n\t\u4e00\u4e2a\u5e94\u7528\u7a0b\u5e8f\u603b\u662f\u7531n\u591a\u4e2a\u7c7b\u7ec4\u6210\uff0cJava\u7a0b\u5e8f\u542f\u52a8\u65f6\uff0c\u5e76\u4e0d\u662f\u4e00\u6b21\u628a\u6240\u6709\u7684\u7c7b\u5168\u90e8\u52a0\u8f7d\u540e\u518d\u8fd0\u884c\uff0c\u5b83\u603b\u662f\u5148\u628a\u4fdd\u8bc1\u7a0b\u5e8f\u8fd0\u884c\u7684\u57fa\u7840\u7c7b\u4e00\u6b21\u6027\u52a0\u8f7d\u5230jvm\u4e2d\uff0c\u5176\u5b83\u7c7b\u7b49\u5230jvm\u7528\u5230\u7684\u65f6\u5019\u518d\u52a0\u8f7d\uff0c\u8fd9\u6837\u7684\u597d\u5904\u662f\u8282\u7701\u4e86\u5185\u5b58\u7684\u5f00\u9500\uff0c\u56e0\u4e3ajava\u6700\u65e9\u5c31\u662f\u4e3a\u5d4c\u5165\u5f0f\u7cfb\u7edf\u800c\u8bbe\u8ba1\u7684\uff0c\u5185\u5b58\u5b9d\u8d35\uff0c\u8fd9\u662f\u4e00\u79cd\u53ef\u4ee5\u7406\u89e3\u7684\u673a\u5236\uff0c\u800c\u7528\u5230\u65f6\u518d\u52a0\u8f7d\u8fd9\u4e5f\u662fjava\u52a8\u6001\u6027\u7684\u4e00\u79cd\u4f53\u73b0\n<\/p>\n<h3>\n\tjava\u7c7b\u88c5\u8f7d\u5668<br \/>\n<\/h3>\n<p>\n\tJava\u4e2d\u7684\u7c7b\u88c5\u8f7d\u5668\u5b9e\u8d28\u4e0a\u4e5f\u662f\u7c7b\uff0c\u529f\u80fd\u662f\u628a\u7c7b\u8f7d\u5165jvm\u4e2d\uff0c\u503c\u5f97\u6ce8\u610f\u7684\u662fjvm\u7684\u7c7b\u88c5\u8f7d\u5668\u5e76\u4e0d\u662f\u4e00\u4e2a\uff0c\u800c\u662f\u4e09\u4e2a\uff0c\u5c42\u6b21\u7ed3\u6784\u5982\u4e0b\uff1a\n<\/p>\n<p>\n\tBootstrap Loader &#8211; \u8d1f\u8d23\u52a0\u8f7d\u7cfb\u7edf\u7c7b\n<\/p>\n<p>\n\tExtClassLoader &#8211; \u8d1f\u8d23\u52a0\u8f7d\u6269\u5c55\u7c7b\n<\/p>\n<p>\n\tAppClassLoader &#8211; \u8d1f\u8d23\u52a0\u8f7d\u5e94\u7528\u7c7b\n<\/p>\n<p>\n\t\u4e3a\u4ec0\u4e48\u8981\u6709\u4e09\u4e2a\u7c7b\u52a0\u8f7d\u5668\uff0c\u4e00\u65b9\u9762\u662f\u5206\u5de5\uff0c\u5404\u81ea\u8d1f\u8d23\u5404\u81ea\u7684\u533a\u5757\uff0c\u53e6\u4e00\u65b9\u9762\u4e3a\u4e86\u5b9e\u73b0\u59d4\u6258\u6a21\u578b\uff0c\u4e0b\u9762\u4f1a\u8c08\u5230\u8be5\u6a21\u578b\n<\/p>\n<h3>\n\t\u7c7b\u52a0\u8f7d\u5668\u4e4b\u95f4\u662f\u5982\u4f55\u534f\u8c03\u5de5\u4f5c\u7684<br \/>\n<\/h3>\n<p>\n\t\u5728\u8fd9\u91ccjava\u91c7\u7528\u4e86\u59d4\u6258\u6a21\u578b\u673a\u5236\uff0c\u8fd9\u4e2a\u673a\u5236\u7b80\u5355\u6765\u8bb2\uff0c\u5c31\u662f&ldquo;\u7c7b\u88c5\u8f7d\u5668\u6709\u8f7d\u5165\u7c7b\u7684\u9700\u6c42\u65f6\uff0c\u4f1a\u5148\u8bf7\u793a\u5176Parent\u4f7f\u7528\u5176\u641c\u7d22\u8def\u5f84\u5e2e\u5fd9\u8f7d\u5165\uff0c\u5982\u679cParent \u627e\u4e0d\u5230,\u90a3\u4e48\u624d\u7531\u81ea\u5df1\u4f9d\u7167\u81ea\u5df1\u7684\u641c\u7d22\u8def\u5f84\u641c\u7d22\u7c7b&rdquo;<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=2721\">Java ClassLoader \u5b9e\u73b0\u539f\u7406\u548c\u52a0\u8f7d\u673a\u5236<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>Java\u4e2d\u7684\u6240\u6709\u7c7b\uff0c\u5fc5\u987b\u88ab\u88c5\u8f7d\u5230jvm\u4e2d\u624d\u80fd\u8fd0\u884c\uff0c\u8fd9\u4e2a\u88c5\u8f7d\u5de5\u4f5c\u662f\u7531jvm\u4e2d\u7684\u7c7b\u88c5\u8f7d\u5668\u5b8c\u6210\u7684\uff0c\u7c7b\u88c5\u8f7d\u5668\u6240\u505a\u7684\u5de5\u4f5c [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[69,261,264,327,385],"class_list":["post-2721","post","type-post","status-publish","format-standard","hentry","category-java","tag-java"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2721","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2721"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2721\/revisions"}],"predecessor-version":[{"id":2722,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2721\/revisions\/2722"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2721"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2721"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2721"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}