import{_ as l,r as e,o as p,c as o,a as s,b as c,e as n,d as r}from"./app.87c2e303.js";const t={},i=n(`<h1 id="\u529F\u80FD\u4ECB\u7ECD" tabindex="-1"><a class="header-anchor" href="#\u529F\u80FD\u4ECB\u7ECD" aria-hidden="true">#</a> \u529F\u80FD\u4ECB\u7ECD</h1><blockquote><p>\u8FD9\u91CC\u5305\u542B\u4E86 <code>YukiReflection</code> \u5168\u90E8\u6838\u5FC3\u529F\u80FD\u7684\u7528\u6CD5\u793A\u4F8B\u3002</p></blockquote><h2 id="class-\u6269\u5C55" tabindex="-1"><a class="header-anchor" href="#class-\u6269\u5C55" aria-hidden="true">#</a> Class \u6269\u5C55</h2><blockquote><p>\u8FD9\u91CC\u662F <strong>Class</strong> \u5BF9\u8C61\u81EA\u8EAB\u76F8\u5173\u7684\u6269\u5C55\u529F\u80FD\u3002</p></blockquote><h3 id="\u5BF9\u8C61\u8F6C\u6362" tabindex="-1"><a class="header-anchor" href="#\u5BF9\u8C61\u8F6C\u6362" aria-hidden="true">#</a> \u5BF9\u8C61\u8F6C\u6362</h3><p>\u5047\u8BBE\u6211\u4EEC\u8981\u5F97\u5230\u4E00\u4E2A\u4E0D\u80FD\u76F4\u63A5\u8C03\u7528\u7684 <code>Class</code>\uFF0C\u901A\u5E38\u60C5\u51B5\u4E0B\uFF0C\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528\u6807\u51C6\u7684\u53CD\u5C04 API \u53BB\u67E5\u627E\u8FD9\u4E2A <code>Class</code>\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u9ED8\u8BA4 ClassLoader \u73AF\u5883\u4E0B\u7684 Class</span></span>
<span class="line"><span style="color:#F47067;">var</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Class</span><span style="color:#ADBAC7;">.forName(</span><span style="color:#96D0FF;">&quot;com.demo.Test&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#768390;">// \u6307\u5B9A ClassLoader \u73AF\u5883\u4E0B\u7684 Class</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> customClassLoader</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">ClassLoader?</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> ... </span><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u4E2A\u5C31\u662F\u4F60\u7684 ClassLoader</span></span>
<span class="line"><span style="color:#F47067;">var</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> custom</span><span style="color:#F69D50;">ClassLoader?</span><span style="color:#ADBAC7;">.loadClass(</span><span style="color:#96D0FF;">&quot;com.demo.Test&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u8FD9\u79CD\u5199\u6CD5\u5927\u6982\u4E0D\u662F\u5F88\u53CB\u597D\uFF0C\u6B64\u65F6 <code>YukiReflection</code> \u5C31\u4E3A\u4F60\u63D0\u4F9B\u4E86\u4E00\u4E2A\u53EF\u5728\u4EFB\u610F\u5730\u65B9\u4F7F\u7528\u7684\u8BED\u6CD5\u7CD6\u3002</p><p>\u4EE5\u4E0A\u5199\u6CD5\u6362\u505A <code>YukiReflection</code> \u53EF\u5199\u4F5C\u5982\u4E0B\u5F62\u5F0F\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u76F4\u63A5\u5F97\u5230\u8FD9\u4E2A Class</span></span>
<span class="line"><span style="color:#F47067;">var</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.demo.Test&quot;</span><span style="color:#ADBAC7;">.toClass()</span></span>
<span class="line"><span style="color:#768390;">// \u81EA\u5B9A\u4E49 Class \u6240\u5728\u7684 ClassLoader</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> customClassLoader</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">ClassLoader?</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> ... </span><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u4E2A\u5C31\u662F\u4F60\u7684 ClassLoader</span></span>
<span class="line"><span style="color:#F47067;">var</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.demo.Test&quot;</span><span style="color:#ADBAC7;">.toClass(customClassLoader)</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u5982\u679C\u5F53\u524D <code>Class</code> \u5E76\u4E0D\u5B58\u5728\uFF0C\u4F7F\u7528\u4E0A\u8FF0\u65B9\u6CD5\u4F1A\u629B\u51FA\u5F02\u5E38\uFF0C\u5982\u679C\u4F60\u4E0D\u786E\u5B9A <code>Class</code> \u662F\u5426\u5B58\u5728\uFF0C\u53EF\u4EE5\u53C2\u8003\u4E0B\u9762\u7684\u89E3\u51B3\u65B9\u6848\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u76F4\u63A5\u5F97\u5230\u8FD9\u4E2A Class</span></span>
<span class="line"><span style="color:#768390;">// \u5F97\u4E0D\u5230\u65F6\u7ED3\u679C\u4F1A\u4E3A null \u4F46\u4E0D\u4F1A\u629B\u51FA\u5F02\u5E38</span></span>
<span class="line"><span style="color:#F47067;">var</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.demo.Test&quot;</span><span style="color:#ADBAC7;">.toClassOrNull()</span></span>
<span class="line"><span style="color:#768390;">// \u81EA\u5B9A\u4E49 Class \u6240\u5728\u7684 ClassLoader</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> customClassLoader</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">ClassLoader?</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> ... </span><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u4E2A\u5C31\u662F\u4F60\u7684 ClassLoader</span></span>
<span class="line"><span style="color:#768390;">// \u5F97\u4E0D\u5230\u65F6\u7ED3\u679C\u4F1A\u4E3A null \u4F46\u4E0D\u4F1A\u629B\u51FA\u5F02\u5E38</span></span>
<span class="line"><span style="color:#F47067;">var</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.demo.Test&quot;</span><span style="color:#ADBAC7;">.toClassOrNull(customClassLoader)</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u6211\u4EEC\u8FD8\u53EF\u4EE5\u901A\u8FC7\u6620\u5C04\u6765\u5F97\u5230\u4E00\u4E2A\u5B58\u5728\u7684 <code>Class</code> \u5BF9\u8C61\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u4E2A Class \u662F\u80FD\u591F\u88AB\u76F4\u63A5\u5F97\u5230\u7684</span></span>
<span class="line"><span style="color:#F47067;">var</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> classOf</span><span style="color:#F47067;">&lt;</span><span style="color:#F69D50;">Test</span><span style="color:#F47067;">&gt;</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u6211\u4EEC\u540C\u6837\u53EF\u4EE5\u81EA\u5B9A\u4E49 Class \u6240\u5728\u7684 ClassLoader\uFF0C\u8FD9\u5BF9\u4E8E stub \u6765\u8BF4\u975E\u5E38\u6709\u6548</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> customClassLoader</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">ClassLoader?</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> ... </span><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u4E2A\u5C31\u662F\u4F60\u7684 ClassLoader</span></span>
<span class="line"><span style="color:#F47067;">var</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> classOf</span><span style="color:#F47067;">&lt;</span><span style="color:#F69D50;">Test</span><span style="color:#F47067;">&gt;</span><span style="color:#ADBAC7;">(customClassLoader)</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="custom-container tip"><p class="custom-container-title">\u5C0F\u63D0\u793A</p><p>\u66F4\u591A\u529F\u80FD\u8BF7\u53C2\u8003 <a href="../api/public/com/highcapable/yukireflection/factory/ReflectionFactory#classof-method">classOf</a>\u3001<a href="../api/public/com/highcapable/yukireflection/factory/ReflectionFactory#string-toclass-ext-method">String.toClass</a>\u3001<a href="../api/public/com/highcapable/yukireflection/factory/ReflectionFactory#string-toclassornull-ext-method">String.toClassOrNull</a> \u65B9\u6CD5\u3002</p></div><h3 id="\u5B58\u5728\u5224\u65AD" tabindex="-1"><a class="header-anchor" href="#\u5B58\u5728\u5224\u65AD" aria-hidden="true">#</a> \u5B58\u5728\u5224\u65AD</h3><p>\u5047\u8BBE\u6211\u4EEC\u8981\u5224\u65AD\u4E00\u4E2A <code>Class</code> \u662F\u5426\u5B58\u5728\uFF0C\u901A\u5E38\u60C5\u51B5\u4E0B\uFF0C\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528\u6807\u51C6\u7684\u53CD\u5C04 API \u53BB\u67E5\u627E\u8FD9\u4E2A <code>Class</code> \u901A\u8FC7\u5F02\u5E38\u6765\u5224\u65AD\u662F\u5426\u5B58\u5728\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u9ED8\u8BA4 ClassLoader \u73AF\u5883\u4E0B\u7684 Class</span></span>
<span class="line"><span style="color:#F47067;">var</span><span style="color:#ADBAC7;"> isExist </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">try</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F69D50;">Class</span><span style="color:#ADBAC7;">.forName(</span><span style="color:#96D0FF;">&quot;com.demo.Test&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#6CB6FF;">true</span></span>
<span class="line"><span style="color:#ADBAC7;">} </span><span style="color:#F47067;">catch</span><span style="color:#ADBAC7;"> (_</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Throwable</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#6CB6FF;">false</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"><span style="color:#768390;">// \u6307\u5B9A ClassLoader \u73AF\u5883\u4E0B\u7684 Class</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> customClassLoader</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">ClassLoader?</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> ... </span><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u4E2A\u5C31\u662F\u4F60\u7684 ClassLoader</span></span>
<span class="line"><span style="color:#F47067;">var</span><span style="color:#ADBAC7;"> isExist </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">try</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"><span style="color:#ADBAC7;">    custom</span><span style="color:#F69D50;">ClassLoader?</span><span style="color:#ADBAC7;">.loadClass(</span><span style="color:#96D0FF;">&quot;com.demo.Test&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#6CB6FF;">true</span></span>
<span class="line"><span style="color:#ADBAC7;">} </span><span style="color:#F47067;">catch</span><span style="color:#ADBAC7;"> (_</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Throwable</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#6CB6FF;">false</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u8FD9\u79CD\u5199\u6CD5\u5927\u6982\u4E0D\u662F\u5F88\u53CB\u597D\uFF0C\u6B64\u65F6 <code>YukiReflection</code> \u5C31\u4E3A\u4F60\u63D0\u4F9B\u4E86\u4E00\u4E2A\u53EF\u5728\u4EFB\u610F\u5730\u65B9\u4F7F\u7528\u7684\u8BED\u6CD5\u7CD6\u3002</p><p>\u4EE5\u4E0A\u5199\u6CD5\u6362\u505A <code>YukiReflection</code> \u53EF\u5199\u4F5C\u5982\u4E0B\u5F62\u5F0F\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5224\u65AD\u8FD9\u4E2A Class \u662F\u5426\u5B58\u5728</span></span>
<span class="line"><span style="color:#F47067;">var</span><span style="color:#ADBAC7;"> isExist </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.demo.Test&quot;</span><span style="color:#ADBAC7;">.hasClass()</span></span>
<span class="line"><span style="color:#768390;">// \u81EA\u5B9A\u4E49 Class \u6240\u5728\u7684 ClassLoader</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> customClassLoader</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">ClassLoader?</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> ... </span><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u4E2A\u5C31\u662F\u4F60\u7684 ClassLoader</span></span>
<span class="line"><span style="color:#F47067;">var</span><span style="color:#ADBAC7;"> isExist </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.demo.Test&quot;</span><span style="color:#ADBAC7;">.hasClass(customClassLoader)</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="custom-container tip"><p class="custom-container-title">\u5C0F\u63D0\u793A</p><p>\u66F4\u591A\u529F\u80FD\u8BF7\u53C2\u8003 <a href="../api/public/com/highcapable/yukireflection/factory/ReflectionFactory#string-hasclass-ext-method">String.hasClass</a> \u65B9\u6CD5\u3002</p></div>`,28),d={id:"\u6A21\u7CCA\u67E5\u627E",tabindex:"-1"},y=s("a",{class:"header-anchor",href:"#\u6A21\u7CCA\u67E5\u627E","aria-hidden":"true"},"#",-1),A=r(" \u6A21\u7CCA\u67E5\u627E\u2002"),u=n(`<p>\u5728 R8 \u7B49\u5DE5\u5177\u6DF7\u6DC6\u540E\u7684\u5F53\u524D APP <strong>Dex</strong> \u4E2D\u7684 <code>Class</code> \u540D\u79F0\u5C06\u4F1A\u96BE\u4EE5\u5206\u8FA8\uFF0C\u4E14\u4E0D\u786E\u5B9A\u5176\u6B63\u786E\u4F4D\u7F6E\uFF0C\u4E0D\u80FD\u76F4\u63A5\u901A\u8FC7 <a href="#%E5%AF%B9%E8%B1%A1%E8%BD%AC%E6%8D%A2">\u5BF9\u8C61\u8F6C\u6362</a> \u6765\u5F97\u5230\u3002</p><p>\u6B64\u65F6\u5C31\u6709\u4E86 <code>DexClassFinder</code>\uFF0C\u5B83\u7684\u4F5C\u7528\u662F\u901A\u8FC7\u9700\u8981\u67E5\u627E\u7684 <code>Class</code> \u4E2D\u7684\u5B57\u8282\u7801\u7279\u5F81\u6765\u786E\u5B9A\u8FD9\u4E2A <code>Class</code> \u7684\u5B9E\u4F8B\u3002</p><div class="custom-container warning"><p class="custom-container-title">\u6CE8\u610F</p><p>\u76EE\u524D <strong>DexClassFinder</strong> \u7684\u529F\u80FD\u5C1A\u5728\u8BD5\u9A8C\u9636\u6BB5\uFF0C\u7531\u4E8E\u4EC5\u901A\u8FC7 Java \u5C42\u5B9E\u73B0\u67E5\u627E\u529F\u80FD\uFF0C\u5728\u5F53\u524D APP <strong>Class</strong> \u8FC7\u591A\u65F6\u6027\u80FD\u53EF\u80FD\u4E0D\u80FD\u8FBE\u5230\u6700\u4F73\u6C34\u5E73\uFF0C\u5982\u679C\u53D1\u751F\u67E5\u627E\u4E0D\u5230\u3001\u5B9A\u4F4D\u6709\u8BEF\u7684\u95EE\u9898\u6B22\u8FCE\u5411\u6211\u4EEC\u53CD\u9988\u3002</p><p>\u7531\u4E8E\u662F\u53CD\u5C04\u5C42\u9762\u7684 API\uFF0C\u76EE\u524D\u5B83\u53EA\u80FD\u901A\u8FC7<strong>\u7C7B\u4E0E\u6210\u5458</strong>\u7684\u7279\u5F81\u6765\u5B9A\u4F4D\u6307\u5B9A\u7684 <strong>Class</strong>\uFF0C\u4E0D\u80FD\u901A\u8FC7\u6307\u5B9A\u5B57\u8282\u7801\u4E2D\u7684\u5B57\u7B26\u4E32\u548C\u65B9\u6CD5\u5185\u5BB9\u7279\u5F81\u6765\u8FDB\u884C\u5B9A\u4F4D\u3002</p><p>\u67E5\u627E <strong>Class</strong> \u7684\u901F\u5EA6\u53D6\u51B3\u4E8E\u5F53\u524D\u8BBE\u5907\u7684\u6027\u80FD\uFF0C\u76EE\u524D\u4E3B\u6D41\u7684\u79FB\u52A8\u7AEF\u5904\u7406\u5668\u5728 <strong>10~15w</strong> \u6570\u91CF\u7684 <strong>Class</strong> \u4E2D\u6761\u4EF6\u4E0D\u7B97\u590D\u6742\u7684\u60C5\u51B5\u4E0B\u5927\u6982\u5728 <strong>3~10s</strong> \u533A\u95F4\uFF0C\u6761\u4EF6\u7A0D\u5FAE\u590D\u6742\u7684\u60C5\u51B5\u4E0B\u6700\u5FEB\u901F\u5EA6\u80FD\u8FBE\u5230 <strong>25s</strong> \u4EE5\u5185\uFF0C\u5339\u914D\u5230\u7684\u540C\u7C7B\u578B <strong>Class</strong> \u8D8A\u591A\u901F\u5EA6\u8D8A\u6162\u3002</p></div><h4 id="\u5F00\u59CB\u4F7F\u7528" tabindex="-1"><a class="header-anchor" href="#\u5F00\u59CB\u4F7F\u7528" aria-hidden="true">#</a> \u5F00\u59CB\u4F7F\u7528</h4><p>\u4E0B\u9762\u662F\u4E00\u4E2A\u7B80\u5355\u7684\u7528\u6CD5\u793A\u4F8B\u3002</p><p>\u5047\u8BBE\u4E0B\u9762\u8FD9\u4E2A <code>Class</code> \u662F\u6211\u4EEC\u60F3\u8981\u5F97\u5230\u7684\uFF0C\u5176\u4E2D\u7684\u540D\u79F0\u7ECF\u8FC7\u4E86\u6DF7\u6DC6\uFF0C\u5728\u6BCF\u4E2A\u7248\u672C\u53EF\u80FD\u90FD\u4E0D\u4E00\u6837\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-java ext-java"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">package</span><span style="color:#ADBAC7;"> com.demo;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">class</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">a</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">extends</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">Activity</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">implements</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">Serializable</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">a</span><span style="color:#ADBAC7;">(String </span><span style="color:#F69D50;">var1</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">private</span><span style="color:#ADBAC7;"> String</span><span style="color:#F69D50;"> </span><span style="color:#ADBAC7;">a;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">private</span><span style="color:#ADBAC7;"> String</span><span style="color:#F69D50;"> </span><span style="color:#ADBAC7;">b;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">private</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">boolean</span><span style="color:#F69D50;"> </span><span style="color:#ADBAC7;">a;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">protected</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">void</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">onCreate</span><span style="color:#ADBAC7;">(Bundle </span><span style="color:#F69D50;">var1</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">private</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">static</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">void</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">a</span><span style="color:#ADBAC7;">(String </span><span style="color:#F69D50;">var1</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">private</span><span style="color:#ADBAC7;"> String </span><span style="color:#DCBDFB;">a</span><span style="color:#ADBAC7;">(</span><span style="color:#F47067;">boolean</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">var1</span><span style="color:#ADBAC7;">, String </span><span style="color:#F69D50;">var2</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">private</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">void</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">a</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">void</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">a</span><span style="color:#ADBAC7;">(</span><span style="color:#F47067;">boolean</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">var1</span><span style="color:#ADBAC7;">, </span><span style="color:#F69D50;">a</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">var2</span><span style="color:#ADBAC7;">, </span><span style="color:#F69D50;">b</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">var3</span><span style="color:#ADBAC7;">, String </span><span style="color:#F69D50;">var4</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre></div><p>\u6B64\u65F6\uFF0C\u6211\u4EEC\u60F3\u5F97\u5230\u8FD9\u4E2A <code>Class</code>\uFF0C\u53EF\u4EE5\u76F4\u63A5\u4F7F\u7528 <code>ClassLoader.searchClass</code> \u65B9\u6CD5\u3002</p><p>\u4E0B\u65B9\u6F14\u793A\u7684\u6761\u4EF6\u4E2D\u6BCF\u4E00\u4E2A\u90FD\u662F\u53EF\u9009\u7684\uFF0C\u6761\u4EF6\u8D8A\u590D\u6742\u5B9A\u4F4D\u8D8A\u7CBE\u786E\uFF0C\u540C\u65F6\u6027\u80FD\u4E5F\u4F1A\u8D8A\u5DEE\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#ADBAC7;">searchClass {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u4ECE\u6307\u5B9A\u7684\u5305\u540D\u8303\u56F4\u5F00\u59CB\u67E5\u627E\uFF0C\u5B9E\u9645\u4F7F\u7528\u65F6\uFF0C\u4F60\u53EF\u4EE5\u540C\u65F6\u6307\u5B9A\u591A\u4E2A\u5305\u540D\u8303\u56F4</span></span>
<span class="line"><span style="color:#ADBAC7;">    from(</span><span style="color:#96D0FF;">&quot;com.demo&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u6307\u5B9A\u5F53\u524D Class \u7684 getSimpleName \u7684\u7ED3\u679C\uFF0C\u4F60\u53EF\u4EE5\u76F4\u63A5\u5BF9\u8FD9\u4E2A\u5B57\u7B26\u4E32\u8FDB\u884C\u903B\u8F91\u5224\u65AD</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u8FD9\u91CC\u6211\u4EEC\u4E0D\u786E\u5B9A\u5B83\u7684\u540D\u79F0\u662F\u4E0D\u662F a\uFF0C\u53EF\u4EE5\u53EA\u5224\u65AD\u5B57\u7B26\u4E32\u957F\u5EA6</span></span>
<span class="line"><span style="color:#ADBAC7;">    simpleName { it.length </span><span style="color:#F47067;">==</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">1</span><span style="color:#ADBAC7;"> }</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u6307\u5B9A\u7EE7\u627F\u7684\u7236\u7C7B\u5BF9\u8C61\uFF0C\u5982\u679C\u662F\u5B58\u5728\u7684 stub\uFF0C\u53EF\u4EE5\u76F4\u63A5\u7528\u6CDB\u578B\u8868\u793A</span></span>
<span class="line"><span style="color:#ADBAC7;">    extends</span><span style="color:#F47067;">&lt;</span><span style="color:#F69D50;">Activity</span><span style="color:#F47067;">&gt;</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u6307\u5B9A\u7EE7\u627F\u7684\u7236\u7C7B\u5BF9\u8C61\uFF0C\u53EF\u4EE5\u76F4\u63A5\u5199\u4E3A\u5B8C\u6574\u7C7B\u540D\uFF0C\u4F60\u8FD8\u53EF\u4EE5\u540C\u65F6\u6307\u5B9A\u591A\u4E2A</span></span>
<span class="line"><span style="color:#ADBAC7;">    extends(</span><span style="color:#96D0FF;">&quot;android.app.Activity&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u6307\u5B9A\u5B9E\u73B0\u7684\u63A5\u53E3\uFF0C\u5982\u679C\u662F\u5B58\u5728\u7684 stub\uFF0C\u53EF\u4EE5\u76F4\u63A5\u7528\u6CDB\u578B\u8868\u793A</span></span>
<span class="line"><span style="color:#ADBAC7;">    implements</span><span style="color:#F47067;">&lt;</span><span style="color:#F69D50;">Serializable</span><span style="color:#F47067;">&gt;</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u6307\u5B9A\u5B9E\u73B0\u7684\u63A5\u53E3\uFF0C\u53EF\u4EE5\u76F4\u63A5\u5199\u4E3A\u5B8C\u6574\u7C7B\u540D\uFF0C\u4F60\u8FD8\u53EF\u4EE5\u540C\u65F6\u6307\u5B9A\u591A\u4E2A</span></span>
<span class="line"><span style="color:#ADBAC7;">    implements(</span><span style="color:#96D0FF;">&quot;java.io.Serializable&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u6307\u5B9A\u6784\u9020\u65B9\u6CD5\u7684\u7C7B\u578B\u4E0E\u6837\u5F0F\uFF0C\u4EE5\u53CA\u5728\u5F53\u524D\u7C7B\u4E2D\u5B58\u5728\u7684\u4E2A\u6570 count</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#DCBDFB;">constructor</span><span style="color:#ADBAC7;"> { param(</span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;">) }.count(num </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">1</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u6307\u5B9A\u53D8\u91CF\u7684\u7C7B\u578B\u4E0E\u6837\u5F0F\uFF0C\u4EE5\u53CA\u5728\u5F53\u524D\u7C7B\u4E2D\u5B58\u5728\u7684\u4E2A\u6570 count</span></span>
<span class="line"><span style="color:#ADBAC7;">    field { type </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;"> }.count(num </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">2</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u6307\u5B9A\u53D8\u91CF\u7684\u7C7B\u578B\u4E0E\u6837\u5F0F\uFF0C\u4EE5\u53CA\u5728\u5F53\u524D\u7C7B\u4E2D\u5B58\u5728\u7684\u4E2A\u6570 count</span></span>
<span class="line"><span style="color:#ADBAC7;">    field { type </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">BooleanType</span><span style="color:#ADBAC7;"> }.count(num </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">1</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u76F4\u63A5\u6307\u5B9A\u6240\u6709\u53D8\u91CF\u5728\u5F53\u524D\u7C7B\u4E2D\u5B58\u5728\u7684\u4E2A\u6570 count</span></span>
<span class="line"><span style="color:#ADBAC7;">    field().count(num </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">3</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u5982\u679C\u4F60\u8BA4\u4E3A\u53D8\u91CF\u7684\u4E2A\u6570\u662F\u4E0D\u786E\u5B9A\u7684\uFF0C\u8FD8\u53EF\u4EE5\u4F7F\u7528\u5982\u4E0B\u81EA\u5B9A\u4E49\u6761\u4EF6</span></span>
<span class="line"><span style="color:#ADBAC7;">    field().count(</span><span style="color:#6CB6FF;">1</span><span style="color:#ADBAC7;">..</span><span style="color:#6CB6FF;">3</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    field().count { it </span><span style="color:#F47067;">&gt;=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">3</span><span style="color:#ADBAC7;"> }</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u6307\u5B9A\u65B9\u6CD5\u7684\u7C7B\u578B\u4E0E\u6837\u5F0F\uFF0C\u4EE5\u53CA\u5728\u5F53\u524D\u7C7B\u4E2D\u5B58\u5728\u7684\u4E2A\u6570 count</span></span>
<span class="line"><span style="color:#ADBAC7;">    method {</span></span>
<span class="line"><span style="color:#ADBAC7;">        name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;onCreate&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">        param(</span><span style="color:#F69D50;">BundleClass</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    }.count(num </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">1</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u6307\u5B9A\u65B9\u6CD5\u7684\u7C7B\u578B\u4E0E\u6837\u5F0F\uFF0C\u540C\u65F6\u6307\u5B9A\u4FEE\u9970\u7B26\uFF0C\u4EE5\u53CA\u5728\u5F53\u524D\u7C7B\u4E2D\u5B58\u5728\u7684\u4E2A\u6570 count</span></span>
<span class="line"><span style="color:#ADBAC7;">    method {</span></span>
<span class="line"><span style="color:#ADBAC7;">        modifiers { isStatic </span><span style="color:#F47067;">&amp;&amp;</span><span style="color:#ADBAC7;"> isPrivate }</span></span>
<span class="line"><span style="color:#ADBAC7;">        param(</span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">        returnType </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">UnitType</span></span>
<span class="line"><span style="color:#ADBAC7;">    }.count(num </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">1</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u6307\u5B9A\u65B9\u6CD5\u7684\u7C7B\u578B\u4E0E\u6837\u5F0F\uFF0C\u540C\u65F6\u6307\u5B9A\u4FEE\u9970\u7B26\uFF0C\u4EE5\u53CA\u5728\u5F53\u524D\u7C7B\u4E2D\u5B58\u5728\u7684\u4E2A\u6570 count</span></span>
<span class="line"><span style="color:#ADBAC7;">    method {</span></span>
<span class="line"><span style="color:#ADBAC7;">        modifiers { isPrivate </span><span style="color:#F47067;">&amp;&amp;</span><span style="color:#ADBAC7;"> isStatic.</span><span style="color:#F47067;">not</span><span style="color:#ADBAC7;">() }</span></span>
<span class="line"><span style="color:#ADBAC7;">        param(</span><span style="color:#F69D50;">BooleanType</span><span style="color:#ADBAC7;">, </span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">        returnType </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">StringClass</span></span>
<span class="line"><span style="color:#ADBAC7;">    }.count(num </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">1</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u6307\u5B9A\u65B9\u6CD5\u7684\u7C7B\u578B\u4E0E\u6837\u5F0F\uFF0C\u540C\u65F6\u6307\u5B9A\u4FEE\u9970\u7B26\uFF0C\u4EE5\u53CA\u5728\u5F53\u524D\u7C7B\u4E2D\u5B58\u5728\u7684\u4E2A\u6570 count</span></span>
<span class="line"><span style="color:#ADBAC7;">    method {</span></span>
<span class="line"><span style="color:#ADBAC7;">        modifiers { isPrivate </span><span style="color:#F47067;">&amp;&amp;</span><span style="color:#ADBAC7;"> isStatic.</span><span style="color:#F47067;">not</span><span style="color:#ADBAC7;">() }</span></span>
<span class="line"><span style="color:#ADBAC7;">        emptyParam()</span></span>
<span class="line"><span style="color:#ADBAC7;">        returnType </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">UnitType</span></span>
<span class="line"><span style="color:#ADBAC7;">    }.count(num </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">1</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u6307\u5B9A\u65B9\u6CD5\u7684\u7C7B\u578B\u4E0E\u6837\u5F0F\uFF0C\u540C\u65F6\u6307\u5B9A\u4FEE\u9970\u7B26\u548C\u6A21\u7CCA\u7C7B\u578B VagueType\uFF0C\u4EE5\u53CA\u5728\u5F53\u524D\u7C7B\u4E2D\u5B58\u5728\u7684\u4E2A\u6570 count</span></span>
<span class="line"><span style="color:#ADBAC7;">    method {</span></span>
<span class="line"><span style="color:#ADBAC7;">        modifiers { isPrivate </span><span style="color:#F47067;">&amp;&amp;</span><span style="color:#ADBAC7;"> isStatic.</span><span style="color:#F47067;">not</span><span style="color:#ADBAC7;">() }</span></span>
<span class="line"><span style="color:#ADBAC7;">        param(</span><span style="color:#F69D50;">BooleanType</span><span style="color:#ADBAC7;">, </span><span style="color:#F69D50;">VagueType</span><span style="color:#ADBAC7;">, </span><span style="color:#F69D50;">VagueType</span><span style="color:#ADBAC7;">, </span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">        returnType </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">UnitType</span></span>
<span class="line"><span style="color:#ADBAC7;">    }.count(num </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">1</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u76F4\u63A5\u6307\u5B9A\u6240\u6709\u65B9\u6CD5\u5728\u5F53\u524D\u7C7B\u4E2D\u5B58\u5728\u7684\u4E2A\u6570 count</span></span>
<span class="line"><span style="color:#ADBAC7;">    method().count(num </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">5</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u5982\u679C\u4F60\u8BA4\u4E3A\u65B9\u6CD5\u7684\u4E2A\u6570\u662F\u4E0D\u786E\u5B9A\u7684\uFF0C\u8FD8\u53EF\u4EE5\u4F7F\u7528\u5982\u4E0B\u81EA\u5B9A\u4E49\u6761\u4EF6</span></span>
<span class="line"><span style="color:#ADBAC7;">    method().count(</span><span style="color:#6CB6FF;">1</span><span style="color:#ADBAC7;">..</span><span style="color:#6CB6FF;">5</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    method().count { it </span><span style="color:#F47067;">&gt;=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">5</span><span style="color:#ADBAC7;"> }</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u76F4\u63A5\u6307\u5B9A\u6240\u6709\u6210\u5458 (Member) \u5728\u5F53\u524D\u7C7B\u4E2D\u5B58\u5728\u7684\u4E2A\u6570 count</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u6210\u5458\u5305\u62EC\uFF1AField (\u53D8\u91CF)\u3001Method (\u65B9\u6CD5)\u3001Constructor (\u6784\u9020\u65B9\u6CD5)</span></span>
<span class="line"><span style="color:#ADBAC7;">    member().count(num </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">9</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u6240\u6709\u6210\u5458\u4E2D\u4E00\u5B9A\u5B58\u5728\u4E00\u4E2A static \u4FEE\u9970\u7B26\uFF0C\u53EF\u4EE5\u8FD9\u6837\u52A0\u5165\u6B64\u6761\u4EF6</span></span>
<span class="line"><span style="color:#ADBAC7;">    member {</span></span>
<span class="line"><span style="color:#ADBAC7;">        modifiers { isStatic }</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get() </span><span style="color:#768390;">// \u5F97\u5230\u8FD9\u4E2A Class \u672C\u8EAB\u7684\u5B9E\u4F8B\uFF0C\u627E\u4E0D\u5230\u4F1A\u8FD4\u56DE null</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="custom-container tip"><p class="custom-container-title">\u5C0F\u63D0\u793A</p><p>\u4E0A\u8FF0\u7528\u6CD5\u4E2D\u5BF9\u4E8E <strong>Field</strong>\u3001<strong>Method</strong>\u3001<strong>Constructor</strong> \u7684\u6761\u4EF6\u7528\u6CD5\u4E0E <a href="#member-%E6%89%A9%E5%B1%95">Member \u6269\u5C55</a> \u4E2D\u7684\u76F8\u5173\u7528\u6CD5\u662F\u4E00\u81F4\u7684\uFF0C\u4EC5\u6709\u5C0F\u90E8\u5206\u533A\u522B\u3002</p><p>\u66F4\u591A\u529F\u80FD\u8BF7\u53C2\u8003 <a href="../api/public/com/highcapable/yukireflection/finder/classes/rules/MemberRules">MemberRules</a>\u3001<a href="../api/public/com/highcapable/yukireflection/finder/classes/rules/FieldRules">FieldRules</a>\u3001<a href="../api/public/com/highcapable/yukireflection/finder/classes/rules/MethodRules">MethodRules</a>\u3001<a href="../api/public/com/highcapable/yukireflection/finder/classes/rules/ConstructorRules">ConstructorRules</a>\u3002</p></div><h4 id="\u5F02\u6B65\u67E5\u627E" tabindex="-1"><a class="header-anchor" href="#\u5F02\u6B65\u67E5\u627E" aria-hidden="true">#</a> \u5F02\u6B65\u67E5\u627E</h4><p>\u9ED8\u8BA4\u60C5\u51B5\u4E0B <code>DexClassFinder</code> \u4F1A\u4F7F\u7528\u540C\u6B65\u65B9\u5F0F\u67E5\u627E <code>Class</code>\uFF0C\u4F1A\u963B\u585E\u5F53\u524D\u7EBF\u7A0B\u76F4\u5230\u627E\u5230\u6216\u627E\u4E0D\u5230\u53D1\u751F\u5F02\u5E38\u4E3A\u6B62\uFF0C\u82E5\u67E5\u627E\u6D88\u8017\u7684\u65F6\u95F4\u8FC7\u957F\uFF0C\u53EF\u80FD\u4F1A\u5BFC\u81F4\u5F53\u524D APP \u53D1\u751F <strong>ANR</strong> \u95EE\u9898\u3002</p><p>\u9488\u5BF9\u4E0A\u8FF0\u95EE\u9898\uFF0C\u6211\u4EEC\u53EF\u4EE5\u542F\u7528\u5F02\u6B65\uFF0C\u53EA\u9700\u8981\u52A0\u5165\u53C2\u6570 <code>async = true</code>\uFF0C\u8FD9\u5C06\u4E0D\u9700\u8981\u4F60\u518D\u6B21\u542F\u52A8\u4E00\u4E2A\u7EBF\u7A0B\uFF0CAPI \u5DF2\u5E2E\u4F60\u5904\u7406\u597D\u76F8\u5173\u95EE\u9898\u3002</p><div class="custom-container warning"><p class="custom-container-title">\u6CE8\u610F</p><p>\u82E5\u8981\u4F7F\u7528\u6B64\u529F\u80FD\uFF0C\u4F60\u9700\u8981\u5728\u65B9\u6CD5\u53C2\u6570\u9996\u4F4D\u4F20\u5165\u5F53\u524D APP \u7684 <strong>Context</strong>\u3002</p><p>\u5BF9\u4E8E\u5F02\u6B65\u60C5\u51B5\u4E0B\u4F60\u9700\u8981\u4F7F\u7528 <strong>wait</strong> \u65B9\u6CD5\u6765\u5F97\u5230\u7ED3\u679C\uFF0C<strong>get</strong> \u65B9\u6CD5\u5C06\u4E0D\u518D\u8D77\u4F5C\u7528\u3002</p></div><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> context</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Context</span><span style="color:#ADBAC7;"> </span><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u5F53\u524D APP \u7684 Context</span></span>
<span class="line"><span style="color:#ADBAC7;">searchClass(context, async </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">true</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">}.wait { class1 </span><span style="color:#F47067;">-&gt;</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u5F97\u5230\u5F02\u6B65\u7ED3\u679C</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"><span style="color:#ADBAC7;">searchClass(context, async </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">true</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">}.wait { class2 </span><span style="color:#F47067;">-&gt;</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u5F97\u5230\u5F02\u6B65\u7ED3\u679C</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u8FD9\u6837\u6211\u4EEC\u7684\u67E5\u627E\u8FC7\u7A0B\u5C31\u662F\u5F02\u6B65\u8FD0\u884C\u4E86\uFF0C\u5B83\u5C06\u4E0D\u4F1A\u963B\u585E\u4E3B\u7EBF\u7A0B\uFF0C\u6BCF\u4E2A\u67E5\u627E\u90FD\u5C06\u5728\u5355\u72EC\u7684\u7EBF\u7A0B\u540C\u65F6\u8FDB\u884C\uFF0C\u53EF\u8FBE\u5230\u5E76\u884C\u4EFB\u52A1\u7684\u6548\u679C\u3002</p><h4 id="\u672C\u5730\u7F13\u5B58" tabindex="-1"><a class="header-anchor" href="#\u672C\u5730\u7F13\u5B58" aria-hidden="true">#</a> \u672C\u5730\u7F13\u5B58</h4><p>\u7531\u4E8E\u6BCF\u6B21\u91CD\u65B0\u6253\u5F00\u5F53\u524D APP \u90FD\u4F1A\u91CD\u65B0\u8FDB\u884C\u67E5\u627E\uFF0C\u5728\u5F53\u524D APP \u7248\u672C\u4E0D\u53D8\u7684\u60C5\u51B5\u4E0B\u8FD9\u662F\u4E00\u79CD\u91CD\u590D\u6027\u80FD\u6D6A\u8D39\u3002</p><p>\u6B64\u65F6\u6211\u4EEC\u53EF\u4EE5\u901A\u8FC7\u6307\u5B9A <code>name</code> \u53C2\u6570\u6765\u5BF9\u5F53\u524D APP \u7248\u672C\u7684\u67E5\u627E\u7ED3\u679C\u8FDB\u884C\u672C\u5730\u7F13\u5B58\uFF0C\u4E0B\u4E00\u6B21\u5C06\u76F4\u63A5\u4ECE\u672C\u5730\u7F13\u5B58\u4E2D\u8BFB\u53D6\u67E5\u627E\u5230\u7684\u7C7B\u540D\u3002</p><p>\u672C\u5730\u7F13\u5B58\u4F7F\u7528\u7684\u662F <code>SharedPreferences</code>\uFF0C\u5B83\u5C06\u88AB\u4FDD\u5B58\u5230\u5F53\u524D APP \u7684\u6570\u636E\u76EE\u5F55\u4E2D\uFF0C\u5728\u5F53\u524D APP \u7248\u672C\u66F4\u65B0\u540E\u4F1A\u91CD\u65B0\u8FDB\u884C\u7F13\u5B58\u3002</p><p>\u542F\u7528\u672C\u5730\u7F13\u5B58\u540E\uFF0C\u5C06\u540C\u65F6\u8BBE\u7F6E <code>async = true</code>\uFF0C\u4F60\u53EF\u4EE5\u4E0D\u9700\u8981\u518D\u624B\u52A8\u8FDB\u884C\u8BBE\u7F6E\u3002</p><div class="custom-container warning"><p class="custom-container-title">\u6CE8\u610F</p><p>\u82E5\u8981\u4F7F\u7528\u6B64\u529F\u80FD\uFF0C\u4F60\u9700\u8981\u5728\u65B9\u6CD5\u53C2\u6570\u9996\u4F4D\u4F20\u5165\u5F53\u524D APP \u7684 <strong>Context</strong>\u3002</p></div><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> context</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Context</span><span style="color:#ADBAC7;"> </span><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u5F53\u524D APP \u7684 Context</span></span>
<span class="line"><span style="color:#ADBAC7;">searchClass(context, name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.demo.class1&quot;</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">}.wait { class1 </span><span style="color:#F47067;">-&gt;</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u5F97\u5230\u5F02\u6B65\u7ED3\u679C</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"><span style="color:#ADBAC7;">searchClass(context, name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.demo.class2&quot;</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">}.wait { class2 </span><span style="color:#F47067;">-&gt;</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u5F97\u5230\u5F02\u6B65\u7ED3\u679C</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u5982\u679C\u4F60\u60F3\u624B\u52A8\u6E05\u9664\u672C\u5730\u7F13\u5B58\uFF0C\u53EF\u4EE5\u4F7F\u7528\u5982\u4E0B\u65B9\u6CD5\u6E05\u9664\u5F53\u524D APP \u7248\u672C\u7684\u7F13\u5B58\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> context</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Context</span><span style="color:#ADBAC7;"> </span><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u5F53\u524D APP \u7684 Context</span></span>
<span class="line"><span style="color:#F69D50;">DexClassFinder</span><span style="color:#ADBAC7;">.clearCache(context)</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p>\u4F60\u8FD8\u53EF\u4EE5\u6E05\u9664\u6307\u5B9A\u7248\u672C\u7684 APP \u7F13\u5B58\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> context</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Context</span><span style="color:#ADBAC7;"> </span><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u5F53\u524D APP \u7684 Context</span></span>
<span class="line"><span style="color:#F69D50;">DexClassFinder</span><span style="color:#ADBAC7;">.clearCache(context, versionName </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;1.0&quot;</span><span style="color:#ADBAC7;">, versionCode </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">1</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="\u591A\u91CD\u67E5\u627E" tabindex="-1"><a class="header-anchor" href="#\u591A\u91CD\u67E5\u627E" aria-hidden="true">#</a> \u591A\u91CD\u67E5\u627E</h4><p>\u5982\u679C\u4F60\u9700\u8981\u4F7F\u7528\u56FA\u5B9A\u7684\u6761\u4EF6\u540C\u65F6\u67E5\u627E\u4E00\u7EC4 <code>Class</code>\uFF0C\u90A3\u4E48\u4F60\u53EA\u9700\u8981\u4F7F\u7528 <code>all</code> \u6216 <code>waitAll</code> \u65B9\u6CD5\u6765\u5F97\u5230\u7ED3\u679C\u3002</p><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u540C\u6B65\u67E5\u627E\uFF0C\u4F7F\u7528 all \u5F97\u5230\u6761\u4EF6\u5168\u90E8\u67E5\u627E\u5230\u7684\u7ED3\u679C</span></span>
<span class="line"><span style="color:#ADBAC7;">searchClass {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">}.all().forEach { clazz </span><span style="color:#F47067;">-&gt;</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u5F97\u5230\u6BCF\u4E2A\u7ED3\u679C</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"><span style="color:#768390;">// \u540C\u6B65\u67E5\u627E\uFF0C\u4F7F\u7528 all { ... } \u904D\u5386\u6BCF\u4E2A\u7ED3\u679C</span></span>
<span class="line"><span style="color:#ADBAC7;">searchClass {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">}.all { clazz </span><span style="color:#F47067;">-&gt;</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u5F97\u5230\u6BCF\u4E2A\u7ED3\u679C</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"><span style="color:#768390;">// \u5F02\u6B65\u67E5\u627E\uFF0C\u4F7F\u7528 waitAll \u5F97\u5230\u6761\u4EF6\u5168\u90E8\u67E5\u627E\u5230\u7684\u7ED3\u679C</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> context</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Context</span><span style="color:#ADBAC7;"> </span><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u5F53\u524D APP \u7684 Context</span></span>
<span class="line"><span style="color:#ADBAC7;">searchClass(context, async </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">true</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">}.waitAll { classes </span><span style="color:#F47067;">-&gt;</span></span>
<span class="line"><span style="color:#ADBAC7;">    classes.forEach {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// \u5F97\u5230\u6BCF\u4E2A\u7ED3\u679C</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="custom-container tip"><p class="custom-container-title">\u5C0F\u63D0\u793A</p><p>\u66F4\u591A\u529F\u80FD\u8BF7\u53C2\u8003 <a href="../api/public/com/highcapable/yukireflection/factory/ReflectionFactory#classloader-searchclass-ext-method">ClassLoader.searchClass</a> \u65B9\u6CD5\u3002</p></div><h2 id="member-\u6269\u5C55" tabindex="-1"><a class="header-anchor" href="#member-\u6269\u5C55" aria-hidden="true">#</a> Member \u6269\u5C55</h2><blockquote><p>\u8FD9\u91CC\u662F <strong>Class</strong> \u5B57\u8282\u7801\u6210\u5458\u53D8\u91CF <strong>Field</strong>\u3001<strong>Method</strong>\u3001<strong>Constructor</strong> \u76F8\u5173\u7684\u6269\u5C55\u529F\u80FD\u3002</p></blockquote><div class="custom-container tip"><p class="custom-container-title">\u5C0F\u63D0\u793A</p><p><strong>Member</strong> \u662F <strong>Field</strong>\u3001<strong>Method</strong>\u3001<strong>Constructor</strong> \u7684\u63A5\u53E3\u63CF\u8FF0\u5BF9\u8C61\uFF0C\u5B83\u5728 Java \u53CD\u5C04\u4E2D\u4E3A <strong>Class</strong> \u4E2D\u5B57\u8282\u7801\u6210\u5458\u7684\u603B\u79F0\u3002</p></div><p>\u5047\u8BBE\u6709\u4E00\u4E2A\u8FD9\u6837\u7684 <code>Class</code>\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-java ext-java"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">package</span><span style="color:#ADBAC7;"> com.demo;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">class</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">BaseTest</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">BaseTest</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">BaseTest</span><span style="color:#ADBAC7;">(</span><span style="color:#F47067;">boolean</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">isInit</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">private</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">void</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">doBaseTask</span><span style="color:#ADBAC7;">(String </span><span style="color:#F69D50;">taskName</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre></div><div class="language-java ext-java"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">package</span><span style="color:#ADBAC7;"> com.demo;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">class</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">extends</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">BaseTest</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">Test</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">Test</span><span style="color:#ADBAC7;">(</span><span style="color:#F47067;">boolean</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">isInit</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">private</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">static</span><span style="color:#ADBAC7;"> TAG </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;Test&quot;</span><span style="color:#ADBAC7;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">private</span><span style="color:#ADBAC7;"> BaseTest</span><span style="color:#F69D50;"> </span><span style="color:#ADBAC7;">baseInstance;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">private</span><span style="color:#ADBAC7;"> String</span><span style="color:#F69D50;"> </span><span style="color:#ADBAC7;">a;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">private</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">boolean</span><span style="color:#F69D50;"> </span><span style="color:#ADBAC7;">a;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">private</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">boolean</span><span style="color:#F69D50;"> </span><span style="color:#ADBAC7;">isTaskRunning</span><span style="color:#F69D50;"> </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">false</span><span style="color:#ADBAC7;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">private</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">static</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">void</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">init</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">private</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">void</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">doTask</span><span style="color:#ADBAC7;">(String </span><span style="color:#F69D50;">taskName</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">private</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">void</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">release</span><span style="color:#ADBAC7;">(String </span><span style="color:#F69D50;">taskName</span><span style="color:#ADBAC7;">, Function&lt;</span><span style="color:#F47067;">boolean</span><span style="color:#ADBAC7;">, </span><span style="color:#F47067;">String</span><span style="color:#ADBAC7;">&gt; </span><span style="color:#F69D50;">task</span><span style="color:#ADBAC7;">, </span><span style="color:#F47067;">boolean</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">isFinish</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">private</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">void</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">stop</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">private</span><span style="color:#ADBAC7;"> String </span><span style="color:#DCBDFB;">getName</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">private</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">void</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">b</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">private</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">void</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">b</span><span style="color:#ADBAC7;">(String </span><span style="color:#F69D50;">a</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre></div><h3 id="\u67E5\u627E\u4E0E\u53CD\u5C04\u8C03\u7528" tabindex="-1"><a class="header-anchor" href="#\u67E5\u627E\u4E0E\u53CD\u5C04\u8C03\u7528" aria-hidden="true">#</a> \u67E5\u627E\u4E0E\u53CD\u5C04\u8C03\u7528</h3><p>\u5047\u8BBE\u6211\u4EEC\u8981\u5F97\u5230 <code>Test</code>(\u4EE5\u4E0B\u7EDF\u79F0\u201C\u5F53\u524D <code>Class</code>\u201D)\u7684 <code>doTask</code> \u65B9\u6CD5\u5E76\u6267\u884C\uFF0C\u901A\u5E38\u60C5\u51B5\u4E0B\uFF0C\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528\u6807\u51C6\u7684\u53CD\u5C04 API \u53BB\u67E5\u627E\u8FD9\u4E2A\u65B9\u6CD5\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u4F7F\u7528\u53CD\u5C04 API \u8C03\u7528\u5E76\u6267\u884C</span></span>
<span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java</span></span>
<span class="line"><span style="color:#ADBAC7;">    .getDeclaredMethod(</span><span style="color:#96D0FF;">&quot;doTask&quot;</span><span style="color:#ADBAC7;">, String::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java)</span></span>
<span class="line"><span style="color:#ADBAC7;">    .</span><span style="color:#6CB6FF;">apply</span><span style="color:#ADBAC7;"> { isAccessible </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">true</span><span style="color:#ADBAC7;"> }</span></span>
<span class="line"><span style="color:#ADBAC7;">    .invoke(instance, </span><span style="color:#96D0FF;">&quot;task_name&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u8FD9\u79CD\u5199\u6CD5\u5927\u6982\u4E0D\u662F\u5F88\u53CB\u597D\uFF0C\u6B64\u65F6 <code>YukiReflection</code> \u5C31\u4E3A\u4F60\u63D0\u4F9B\u4E86\u4E00\u4E2A\u53EF\u5728\u4EFB\u610F\u5730\u65B9\u4F7F\u7528\u7684\u8BED\u6CD5\u7CD6\u3002</p><p>\u4EE5\u4E0A\u5199\u6CD5\u6362\u505A <code>YukiReflection</code> \u53EF\u5199\u4F5C\u5982\u4E0B\u5F62\u5F0F\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u4F7F\u7528 YukiReflection \u8C03\u7528\u5E76\u6267\u884C</span></span>
<span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;doTask&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    param(</span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get(instance).call(</span><span style="color:#96D0FF;">&quot;task_name&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="custom-container tip"><p class="custom-container-title">\u5C0F\u63D0\u793A</p><p>\u66F4\u591A\u529F\u80FD\u8BF7\u53C2\u8003 <a href="../api/public/com/highcapable/yukireflection/finder/members/MethodFinder">MethodFinder</a>\u3002</p></div><p>\u540C\u6837\u5730\uFF0C\u6211\u4EEC\u9700\u8981\u5F97\u5230 <code>isTaskRunning</code> \u53D8\u91CF\u4E5F\u53EF\u4EE5\u5199\u4F5C\u5982\u4E0B\u5F62\u5F0F\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u4F7F\u7528 YukiReflection \u8C03\u7528\u5E76\u6267\u884C</span></span>
<span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.field {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;isTaskRunning&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    type </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">BooleanType</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get(instance).any() </span><span style="color:#768390;">// any \u4E3A Field \u7684\u4EFB\u610F\u7C7B\u578B\u5B9E\u4F8B\u5316\u5BF9\u8C61</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="custom-container tip"><p class="custom-container-title">\u5C0F\u63D0\u793A</p><p>\u66F4\u591A\u529F\u80FD\u8BF7\u53C2\u8003 <a href="../api/public/com/highcapable/yukireflection/finder/members/FieldFinder">FieldFinder</a>\u3002</p></div><p>\u4E5F\u8BB8\u4F60\u8FD8\u60F3\u5F97\u5230\u5F53\u524D <code>Class</code> \u7684\u6784\u9020\u65B9\u6CD5\uFF0C\u540C\u6837\u53EF\u4EE5\u5B9E\u73B0\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.</span><span style="color:#DCBDFB;">constructor</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"><span style="color:#ADBAC7;">    param(</span><span style="color:#F69D50;">BooleanType</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get().call(</span><span style="color:#6CB6FF;">true</span><span style="color:#ADBAC7;">) </span><span style="color:#768390;">// \u53EF\u521B\u5EFA\u4E00\u4E2A\u65B0\u7684\u5B9E\u4F8B</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u82E5\u60F3\u5F97\u5230\u7684\u662F <code>Class</code> \u7684\u65E0\u53C2\u6784\u9020\u65B9\u6CD5\uFF0C\u53EF\u5199\u4F5C\u5982\u4E0B\u5F62\u5F0F\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.</span><span style="color:#DCBDFB;">constructor</span><span style="color:#ADBAC7;">().get().call() </span><span style="color:#768390;">// \u53EF\u521B\u5EFA\u4E00\u4E2A\u65B0\u7684\u5B9E\u4F8B</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><div class="custom-container tip"><p class="custom-container-title">\u5C0F\u63D0\u793A</p><p>\u66F4\u591A\u529F\u80FD\u8BF7\u53C2\u8003 <a href="../api/public/com/highcapable/yukireflection/finder/members/ConstructorFinder">ConstructorFinder</a>\u3002</p></div><h3 id="\u53EF\u9009\u7684\u67E5\u627E\u6761\u4EF6" tabindex="-1"><a class="header-anchor" href="#\u53EF\u9009\u7684\u67E5\u627E\u6761\u4EF6" aria-hidden="true">#</a> \u53EF\u9009\u7684\u67E5\u627E\u6761\u4EF6</h3><p>\u5047\u8BBE\u6211\u4EEC\u8981\u5F97\u5230 <code>Class</code> \u4E2D\u7684 <code>getName</code> \u65B9\u6CD5\uFF0C\u53EF\u4EE5\u4F7F\u7528\u5982\u4E0B\u5B9E\u73B0\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u4F7F\u7528 YukiReflection \u8C03\u7528\u5E76\u6267\u884C</span></span>
<span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;getName&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    emptyParam()</span></span>
<span class="line"><span style="color:#ADBAC7;">    returnType </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">StringClass</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get(instance).string() </span><span style="color:#768390;">// \u5F97\u5230\u65B9\u6CD5\u7684\u7ED3\u679C</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u901A\u8FC7\u89C2\u5BDF\u53D1\u73B0\uFF0C\u8FD9\u4E2A <code>Class</code> \u4E2D\u53EA\u6709\u4E00\u4E2A\u540D\u4E3A <code>getName</code> \u7684\u65B9\u6CD5\uFF0C\u90A3\u6211\u4EEC\u53EF\u4E0D\u53EF\u4EE5\u518D\u7B80\u5355\u4E00\u70B9\u5462\uFF1F</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u4F7F\u7528 YukiReflection \u8C03\u7528\u5E76\u6267\u884C</span></span>
<span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;getName&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    emptyParam()</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get(instance).string() </span><span style="color:#768390;">// \u5F97\u5230\u65B9\u6CD5\u7684\u7ED3\u679C</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u662F\u7684\uFF0C\u5BF9\u4E8E\u786E\u5207\u4E0D\u4F1A\u53D8\u5316\u7684\u65B9\u6CD5\uFF0C\u4F60\u53EF\u4EE5\u7CBE\u7B80\u67E5\u627E\u6761\u4EF6\u3002</p><p>\u5728\u53EA\u4F7F\u7528 <code>get</code> \u6216 <code>wait</code> \u65B9\u6CD5\u5F97\u5230\u7ED3\u679C\u65F6 <code>YukiReflection</code> <strong>\u4F1A\u9ED8\u8BA4\u6309\u7167\u5B57\u8282\u7801\u987A\u5E8F\u5339\u914D\u7B2C\u4E00\u4E2A\u67E5\u627E\u5230\u7684\u7ED3\u679C</strong>\u3002</p><p>\u95EE\u9898\u53C8\u6765\u4E86\uFF0C\u8FD9\u4E2A <code>Class</code> \u4E2D\u6709\u4E00\u4E2A <code>release</code> \u65B9\u6CD5\uFF0C\u4F46\u662F\u5B83\u7684\u65B9\u6CD5\u53C2\u6570\u5F88\u957F\uFF0C\u800C\u4E14\u90E8\u5206\u7C7B\u578B\u53EF\u80FD\u65E0\u6CD5\u76F4\u63A5\u5F97\u5230\u3002</p><p>\u901A\u5E38\u60C5\u51B5\u4E0B\u6211\u4EEC\u4F1A\u4F7F\u7528 <code>param(...)</code> \u6765\u67E5\u627E\u8FD9\u4E2A\u65B9\u6CD5\uFF0C\u4F46\u662F\u6709\u6CA1\u6709\u66F4\u7B80\u5355\u7684\u65B9\u6CD5\u5462\u3002</p><p>\u6B64\u65F6\uFF0C\u5728\u786E\u5B9A\u65B9\u6CD5\u552F\u4E00\u6027\u540E\uFF0C\u4F60\u53EF\u4EE5\u4F7F\u7528 <code>paramCount</code> \u6765\u67E5\u627E\u5230\u8FD9\u4E2A\u65B9\u6CD5\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u4F7F\u7528 YukiReflection \u8C03\u7528\u5E76\u6267\u884C</span></span>
<span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;release&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u6B64\u65F6\u6211\u4EEC\u4E0D\u5FC5\u786E\u5B9A\u65B9\u6CD5\u53C2\u6570\u5177\u4F53\u7C7B\u578B\uFF0C\u5199\u4E2A\u6570\u5C31\u597D</span></span>
<span class="line"><span style="color:#ADBAC7;">    paramCount </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">3</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get(instance) </span><span style="color:#768390;">// \u5F97\u5230\u8FD9\u4E2A\u65B9\u6CD5</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u4E0A\u8FF0\u793A\u4F8B\u867D\u7136\u80FD\u591F\u5339\u914D\u6210\u529F\uFF0C\u4F46\u662F\u4E0D\u7CBE\u786E\uFF0C\u6B64\u65F6\u4F60\u8FD8\u53EF\u4EE5\u4F7F\u7528 <code>VagueType</code> \u6765\u586B\u5145\u4F60\u4E0D\u60F3\u586B\u5199\u7684\u65B9\u6CD5\u53C2\u6570\u7C7B\u578B\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u4F7F\u7528 YukiReflection \u8C03\u7528\u5E76\u6267\u884C</span></span>
<span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;release&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u4F7F\u7528 VagueType \u6765\u586B\u5145\u4E0D\u60F3\u586B\u5199\u7684\u7C7B\u578B\uFF0C\u540C\u65F6\u4FDD\u8BC1\u5176\u5B83\u7C7B\u578B\u80FD\u591F\u5339\u914D</span></span>
<span class="line"><span style="color:#ADBAC7;">    param(</span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;">, </span><span style="color:#F69D50;">VagueType</span><span style="color:#ADBAC7;">, </span><span style="color:#F69D50;">BooleanType</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get(instance) </span><span style="color:#768390;">// \u5F97\u5230\u8FD9\u4E2A\u65B9\u6CD5</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u5982\u679C\u4F60\u5E76\u4E0D\u786E\u5B9A\u6BCF\u4E00\u4E2A\u53C2\u6570\u7684\u7C7B\u578B\uFF0C\u4F60\u53EF\u4EE5\u901A\u8FC7 <code>param { ... }</code> \u65B9\u6CD5\u6765\u521B\u5EFA\u4E00\u4E2A\u6761\u4EF6\u65B9\u6CD5\u4F53\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u4F7F\u7528 YukiReflection \u8C03\u7528\u5E76\u6267\u884C</span></span>
<span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;release&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u5F97\u5230 it (Class) \u65B9\u6CD5\u53C2\u6570\u7C7B\u578B\u6570\u7EC4\u5B9E\u4F8B\u6765\u4EC5\u5224\u65AD\u5DF2\u77E5\u7684\u7C7B\u578B\u548C\u5B83\u7684\u4F4D\u7F6E</span></span>
<span class="line"><span style="color:#ADBAC7;">    param { it[</span><span style="color:#6CB6FF;">0</span><span style="color:#ADBAC7;">] </span><span style="color:#F47067;">==</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">&amp;&amp;</span><span style="color:#ADBAC7;"> it[</span><span style="color:#6CB6FF;">2</span><span style="color:#ADBAC7;">] </span><span style="color:#F47067;">==</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">BooleanType</span><span style="color:#ADBAC7;"> }</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get(instance) </span><span style="color:#768390;">// \u5F97\u5230\u8FD9\u4E2A\u65B9\u6CD5</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="custom-container tip"><p class="custom-container-title">\u5C0F\u63D0\u793A</p><p>\u4F7F\u7528 <strong>param { ... }</strong> \u521B\u5EFA\u4E00\u4E2A\u6761\u4EF6\u65B9\u6CD5\u4F53\uFF0C\u5176\u4E2D\u7684\u53D8\u91CF <strong>it</strong> \u5373\u5F53\u524D\u65B9\u6CD5\u53C2\u6570\u7684 <strong>Class</strong> \u7C7B\u578B\u6570\u7EC4\u5B9E\u4F8B\uFF0C\u6B64\u65F6\u4F60\u5C31\u53EF\u4EE5\u81EA\u7531\u4F7F\u7528 <strong>Class</strong> \u4E2D\u7684\u6240\u6709\u5BF9\u8C61\u53CA\u5176\u65B9\u6CD5\u3002</p><p>\u65B9\u6CD5\u4F53\u672B\u5C3E\u6761\u4EF6\u9700\u8981\u8FD4\u56DE\u4E00\u4E2A <strong>Boolean</strong>\uFF0C\u5373\u6700\u7EC8\u7684\u6761\u4EF6\u5224\u65AD\u7ED3\u679C\u3002</p><p>\u66F4\u591A\u529F\u80FD\u8BF7\u53C2\u8003 <a href="../api/public/com/highcapable/yukireflection/finder/members/FieldFinder#type-method-1">FieldFinder.type</a>\u3001<a href="../api/public/com/highcapable/yukireflection/finder/members/MethodFinder#param-method-1">MethodFinder.param</a>\u3001<a href="../api/public/com/highcapable/yukireflection/finder/members/MethodFinder#returntype-method-1">MethodFinder.returnType</a>\u3001<a href="../api/public/com/highcapable/yukireflection/finder/members/ConstructorFinder#param-method-1">ConstructorFinder.param</a> \u65B9\u6CD5\u3002</p></div><h3 id="\u5728\u7236\u7C7B\u67E5\u627E" tabindex="-1"><a class="header-anchor" href="#\u5728\u7236\u7C7B\u67E5\u627E" aria-hidden="true">#</a> \u5728\u7236\u7C7B\u67E5\u627E</h3><p>\u4F60\u4F1A\u6CE8\u610F\u5230 <code>Test</code> \u7EE7\u627F\u4E8E <code>BaseTest</code>\uFF0C\u73B0\u5728\u6211\u4EEC\u60F3\u5F97\u5230 <code>BaseTest</code> \u7684 <code>doBaseTask</code> \u65B9\u6CD5\uFF0C\u5728\u4E0D\u77E5\u9053\u7236\u7C7B\u540D\u79F0\u7684\u60C5\u51B5\u4E0B\uFF0C\u8981\u600E\u4E48\u505A\u5462\uFF1F</p><p>\u53C2\u7167\u4E0A\u9762\u7684\u67E5\u627E\u6761\u4EF6\uFF0C\u6211\u4EEC\u53EA\u9700\u8981\u5728\u67E5\u627E\u6761\u4EF6\u4E2D\u52A0\u5165\u4E00\u4E2A <code>superClass</code> \u5373\u53EF\u5B9E\u73B0\u8FD9\u4E2A\u529F\u80FD\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u4F7F\u7528 YukiReflection \u8C03\u7528\u5E76\u6267\u884C</span></span>
<span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;doBaseTask&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    param(</span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u53EA\u9700\u8981\u6DFB\u52A0\u8FD9\u4E2A\u6761\u4EF6</span></span>
<span class="line"><span style="color:#ADBAC7;">    superClass()</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get(instance).call(</span><span style="color:#96D0FF;">&quot;task_name&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u8FD9\u4E2A\u65F6\u5019\u6211\u4EEC\u5C31\u53EF\u4EE5\u5728\u7236\u7C7B\u4E2D\u53D6\u5230\u8FD9\u4E2A\u65B9\u6CD5\u4E86\u3002</p><p><code>superClass</code> \u6709\u4E00\u4E2A\u53C2\u6570\u4E3A <code>isOnlySuperClass</code>\uFF0C\u8BBE\u7F6E\u4E3A <code>true</code> \u540E\uFF0C\u53EF\u4EE5\u8DF3\u8FC7\u5F53\u524D <code>Class</code> \u4EC5\u67E5\u627E\u5F53\u524D <code>Class</code> \u7684\u7236\u7C7B\u3002</p><p>\u7531\u4E8E\u6211\u4EEC\u73B0\u5728\u5DF2\u77E5 <code>doBaseTask</code> \u65B9\u6CD5\u53EA\u5B58\u5728\u4E8E\u7236\u7C7B\uFF0C\u53EF\u4EE5\u52A0\u4E0A\u8FD9\u4E2A\u6761\u4EF6\u8282\u7701\u67E5\u627E\u65F6\u95F4\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u4F7F\u7528 YukiReflection \u8C03\u7528\u5E76\u6267\u884C</span></span>
<span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;doBaseTask&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    param(</span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u52A0\u5165\u4E00\u4E2A\u67E5\u627E\u6761\u4EF6</span></span>
<span class="line"><span style="color:#ADBAC7;">    superClass(isOnlySuperClass </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">true</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get(instance).call(</span><span style="color:#96D0FF;">&quot;task_name&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u8FD9\u4E2A\u65F6\u5019\u6211\u4EEC\u540C\u6837\u53EF\u4EE5\u5F97\u5230\u7236\u7C7B\u4E2D\u7684\u8FD9\u4E2A\u65B9\u6CD5\u3002</p><p><code>superClass</code> \u4E00\u65E6\u8BBE\u7F6E\u5C31\u4F1A\u81EA\u52A8\u5FAA\u73AF\u5411\u540E\u67E5\u627E\u5168\u90E8\u7EE7\u627F\u7684\u7236\u7C7B\u4E2D\u662F\u5426\u6709\u8FD9\u4E2A\u65B9\u6CD5\uFF0C\u76F4\u5230\u67E5\u627E\u5230\u76EE\u6807\u6CA1\u6709\u7236\u7C7B(\u7EE7\u627F\u5173\u7CFB\u4E3A <code>java.lang.Object</code>)\u4E3A\u6B62\u3002</p><div class="custom-container tip"><p class="custom-container-title">\u5C0F\u63D0\u793A</p><p>\u66F4\u591A\u529F\u80FD\u8BF7\u53C2\u8003 <a href="../api/public/com/highcapable/yukireflection/finder/members/MethodFinder#superclass-method">MethodFinder.superClass</a>\u3001<a href="../api/public/com/highcapable/yukireflection/finder/members/ConstructorFinder#superclass-method">ConstructorFinder.superClass</a>\u3001<a href="../api/public/com/highcapable/yukireflection/finder/members/FieldFinder#superclass-method">FieldFinder.superClass</a> \u65B9\u6CD5\u3002</p></div><div class="custom-container danger"><p class="custom-container-title">\u7279\u522B\u6CE8\u610F</p><p>\u5F53\u524D\u67E5\u627E\u7684 <strong>Method</strong> \u9664\u975E\u6307\u5B9A <strong>superClass</strong> \u6761\u4EF6\uFF0C\u5426\u5219\u53EA\u80FD\u67E5\u627E\u5230\u5F53\u524D <strong>Class</strong> \u7684 <strong>Method</strong>\uFF0C\u8FD9\u662F Java \u53CD\u5C04 API \u7684\u9ED8\u8BA4\u884C\u4E3A\u3002</p></div><h3 id="\u6A21\u7CCA\u67E5\u627E-1" tabindex="-1"><a class="header-anchor" href="#\u6A21\u7CCA\u67E5\u627E-1" aria-hidden="true">#</a> \u6A21\u7CCA\u67E5\u627E</h3><p>\u5982\u679C\u6211\u4EEC\u60F3\u67E5\u627E\u4E00\u4E2A\u65B9\u6CD5\u540D\u79F0\uFF0C\u4F46\u662F\u53C8\u4E0D\u786E\u5B9A\u5B83\u5728\u6BCF\u4E2A\u7248\u672C\u4E2D\u662F\u5426\u53D1\u751F\u53D8\u5316\uFF0C\u6B64\u65F6\u6211\u4EEC\u5C31\u53EF\u4EE5\u4F7F\u7528\u6A21\u7CCA\u67E5\u627E\u529F\u80FD\u3002</p><p>\u5047\u8BBE\u6211\u4EEC\u8981\u5F97\u5230 <code>Class</code> \u4E2D\u7684 <code>doTask</code> \u65B9\u6CD5\uFF0C\u53EF\u4EE5\u4F7F\u7528\u5982\u4E0B\u5B9E\u73B0\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u4F7F\u7528 YukiReflection \u8C03\u7528\u5E76\u6267\u884C</span></span>
<span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// \u8BBE\u7F6E\u540D\u79F0\u4E0D\u533A\u5206\u5927\u5C0F\u5199</span></span>
<span class="line"><span style="color:#ADBAC7;">        it.equals(</span><span style="color:#96D0FF;">&quot;dotask&quot;</span><span style="color:#ADBAC7;">, isIgnoreCase </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">true</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">    param(</span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get(instance).call(</span><span style="color:#96D0FF;">&quot;task_name&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u5DF2\u77E5\u5F53\u524D <code>Class</code> \u4E2D\u4EC5\u6709\u4E00\u4E2A <code>doTask</code> \u65B9\u6CD5\uFF0C\u6211\u4EEC\u8FD8\u53EF\u4EE5\u5224\u65AD\u65B9\u6CD5\u540D\u79F0\u4EC5\u5305\u542B\u5176\u4E2D\u6307\u5B9A\u7684\u5B57\u7B26\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u4F7F\u7528 YukiReflection \u8C03\u7528\u5E76\u6267\u884C</span></span>
<span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// \u4EC5\u5305\u542B oTas</span></span>
<span class="line"><span style="color:#ADBAC7;">        it.contains(</span><span style="color:#96D0FF;">&quot;oTas&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">    param(</span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get(instance).call(</span><span style="color:#96D0FF;">&quot;task_name&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u6211\u4EEC\u8FD8\u53EF\u4EE5\u6839\u636E\u9996\u5C3E\u5B57\u7B26\u4E32\u8FDB\u884C\u5224\u65AD\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u4F7F\u7528 YukiReflection \u8C03\u7528\u5E76\u6267\u884C</span></span>
<span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// \u5F00\u5934\u5305\u542B do\uFF0C\u7ED3\u5C3E\u5305\u542B Task</span></span>
<span class="line"><span style="color:#ADBAC7;">        it.startsWith(</span><span style="color:#96D0FF;">&quot;do&quot;</span><span style="color:#ADBAC7;">) </span><span style="color:#F47067;">&amp;&amp;</span><span style="color:#ADBAC7;"> it.endsWith(</span><span style="color:#96D0FF;">&quot;Task&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">    param(</span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get(instance).call(</span><span style="color:#96D0FF;">&quot;task_name&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u901A\u8FC7\u89C2\u5BDF\u53D1\u73B0\u8FD9\u4E2A\u65B9\u6CD5\u540D\u79F0\u4E2D\u53EA\u5305\u542B\u5B57\u6BCD\uFF0C\u6211\u4EEC\u8FD8\u53EF\u4EE5\u518D\u589E\u52A0\u4E00\u4E2A\u7CBE\u786E\u7684\u67E5\u627E\u6761\u4EF6\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u4F7F\u7528 YukiReflection \u8C03\u7528\u5E76\u6267\u884C</span></span>
<span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// \u5F00\u5934\u5305\u542B do\uFF0C\u7ED3\u5C3E\u5305\u542B Task\uFF0C\u4EC5\u5305\u542B\u5B57\u6BCD</span></span>
<span class="line"><span style="color:#ADBAC7;">        it.startsWith(</span><span style="color:#96D0FF;">&quot;do&quot;</span><span style="color:#ADBAC7;">) </span><span style="color:#F47067;">&amp;&amp;</span><span style="color:#ADBAC7;"> it.endsWith(</span><span style="color:#96D0FF;">&quot;Task&quot;</span><span style="color:#ADBAC7;">) </span><span style="color:#F47067;">&amp;&amp;</span><span style="color:#ADBAC7;"> it.isOnlyLetters()</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">    param(</span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get(instance).call(</span><span style="color:#96D0FF;">&quot;task_name&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="custom-container tip"><p class="custom-container-title">\u5C0F\u63D0\u793A</p><p>\u4F7F\u7528 <strong>name { ... }</strong> \u521B\u5EFA\u4E00\u4E2A\u6761\u4EF6\u65B9\u6CD5\u4F53\uFF0C\u5176\u4E2D\u7684\u53D8\u91CF <strong>it</strong> \u5373\u5F53\u524D\u540D\u79F0\u7684\u5B57\u7B26\u4E32\uFF0C\u6B64\u65F6\u4F60\u5C31\u53EF\u4EE5\u5728 <strong>NameRules</strong> \u7684\u6269\u5C55\u65B9\u6CD5\u4E2D\u81EA\u7531\u4F7F\u7528\u5176\u4E2D\u7684\u529F\u80FD\u3002</p><p>\u65B9\u6CD5\u4F53\u672B\u5C3E\u6761\u4EF6\u9700\u8981\u8FD4\u56DE\u4E00\u4E2A <strong>Boolean</strong>\uFF0C\u5373\u6700\u7EC8\u7684\u6761\u4EF6\u5224\u65AD\u7ED3\u679C\u3002</p><p>\u66F4\u591A\u529F\u80FD\u8BF7\u53C2\u8003 <a href="../api/public/com/highcapable/yukireflection/finder/members/FieldFinder#name-method-1">FieldFinder.name</a>\u3001<a href="../api/public/com/highcapable/yukireflection/finder/members/MethodFinder#name-method-1">MethodFinder.name</a> \u65B9\u6CD5\u4EE5\u53CA <a href="../api/public/com/highcapable/yukireflection/finder/base/rules/NameRules">NameRules</a>\u3002</p></div><h3 id="\u591A\u91CD\u67E5\u627E-1" tabindex="-1"><a class="header-anchor" href="#\u591A\u91CD\u67E5\u627E-1" aria-hidden="true">#</a> \u591A\u91CD\u67E5\u627E</h3><p>\u6709\u4E9B\u65F6\u5019\uFF0C\u6211\u4EEC\u53EF\u80FD\u9700\u8981\u67E5\u627E\u4E00\u4E2A <code>Class</code> \u4E2D\u5177\u6709\u76F8\u540C\u7279\u5F81\u7684\u4E00\u7EC4\u65B9\u6CD5\u3001\u6784\u9020\u65B9\u6CD5\u3001\u53D8\u91CF\uFF0C\u6B64\u65F6\uFF0C\u6211\u4EEC\u5C31\u53EF\u4EE5\u5229\u7528\u76F8\u5BF9\u6761\u4EF6\u5339\u914D\u6765\u5B8C\u6210\u3002</p><p>\u5728\u67E5\u627E\u6761\u4EF6\u7ED3\u679C\u7684\u57FA\u7840\u4E0A\uFF0C\u6211\u4EEC\u53EA\u9700\u8981\u628A <code>get</code> \u6362\u4E3A <code>all</code> \u5373\u53EF\u5F97\u5230\u5339\u914D\u6761\u4EF6\u7684\u5168\u90E8\u5B57\u8282\u7801\u3002</p><p>\u5047\u8BBE\u8FD9\u6B21\u6211\u4EEC\u8981\u5F97\u5230 <code>Class</code> \u4E2D\u65B9\u6CD5\u53C2\u6570\u4E2A\u6570\u8303\u56F4\u5728 <code>1..3</code> \u7684\u5168\u90E8\u65B9\u6CD5\uFF0C\u53EF\u4EE5\u4F7F\u7528\u5982\u4E0B\u5B9E\u73B0\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u4F7F\u7528 YukiReflection \u8C03\u7528\u5E76\u6267\u884C</span></span>
<span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    paramCount(</span><span style="color:#6CB6FF;">1</span><span style="color:#ADBAC7;">..</span><span style="color:#6CB6FF;">3</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">}.all(instance).forEach { instance </span><span style="color:#F47067;">-&gt;</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u8C03\u7528\u6267\u884C\u6BCF\u4E2A\u65B9\u6CD5</span></span>
<span class="line"><span style="color:#ADBAC7;">    instance.call(...)</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u4E0A\u8FF0\u793A\u4F8B\u53EF\u5B8C\u7F8E\u5339\u914D\u5230\u5982\u4E0B 3 \u4E2A\u65B9\u6CD5\u3002</p><p><code>private void doTask(String taskName)</code></p><p><code>private void release(String taskName, Function&lt;boolean, String&gt; task, boolean isFinish)</code></p><p><code>private void b(String a)</code></p><p>\u5982\u679C\u4F60\u60F3\u66F4\u52A0\u81EA\u7531\u5730\u5B9A\u4E49\u53C2\u6570\u4E2A\u6570\u8303\u56F4\u7684\u6761\u4EF6\uFF0C\u53EF\u4EE5\u4F7F\u7528\u5982\u4E0B\u5B9E\u73B0\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u4F7F\u7528 YukiReflection \u8C03\u7528\u5E76\u6267\u884C</span></span>
<span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    paramCount { it </span><span style="color:#F47067;">&lt;</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">3</span><span style="color:#ADBAC7;"> }</span></span>
<span class="line"><span style="color:#ADBAC7;">}.all(instance).forEach { instance </span><span style="color:#F47067;">-&gt;</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u8C03\u7528\u6267\u884C\u6BCF\u4E2A\u65B9\u6CD5</span></span>
<span class="line"><span style="color:#ADBAC7;">    instance.call(...)</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u4E0A\u8FF0\u793A\u4F8B\u53EF\u5B8C\u7F8E\u5339\u914D\u5230\u5982\u4E0B 6 \u4E2A\u65B9\u6CD5\u3002</p><p><code>private static void init()</code></p><p><code>private void doTask(String taskName)</code></p><p><code>private void stop(String a)</code></p><p><code>private void getName(String a)</code></p><p><code>private void b()</code></p><p><code>private void b(String a)</code></p><p>\u901A\u8FC7\u89C2\u5BDF <code>Class</code> \u4E2D\u6709\u4E24\u4E2A\u540D\u79F0\u4E3A <code>b</code> \u7684\u65B9\u6CD5\uFF0C\u53EF\u4EE5\u4F7F\u7528\u5982\u4E0B\u5B9E\u73B0\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u4F7F\u7528 YukiReflection \u8C03\u7528\u5E76\u6267\u884C</span></span>
<span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;b&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">}.all(instance).forEach { instance </span><span style="color:#F47067;">-&gt;</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u8C03\u7528\u6267\u884C\u6BCF\u4E2A\u65B9\u6CD5</span></span>
<span class="line"><span style="color:#ADBAC7;">    instance.call(...)</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u4E0A\u8FF0\u793A\u4F8B\u53EF\u5B8C\u7F8E\u5339\u914D\u5230\u5982\u4E0B 2 \u4E2A\u65B9\u6CD5\u3002</p><p><code>private void b()</code></p><p><code>private void b(String a)</code></p><div class="custom-container tip"><p class="custom-container-title">\u5C0F\u63D0\u793A</p><p>\u4F7F\u7528 <strong>paramCount { ... }</strong> \u521B\u5EFA\u4E00\u4E2A\u6761\u4EF6\u65B9\u6CD5\u4F53\uFF0C\u5176\u4E2D\u7684\u53D8\u91CF <strong>it</strong> \u5373\u5F53\u524D\u53C2\u6570\u4E2A\u6570\u7684\u6574\u6570\uFF0C\u6B64\u65F6\u4F60\u5C31\u53EF\u4EE5\u5728 <strong>CountRules</strong> \u7684\u6269\u5C55\u65B9\u6CD5\u4E2D\u81EA\u7531\u4F7F\u7528\u5176\u4E2D\u7684\u529F\u80FD\u3002</p><p>\u65B9\u6CD5\u4F53\u672B\u5C3E\u6761\u4EF6\u9700\u8981\u8FD4\u56DE\u4E00\u4E2A <strong>Boolean</strong>\uFF0C\u5373\u6700\u7EC8\u7684\u6761\u4EF6\u5224\u65AD\u7ED3\u679C\u3002</p><p>\u66F4\u591A\u529F\u80FD\u8BF7\u53C2\u8003 <a href="../api/public/com/highcapable/yukireflection/finder/members/MethodFinder#paramcount-method-2">MethodFinder.paramCount</a>\u3001<a href="../api/public/com/highcapable/yukireflection/finder/members/ConstructorFinder#paramcount-method-2">ConstructorFinder.paramCount</a> \u65B9\u6CD5\u4EE5\u53CA <a href="../api/public/com/highcapable/yukireflection/finder/base/rules/CountRules">CountRules</a>\u3002</p></div><h3 id="\u9759\u6001\u5B57\u8282\u7801" tabindex="-1"><a class="header-anchor" href="#\u9759\u6001\u5B57\u8282\u7801" aria-hidden="true">#</a> \u9759\u6001\u5B57\u8282\u7801</h3><p>\u6709\u4E9B\u65B9\u6CD5\u548C\u53D8\u91CF\u5728 <code>Class</code> \u4E2D\u662F\u9759\u6001\u7684\u5B9E\u73B0\uFF0C\u8FD9\u4E2A\u65F6\u5019\uFF0C\u6211\u4EEC\u4E0D\u9700\u8981\u4F20\u5165\u5B9E\u4F8B\u5C31\u53EF\u4EE5\u8C03\u7528\u5B83\u4EEC\u3002</p><p>\u5047\u8BBE\u6211\u4EEC\u8FD9\u6B21\u8981\u5F97\u5230\u9759\u6001\u53D8\u91CF <code>TAG</code> \u7684\u5185\u5BB9\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.field {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;TAG&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    type </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">StringClass</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get().string() </span><span style="color:#768390;">// Field \u7684\u7C7B\u578B\u662F\u5B57\u7B26\u4E32\uFF0C\u53EF\u76F4\u63A5\u8FDB\u884C cast</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u5047\u8BBE <code>Class</code> \u4E2D\u5B58\u5728\u540C\u540D\u7684\u975E\u9759\u6001 <code>TAG</code> \u53D8\u91CF\uFF0C\u8FD9\u4E2A\u65F6\u5019\u600E\u4E48\u529E\u5462\uFF1F</p><p>\u52A0\u5165\u4E00\u4E2A\u7B5B\u9009\u6761\u4EF6\u5373\u53EF\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.field {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;TAG&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    type </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">StringClass</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u6807\u8BC6\u67E5\u627E\u7684\u8FD9\u4E2A\u53D8\u91CF\u9700\u8981\u662F\u9759\u6001</span></span>
<span class="line"><span style="color:#ADBAC7;">    modifiers { isStatic }</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get().string() </span><span style="color:#768390;">// Field \u7684\u7C7B\u578B\u662F\u5B57\u7B26\u4E32\uFF0C\u53EF\u76F4\u63A5\u8FDB\u884C cast</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u6211\u4EEC\u8FD8\u53EF\u4EE5\u8C03\u7528\u540D\u4E3A <code>init</code> \u7684\u9759\u6001\u65B9\u6CD5\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;init&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    emptyParam()</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get().call()</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u540C\u6837\u5730\uFF0C\u4F60\u53EF\u4EE5\u6807\u8BC6\u5B83\u662F\u4E00\u4E2A\u9759\u6001\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;init&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    emptyParam()</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u6807\u8BC6\u67E5\u627E\u7684\u8FD9\u4E2A\u65B9\u6CD5\u9700\u8981\u662F\u9759\u6001</span></span>
<span class="line"><span style="color:#ADBAC7;">    modifiers { isStatic }</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get().call()</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="custom-container tip"><p class="custom-container-title">\u5C0F\u63D0\u793A</p><p>\u4F7F\u7528 <strong>modifiers { ... }</strong> \u521B\u5EFA\u4E00\u4E2A\u6761\u4EF6\u65B9\u6CD5\u4F53\uFF0C\u6B64\u65F6\u4F60\u5C31\u53EF\u4EE5\u5728 <strong>ModifierRules</strong> \u4E2D\u81EA\u7531\u4F7F\u7528\u5176\u4E2D\u7684\u529F\u80FD\u3002</p><p>\u65B9\u6CD5\u4F53\u672B\u5C3E\u6761\u4EF6\u9700\u8981\u8FD4\u56DE\u4E00\u4E2A <strong>Boolean</strong>\uFF0C\u5373\u6700\u7EC8\u7684\u6761\u4EF6\u5224\u65AD\u7ED3\u679C\u3002</p><p>\u66F4\u591A\u529F\u80FD\u8BF7\u53C2\u8003 <a href="../api/public/com/highcapable/yukireflection/finder/members/FieldFinder#modifiers-method">FieldFinder.modifiers</a>\u3001<a href="../api/public/com/highcapable/yukireflection/finder/members/MethodFinder#modifiers-method">MethodFinder.modifiers</a>\u3001<a href="../api/public/com/highcapable/yukireflection/finder/members/ConstructorFinder#modifiers-method">ConstructorFinder.modifiers</a> \u65B9\u6CD5\u4EE5\u53CA <a href="../api/public/com/highcapable/yukireflection/finder/base/rules/ModifierRules">ModifierRules</a>\u3002</p></div><h3 id="\u6DF7\u6DC6\u7684\u5B57\u8282\u7801" tabindex="-1"><a class="header-anchor" href="#\u6DF7\u6DC6\u7684\u5B57\u8282\u7801" aria-hidden="true">#</a> \u6DF7\u6DC6\u7684\u5B57\u8282\u7801</h3><p>\u4F60\u53EF\u80FD\u5DF2\u7ECF\u6CE8\u610F\u5230\u4E86\uFF0C\u8FD9\u91CC\u7ED9\u51FA\u7684\u793A\u4F8B <code>Class</code> \u4E2D\u6709\u4E24\u4E2A\u6DF7\u6DC6\u7684\u53D8\u91CF\u540D\u79F0\uFF0C\u5B83\u4EEC\u90FD\u662F <code>a</code>\uFF0C\u8FD9\u4E2A\u65F6\u5019\u6211\u4EEC\u8981\u600E\u4E48\u5F97\u5230\u5B83\u4EEC\u5462\uFF1F</p><p>\u6709\u4E24\u79CD\u65B9\u6848\u3002</p><p>\u7B2C\u4E00\u79CD\u65B9\u6848\uFF0C\u786E\u5B9A\u53D8\u91CF\u7684\u540D\u79F0\u548C\u7C7B\u578B\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u4F7F\u7528 YukiReflection \u8C03\u7528\u5E76\u6267\u884C</span></span>
<span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.field {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;a&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    type </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">BooleanType</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get(instance).any() </span><span style="color:#768390;">// \u5F97\u5230\u540D\u79F0\u4E3A a \u7C7B\u578B\u4E3A Boolean \u7684\u53D8\u91CF</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u7B2C\u4E8C\u79CD\u65B9\u6848\uFF0C\u786E\u5B9A\u53D8\u91CF\u7684\u7C7B\u578B\u6240\u5728\u7684\u4F4D\u7F6E\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u4F7F\u7528 YukiReflection \u8C03\u7528\u5E76\u6267\u884C</span></span>
<span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.field {</span></span>
<span class="line"><span style="color:#ADBAC7;">    type(</span><span style="color:#F69D50;">BooleanType</span><span style="color:#ADBAC7;">).index().first()</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get(instance).any() </span><span style="color:#768390;">// \u5F97\u5230\u7B2C\u4E00\u4E2A\u7C7B\u578B\u4E3A Boolean \u7684\u53D8\u91CF</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u4EE5\u4E0A\u4E24\u79CD\u60C5\u51B5\u5747\u53EF\u5F97\u5230\u5BF9\u5E94\u7684\u53D8\u91CF <code>private boolean a</code>\u3002</p><p>\u540C\u6837\u5730\uFF0C\u8FD9\u4E2A <code>Class</code> \u4E2D\u4E5F\u6709\u4E24\u4E2A\u6DF7\u6DC6\u7684\u65B9\u6CD5\u540D\u79F0\uFF0C\u5B83\u4EEC\u90FD\u662F <code>b</code>\u3002</p><p>\u4F60\u4E5F\u53EF\u4EE5\u6709\u4E24\u79CD\u65B9\u6848\u6765\u5F97\u5230\u5B83\u4EEC\u3002</p><p>\u7B2C\u4E00\u79CD\u65B9\u6848\uFF0C\u786E\u5B9A\u65B9\u6CD5\u7684\u540D\u79F0\u548C\u65B9\u6CD5\u53C2\u6570\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u4F7F\u7528 YukiReflection \u8C03\u7528\u5E76\u6267\u884C</span></span>
<span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;b&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    param(</span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get(instance).call(</span><span style="color:#96D0FF;">&quot;test_string&quot;</span><span style="color:#ADBAC7;">) </span><span style="color:#768390;">// \u5F97\u5230\u540D\u79F0\u4E3A b \u65B9\u6CD5\u53C2\u6570\u4E3A [String] \u7684\u65B9\u6CD5</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u7B2C\u4E8C\u79CD\u65B9\u6848\uFF0C\u786E\u5B9A\u65B9\u6CD5\u7684\u53C2\u6570\u6240\u5728\u7684\u4F4D\u7F6E\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u4F7F\u7528 YukiReflection \u8C03\u7528\u5E76\u6267\u884C</span></span>
<span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    param(</span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;">).index().first()</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get(instance).call(</span><span style="color:#96D0FF;">&quot;test_string&quot;</span><span style="color:#ADBAC7;">) </span><span style="color:#768390;">// \u5F97\u5230\u7B2C\u4E00\u4E2A\u65B9\u6CD5\u53C2\u6570\u4E3A [String] \u7684\u65B9\u6CD5</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u7531\u4E8E\u89C2\u5BDF\u5230\u8FD9\u4E2A\u65B9\u6CD5\u5728 <code>Class</code> \u7684\u6700\u540E\u4E00\u4E2A\uFF0C\u90A3\u6211\u4EEC\u8FD8\u6709\u4E00\u4E2A\u5907\u9009\u65B9\u6848\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u4F7F\u7528 YukiReflection \u8C03\u7528\u5E76\u6267\u884C</span></span>
<span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    order().index().last()</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get(instance).call(</span><span style="color:#96D0FF;">&quot;test_string&quot;</span><span style="color:#ADBAC7;">) </span><span style="color:#768390;">// \u5F97\u5230\u5F53\u524D Class \u7684\u6700\u540E\u4E00\u4E2A\u65B9\u6CD5</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="custom-container warning"><p class="custom-container-title">\u6CE8\u610F</p><p>\u8BF7\u5C3D\u91CF\u907F\u514D\u4F7F\u7528 <strong>order</strong> \u6765\u7B5B\u9009\u5B57\u8282\u7801\u7684\u4E0B\u6807\uFF0C\u5B83\u4EEC\u53EF\u80FD\u662F\u4E0D\u786E\u5B9A\u7684\uFF0C\u9664\u975E\u4F60\u786E\u5B9A\u5B83\u5728\u8FD9\u4E2A <strong>Class</strong> \u4E2D\u7684\u4F4D\u7F6E\u4E00\u5B9A\u4E0D\u4F1A\u53D8\u3002</p></div><h3 id="\u76F4\u63A5\u8C03\u7528" tabindex="-1"><a class="header-anchor" href="#\u76F4\u63A5\u8C03\u7528" aria-hidden="true">#</a> \u76F4\u63A5\u8C03\u7528</h3><p>\u4E0A\u9762\u4ECB\u7ECD\u7684\u8C03\u7528\u5B57\u8282\u7801\u7684\u65B9\u6CD5\u90FD\u9700\u8981\u4F7F\u7528 <code>get(instance)</code> \u624D\u80FD\u8C03\u7528\u5BF9\u5E94\u7684\u65B9\u6CD5\uFF0C\u6709\u6CA1\u6709\u7B80\u5355\u4E00\u70B9\u7684\u529E\u6CD5\u5462\uFF1F</p><p>\u6B64\u65F6\uFF0C\u4F60\u53EF\u4EE5\u5728\u4EFB\u610F\u5B9E\u4F8B\u4E0A\u4F7F\u7528 <code>current</code> \u65B9\u6CD5\u6765\u521B\u5EFA\u4E00\u4E2A\u8C03\u7528\u7A7A\u95F4\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u4E2A Class \u662F\u4E0D\u80FD\u88AB\u76F4\u63A5\u5F97\u5230\u7684</span></span>
<span class="line"><span style="color:#ADBAC7;">instance.current {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u6267\u884C doTask \u65B9\u6CD5</span></span>
<span class="line"><span style="color:#ADBAC7;">    method {</span></span>
<span class="line"><span style="color:#ADBAC7;">        name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;doTask&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">        param(</span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    }.call(</span><span style="color:#96D0FF;">&quot;task_name&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u6267\u884C stop \u65B9\u6CD5</span></span>
<span class="line"><span style="color:#ADBAC7;">    method {</span></span>
<span class="line"><span style="color:#ADBAC7;">        name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;stop&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">        emptyParam()</span></span>
<span class="line"><span style="color:#ADBAC7;">    }.call()</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u5F97\u5230 name</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> method { name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;getName&quot;</span><span style="color:#ADBAC7;"> }.string()</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u6211\u4EEC\u8FD8\u53EF\u4EE5\u7528 <code>superClass</code> \u8C03\u7528\u5F53\u524D <code>Class</code> \u7236\u7C7B\u7684\u65B9\u6CD5\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u4E2A Class \u662F\u4E0D\u80FD\u88AB\u76F4\u63A5\u5F97\u5230\u7684</span></span>
<span class="line"><span style="color:#ADBAC7;">instance.current {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u6267\u884C\u7236\u7C7B\u7684 doBaseTask \u65B9\u6CD5</span></span>
<span class="line"><span style="color:#ADBAC7;">    superClass().method {</span></span>
<span class="line"><span style="color:#ADBAC7;">        name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;doBaseTask&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">        param(</span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    }.call(</span><span style="color:#96D0FF;">&quot;task_name&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u5982\u679C\u4F60\u4E0D\u559C\u6B22\u4F7F\u7528\u4E00\u4E2A\u5927\u62EC\u53F7\u7684\u8C03\u7528\u57DF\u6765\u521B\u5EFA\u5F53\u524D\u5B9E\u4F8B\u7684\u547D\u540D\u7A7A\u95F4\uFF0C\u4F60\u53EF\u4EE5\u76F4\u63A5\u4F7F\u7528 <code>current()</code> \u65B9\u6CD5\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B\uFF0C\u8FD9\u4E2A Class \u662F\u4E0D\u80FD\u88AB\u76F4\u63A5\u5F97\u5230\u7684</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u6267\u884C doTask \u65B9\u6CD5</span></span>
<span class="line"><span style="color:#ADBAC7;">instance</span></span>
<span class="line"><span style="color:#ADBAC7;">    .current()</span></span>
<span class="line"><span style="color:#ADBAC7;">    .method {</span></span>
<span class="line"><span style="color:#ADBAC7;">        name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;doTask&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">        param(</span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    }.call(</span><span style="color:#96D0FF;">&quot;task_name&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#768390;">// \u6267\u884C stop \u65B9\u6CD5</span></span>
<span class="line"><span style="color:#ADBAC7;">instance</span></span>
<span class="line"><span style="color:#ADBAC7;">    .current()</span></span>
<span class="line"><span style="color:#ADBAC7;">    .method {</span></span>
<span class="line"><span style="color:#ADBAC7;">        name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;stop&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">        emptyParam()</span></span>
<span class="line"><span style="color:#ADBAC7;">    }.call()</span></span>
<span class="line"><span style="color:#768390;">// \u5F97\u5230 name</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> instance.current().method { name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;getName&quot;</span><span style="color:#ADBAC7;"> }.string()</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u540C\u6837\u5730\uFF0C\u5B83\u4EEC\u4E4B\u95F4\u53EF\u4EE5\u8FDE\u7EED\u8C03\u7528\uFF0C\u4F46<u><strong>\u4E0D\u5141\u8BB8\u5185\u8054\u8C03\u7528</strong></u>\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u4E2A Class \u662F\u4E0D\u80FD\u88AB\u76F4\u63A5\u5F97\u5230\u7684</span></span>
<span class="line"><span style="color:#ADBAC7;">instance.current {</span></span>
<span class="line"><span style="color:#ADBAC7;">    method {</span></span>
<span class="line"><span style="color:#ADBAC7;">        name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;doTask&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">        param(</span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    }.call(</span><span style="color:#96D0FF;">&quot;task_name&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">}.current()</span></span>
<span class="line"><span style="color:#ADBAC7;">    .method {</span></span>
<span class="line"><span style="color:#ADBAC7;">        name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;stop&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">        emptyParam()</span></span>
<span class="line"><span style="color:#ADBAC7;">    }.call()</span></span>
<span class="line"><span style="color:#768390;">// \u2757\u6CE8\u610F\uFF0C\u56E0\u4E3A current() \u8FD4\u56DE\u7684\u662F CurrentClass \u81EA\u8EAB\u5BF9\u8C61\uFF0C\u6240\u4EE5\u4E0D\u80FD\u50CF\u4E0B\u9762\u8FD9\u6837\u8C03\u7528</span></span>
<span class="line"><span style="color:#ADBAC7;">instance.current().current()</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u9488\u5BF9 <code>Field</code> \u5B9E\u4F8B\uFF0C\u8FD8\u6709\u4E00\u4E2A\u4FBF\u6377\u7684\u65B9\u6CD5\uFF0C\u53EF\u4EE5\u76F4\u63A5\u83B7\u53D6 <code>Field</code> \u6240\u5728\u5B9E\u4F8B\u7684\u5BF9\u8C61\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u4E2A Class \u662F\u4E0D\u80FD\u88AB\u76F4\u63A5\u5F97\u5230\u7684</span></span>
<span class="line"><span style="color:#ADBAC7;">instance.current {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// &lt;\u65B9\u68481&gt;</span></span>
<span class="line"><span style="color:#ADBAC7;">    field {</span></span>
<span class="line"><span style="color:#ADBAC7;">        name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;baseInstance&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    }.current {</span></span>
<span class="line"><span style="color:#ADBAC7;">        method {</span></span>
<span class="line"><span style="color:#ADBAC7;">            name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;doBaseTask&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">            param(</span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">        }.call(</span><span style="color:#96D0FF;">&quot;task_name&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// &lt;\u65B9\u68482&gt;</span></span>
<span class="line"><span style="color:#ADBAC7;">    field {</span></span>
<span class="line"><span style="color:#ADBAC7;">        name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;baseInstance&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    }.current()</span></span>
<span class="line"><span style="color:#ADBAC7;">        ?.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">            name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;doBaseTask&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">            param(</span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">        }?.call(</span><span style="color:#96D0FF;">&quot;task_name&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="custom-container warning"><p class="custom-container-title">\u6CE8\u610F</p><p>\u4E0A\u8FF0 <strong>current</strong> \u65B9\u6CD5\u76F8\u5F53\u4E8E\u5E2E\u4F60\u8C03\u7528\u4E86 <strong>CurrentClass</strong> \u4E2D\u7684 <strong>field { ... }.any()?.current()</strong> \u65B9\u6CD5\u3002</p><p>\u82E5\u4E0D\u5B58\u5728 <strong>CurrentClass</strong> \u8C03\u7528\u57DF\uFF0C\u4F60\u9700\u8981\u4F7F\u7528 <strong>field { ... }.get(instance).current()</strong> \u6765\u8FDB\u884C\u8C03\u7528\u3002</p></div><p>\u95EE\u9898\u53C8\u6765\u4E86\uFF0C\u6211\u60F3\u4F7F\u7528\u53CD\u5C04\u7684\u65B9\u5F0F\u521B\u5EFA\u5982\u4E0B\u7684\u5B9E\u4F8B\u5E76\u8C03\u7528\u5176\u4E2D\u7684\u65B9\u6CD5\uFF0C\u8BE5\u600E\u4E48\u505A\u5462\uFF1F</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">(</span><span style="color:#6CB6FF;">true</span><span style="color:#ADBAC7;">).doTask(</span><span style="color:#96D0FF;">&quot;task_name&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>\u901A\u5E38\u60C5\u51B5\u4E0B\uFF0C\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528\u6807\u51C6\u7684\u53CD\u5C04 API \u6765\u8C03\u7528\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#96D0FF;">&quot;com.demo.Test&quot;</span><span style="color:#ADBAC7;">.toClass()</span></span>
<span class="line"><span style="color:#ADBAC7;">    .getDeclaredConstructor(Boolean::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java)</span></span>
<span class="line"><span style="color:#ADBAC7;">    .</span><span style="color:#6CB6FF;">apply</span><span style="color:#ADBAC7;"> { isAccessible </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">true</span><span style="color:#ADBAC7;"> }</span></span>
<span class="line"><span style="color:#ADBAC7;">    .newInstance(</span><span style="color:#6CB6FF;">true</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    .</span><span style="color:#6CB6FF;">apply</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"><span style="color:#ADBAC7;">        javaClass</span></span>
<span class="line"><span style="color:#ADBAC7;">            .getDeclaredMethod(</span><span style="color:#96D0FF;">&quot;doTask&quot;</span><span style="color:#ADBAC7;">, String::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java)</span></span>
<span class="line"><span style="color:#ADBAC7;">            .</span><span style="color:#6CB6FF;">apply</span><span style="color:#ADBAC7;"> { isAccessible </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">true</span><span style="color:#ADBAC7;"> }</span></span>
<span class="line"><span style="color:#ADBAC7;">            .invoke(</span><span style="color:#6CB6FF;">this</span><span style="color:#ADBAC7;">, </span><span style="color:#96D0FF;">&quot;task_name&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u4F46\u662F\u611F\u89C9\u8FD9\u79CD\u505A\u6CD5\u597D\u9EBB\u70E6\uFF0C\u6709\u6CA1\u6709\u66F4\u7B80\u6D01\u7684\u8C03\u7528\u65B9\u6CD5\u5462\uFF1F</p><p>\u8FD9\u4E2A\u65F6\u5019\uFF0C\u6211\u4EEC\u8FD8\u53EF\u4EE5\u501F\u52A9 <code>buildOf</code> \u65B9\u6CD5\u6765\u521B\u5EFA\u4E00\u4E2A\u5B9E\u4F8B\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#96D0FF;">&quot;com.demo.Test&quot;</span><span style="color:#ADBAC7;">.toClass().buildOf(</span><span style="color:#6CB6FF;">true</span><span style="color:#ADBAC7;">) { param(</span><span style="color:#F69D50;">BooleanType</span><span style="color:#ADBAC7;">) }?.current {</span></span>
<span class="line"><span style="color:#ADBAC7;">    method {</span></span>
<span class="line"><span style="color:#ADBAC7;">        name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;doTask&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">        param(</span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    }.call(</span><span style="color:#96D0FF;">&quot;task_name&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u82E5\u4F60\u5E0C\u671B <code>buildOf</code> \u65B9\u6CD5\u8FD4\u56DE\u5F53\u524D\u5B9E\u4F8B\u7684\u7C7B\u578B\uFF0C\u4F60\u53EF\u4EE5\u5728\u5176\u4E2D\u52A0\u5165\u7C7B\u578B\u6CDB\u578B\u58F0\u660E\uFF0C\u800C\u65E0\u9700\u4F7F\u7528 <code>as</code> \u6765 <code>cast</code> \u76EE\u6807\u7C7B\u578B\u3002</p><p>\u8FD9\u79CD\u60C5\u51B5\u591A\u7528\u4E8E\u5B9E\u4F8B\u672C\u8EAB\u7684\u6784\u9020\u65B9\u6CD5\u662F\u79C1\u6709\u7684\uFF0C\u4F46\u662F\u91CC\u9762\u7684\u65B9\u6CD5\u662F\u516C\u6709\u7684\uFF0C\u8FD9\u6837\u6211\u4EEC\u53EA\u9700\u8981\u5BF9\u5176\u6784\u9020\u65B9\u6CD5\u8FDB\u884C\u53CD\u5C04\u521B\u5EFA\u5373\u53EF\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u4E2A Class \u662F\u80FD\u591F\u76F4\u63A5\u88AB\u5F97\u5230\u7684</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> test </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.buildOf</span><span style="color:#F47067;">&lt;</span><span style="color:#F69D50;">Test</span><span style="color:#F47067;">&gt;</span><span style="color:#ADBAC7;">(</span><span style="color:#6CB6FF;">true</span><span style="color:#ADBAC7;">) { param(</span><span style="color:#F69D50;">BooleanType</span><span style="color:#ADBAC7;">) }</span></span>
<span class="line"><span style="color:#ADBAC7;">test.doTask(</span><span style="color:#96D0FF;">&quot;task_name&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="custom-container tip"><p class="custom-container-title">\u5C0F\u63D0\u793A</p><p>\u66F4\u591A\u529F\u80FD\u8BF7\u53C2\u8003 <a href="../api/public/com/highcapable/yukireflection/bean/CurrentClass">CurrentClass</a> \u4EE5\u53CA <a href="../api/public/com/highcapable/yukireflection/factory/ReflectionFactory#class-buildof-ext-method">Class.buildOf</a> \u65B9\u6CD5\u3002</p></div><h3 id="\u518D\u6B21\u67E5\u627E" tabindex="-1"><a class="header-anchor" href="#\u518D\u6B21\u67E5\u627E" aria-hidden="true">#</a> \u518D\u6B21\u67E5\u627E</h3><p>\u5047\u8BBE\u6709\u4E09\u4E2A\u4E0D\u540C\u7248\u672C\u7684 <code>Class</code>\uFF0C\u5B83\u4EEC\u90FD\u662F\u8FD9\u4E2A APP \u4E0D\u540C\u7248\u672C\u76F8\u540C\u7684 <code>Class</code>\u3002</p><p>\u8FD9\u91CC\u9762\u540C\u6837\u90FD\u6709\u4E00\u4E2A\u65B9\u6CD5 <code>doTask</code>\uFF0C\u5047\u8BBE\u5B83\u4EEC\u7684\u529F\u80FD\u662F\u4E00\u6837\u7684\u3002</p><blockquote><p>\u7248\u672C A \u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-java ext-java"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">class</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">void</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">doTask</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre></div><blockquote><p>\u7248\u672C B \u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-java ext-java"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">class</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">void</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">doTask</span><span style="color:#ADBAC7;">(String </span><span style="color:#F69D50;">taskName</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre></div><blockquote><p>\u7248\u672C C \u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-java ext-java"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">class</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">void</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">doTask</span><span style="color:#ADBAC7;">(String </span><span style="color:#F69D50;">taskName</span><span style="color:#ADBAC7;">, </span><span style="color:#F47067;">int</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">type</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre></div><p>\u6211\u4EEC\u9700\u8981\u5728\u4E0D\u540C\u7684\u7248\u672C\u4E2D\u5F97\u5230\u8FD9\u4E2A\u76F8\u540C\u529F\u80FD\u7684 <code>doTask</code> \u65B9\u6CD5\uFF0C\u8981\u600E\u4E48\u505A\u5462\uFF1F</p><p>\u6B64\u65F6\uFF0C\u4F60\u53EF\u4EE5\u4F7F\u7528 <code>RemedyPlan</code> \u5B8C\u6210\u4F60\u7684\u9700\u6C42\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u4F7F\u7528 YukiReflection \u8C03\u7528\u5E76\u6267\u884C</span></span>
<span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;doTask&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    emptyParam()</span></span>
<span class="line"><span style="color:#ADBAC7;">}.remedys {</span></span>
<span class="line"><span style="color:#ADBAC7;">    method {</span></span>
<span class="line"><span style="color:#ADBAC7;">        name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;doTask&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">        param(</span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    }.onFind {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// \u53EF\u5728\u8FD9\u91CC\u5B9E\u73B0\u627E\u5230\u7684\u903B\u8F91</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">    method {</span></span>
<span class="line"><span style="color:#ADBAC7;">        name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;doTask&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">        param(</span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;">, </span><span style="color:#F69D50;">IntType</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    }.onFind {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// \u53EF\u5728\u8FD9\u91CC\u5B9E\u73B0\u627E\u5230\u7684\u903B\u8F91</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}.wait(instance) {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u5F97\u5230\u65B9\u6CD5\u7684\u7ED3\u679C</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="custom-container danger"><p class="custom-container-title">\u7279\u522B\u6CE8\u610F</p><p>\u4F7F\u7528\u4E86 <strong>RemedyPlan</strong> \u7684\u65B9\u6CD5\u67E5\u627E\u7ED3\u679C\u4E0D\u80FD\u518D\u4F7F\u7528 <strong>get</strong> \u7684\u65B9\u5F0F\u5F97\u5230\u65B9\u6CD5\u5B9E\u4F8B\uFF0C\u5E94\u5F53\u4F7F\u7528 <strong>wait</strong> \u65B9\u6CD5\u3002</p></div><p>\u53E6\u5916\uFF0C\u4F60\u8FD8\u53EF\u4EE5\u5728\u4F7F\u7528 <a href="#%E5%A4%9A%E9%87%8D%E6%9F%A5%E6%89%BE">\u591A\u91CD\u67E5\u627E</a> \u7684\u60C5\u51B5\u4E0B\u7EE7\u7EED\u4F7F\u7528 <code>RemedyPlan</code>\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u5C31\u662F\u8FD9\u4E2A Class \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> instance </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"><span style="color:#768390;">// \u4F7F\u7528 YukiReflection \u8C03\u7528\u5E76\u6267\u884C</span></span>
<span class="line"><span style="color:#F69D50;">Test</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;doTask&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    emptyParam()</span></span>
<span class="line"><span style="color:#ADBAC7;">}.remedys {</span></span>
<span class="line"><span style="color:#ADBAC7;">    method {</span></span>
<span class="line"><span style="color:#ADBAC7;">        name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;doTask&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">        paramCount(</span><span style="color:#6CB6FF;">0</span><span style="color:#ADBAC7;">..</span><span style="color:#6CB6FF;">1</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    }.onFind {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// \u53EF\u5728\u8FD9\u91CC\u5B9E\u73B0\u627E\u5230\u7684\u903B\u8F91</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">    method {</span></span>
<span class="line"><span style="color:#ADBAC7;">        name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;doTask&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">        paramCount(</span><span style="color:#6CB6FF;">1</span><span style="color:#ADBAC7;">..</span><span style="color:#6CB6FF;">2</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    }.onFind {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// \u53EF\u5728\u8FD9\u91CC\u5B9E\u73B0\u627E\u5230\u7684\u903B\u8F91</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}.waitAll(instance) {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u5F97\u5230\u65B9\u6CD5\u7684\u7ED3\u679C</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="custom-container tip"><p class="custom-container-title">\u5C0F\u63D0\u793A</p><p>\u66F4\u591A\u529F\u80FD\u8BF7\u53C2\u8003 <a href="../api/public/com/highcapable/yukireflection/finder/members/MethodFinder#remedyplan-class">MethodFinder.RemedyPlan</a>\u3001<a href="../api/public/com/highcapable/yukireflection/finder/members/ConstructorFinder#remedyplan-class">ConstructorFinder.RemedyPlan</a>\u3001<a href="../api/public/com/highcapable/yukireflection/finder/members/FieldFinder#remedyplan-class">FieldFinder.RemedyPlan</a>\u3002</p></div><h3 id="\u76F8\u5BF9\u5339\u914D" tabindex="-1"><a class="header-anchor" href="#\u76F8\u5BF9\u5339\u914D" aria-hidden="true">#</a> \u76F8\u5BF9\u5339\u914D</h3><p>\u5047\u8BBE\u5F53\u524D APP \u4E2D\u4E0D\u540C\u7248\u672C\u4E2D\u5B58\u5728\u529F\u80FD\u76F8\u540C\u7684 <code>Class</code> \u4F46\u4EC5\u6709 <code>Class</code> \u7684\u540D\u79F0\u4E0D\u4E00\u6837\u3002</p><blockquote><p>\u7248\u672C A \u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-java ext-java"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">class</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">ATest</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">static</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">void</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">doTask</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre></div><blockquote><p>\u7248\u672C B \u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-java ext-java"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">class</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">BTest</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">static</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">void</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">doTask</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre></div><p>\u8FD9\u4E2A\u65F6\u5019\u6211\u4EEC\u60F3\u5728\u6BCF\u4E2A\u7248\u672C\u90FD\u8C03\u7528\u8FD9\u4E2A <code>Class</code> \u91CC\u7684 <code>doTask</code> \u65B9\u6CD5\u8BE5\u600E\u4E48\u505A\u5462\uFF1F</p><p>\u901A\u5E38\u505A\u6CD5\u662F\u5224\u65AD <code>Class</code> \u662F\u5426\u5B58\u5728\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u9996\u5148\u67E5\u627E\u5230\u8FD9\u4E2A Class</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> currentClass </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">if</span><span style="color:#ADBAC7;">(</span><span style="color:#96D0FF;">&quot;com.demo.ATest&quot;</span><span style="color:#ADBAC7;">.hasClass()) </span><span style="color:#96D0FF;">&quot;com.demo.ATest&quot;</span><span style="color:#ADBAC7;">.toClass() </span><span style="color:#F47067;">else</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.demo.BTest&quot;</span><span style="color:#ADBAC7;">.toClass()</span></span>
<span class="line"><span style="color:#768390;">// \u7136\u540E\u518D\u67E5\u627E\u8FD9\u4E2A\u65B9\u6CD5\u5E76\u8C03\u7528</span></span>
<span class="line"><span style="color:#ADBAC7;">currentClass.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;doTask&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    emptyParam()</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get().call()</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u611F\u89C9\u8FD9\u79CD\u65B9\u6848\u975E\u5E38\u7684\u4E0D\u4F18\u96C5\u4E14\u7E41\u7410\uFF0C\u90A3\u4E48\u6B64\u65F6 <code>YukiReflection</code> \u5C31\u4E3A\u4F60\u63D0\u4F9B\u4E86\u4E00\u4E2A\u975E\u5E38\u65B9\u4FBF\u7684 <code>VariousClass</code> \u4E13\u95E8\u6765\u89E3\u51B3\u8FD9\u4E2A\u95EE\u9898\u3002</p><p>\u73B0\u5728\uFF0C\u4F60\u53EF\u4EE5\u76F4\u63A5\u4F7F\u7528\u4EE5\u4E0B\u65B9\u5F0F\u83B7\u53D6\u5230\u8FD9\u4E2A <code>Class</code>\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F69D50;">VariousClass</span><span style="color:#ADBAC7;">(</span><span style="color:#96D0FF;">&quot;com.demo.ATest&quot;</span><span style="color:#ADBAC7;">, </span><span style="color:#96D0FF;">&quot;com.demo.BTest&quot;</span><span style="color:#ADBAC7;">).get().method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;doTask&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    emptyParam()</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get().call()</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u82E5\u5F53\u524D <code>Class</code> \u5728\u6307\u5B9A\u7684 <code>ClassLoader</code> \u4E2D\u5B58\u5728\uFF0C\u4F60\u53EF\u4EE5\u5728 <code>get</code> \u4E2D\u586B\u5165\u4F60\u7684 <code>ClassLoader</code>\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> customClassLoader</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">ClassLoader?</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> ... </span><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u4E2A\u5C31\u662F\u4F60\u7684 ClassLoader</span></span>
<span class="line"><span style="color:#F69D50;">VariousClass</span><span style="color:#ADBAC7;">(</span><span style="color:#96D0FF;">&quot;com.demo.ATest&quot;</span><span style="color:#ADBAC7;">, </span><span style="color:#96D0FF;">&quot;com.demo.BTest&quot;</span><span style="color:#ADBAC7;">).get(customClassLoader).method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;doTask&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    emptyParam()</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get().call()</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u82E5\u4F60\u4E0D\u786E\u5B9A\u6240\u6709\u7684 <code>Class</code> \u4E00\u5B9A\u4F1A\u88AB\u5339\u914D\u5230\uFF0C\u4F60\u53EF\u4EE5\u4F7F\u7528 <code>getOrNull</code> \u65B9\u6CD5\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> customClassLoader</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">ClassLoader?</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> ... </span><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u4E2A\u5C31\u662F\u4F60\u7684 ClassLoader</span></span>
<span class="line"><span style="color:#F69D50;">VariousClass</span><span style="color:#ADBAC7;">(</span><span style="color:#96D0FF;">&quot;com.demo.ATest&quot;</span><span style="color:#ADBAC7;">, </span><span style="color:#96D0FF;">&quot;com.demo.BTest&quot;</span><span style="color:#ADBAC7;">).getOrNull(customClassLoader)?.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;doTask&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    emptyParam()</span></span>
<span class="line"><span style="color:#ADBAC7;">}?.get()?.call()</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="custom-container tip"><p class="custom-container-title">\u5C0F\u63D0\u793A</p><p>\u66F4\u591A\u529F\u80FD\u8BF7\u53C2\u8003 <a href="../api/public/com/highcapable/yukireflection/bean/VariousClass">VariousClass</a>\u3002</p></div><h3 id="\u8C03\u7528\u6CDB\u578B" tabindex="-1"><a class="header-anchor" href="#\u8C03\u7528\u6CDB\u578B" aria-hidden="true">#</a> \u8C03\u7528\u6CDB\u578B</h3><p>\u5728\u53CD\u5C04\u8FC7\u7A0B\u4E2D\uFF0C\u6211\u4EEC\u53EF\u80FD\u4F1A\u9047\u5230\u6CDB\u578B\u95EE\u9898\uFF0C\u5728\u6CDB\u578B\u7684\u53CD\u5C04\u5904\u7406\u4E0A\uFF0C<code>YukiReflection</code> \u540C\u6837\u63D0\u4F9B\u4E86\u4E00\u4E2A\u53EF\u5728\u4EFB\u610F\u5730\u65B9\u4F7F\u7528\u7684\u8BED\u6CD5\u7CD6\u3002</p><p>\u4F8B\u5982\u6211\u4EEC\u6709\u5982\u4E0B\u7684\u6CDB\u578B\u7C7B\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">class</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">TestGeneric</span><span style="color:#F47067;">&lt;</span><span style="color:#F69D50;">T</span><span style="color:#ADBAC7;">, </span><span style="color:#F69D50;">R</span><span style="color:#F47067;">&gt;</span><span style="color:#ADBAC7;"> (t</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">T</span><span style="color:#ADBAC7;">, r</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">R</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">fun</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">foo</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u5F53\u6211\u4EEC\u60F3\u5728\u5F53\u524D <code>Class</code> \u4E2D\u83B7\u5F97\u6CDB\u578B <code>T</code> \u6216 <code>R</code> \u7684 <code>Class</code> \u5B9E\u4F8B\uFF0C\u53EA\u9700\u8981\u5982\u4E0B\u5B9E\u73B0\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">class</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">TestGeneric</span><span style="color:#F47067;">&lt;</span><span style="color:#F69D50;">T</span><span style="color:#ADBAC7;">, </span><span style="color:#F69D50;">R</span><span style="color:#F47067;">&gt;</span><span style="color:#ADBAC7;"> (t</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">T</span><span style="color:#ADBAC7;">, r</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">R</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">fun</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">foo</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// \u83B7\u5F97\u5F53\u524D\u5B9E\u4F8B\u7684\u64CD\u4F5C\u5BF9\u8C61</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// \u83B7\u5F97 T \u7684 Class \u5B9E\u4F8B\uFF0C\u5728\u53C2\u6570\u7B2C 0 \u4F4D\uFF0C\u9ED8\u8BA4\u503C\u53EF\u4EE5\u4E0D\u5199</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> tClass </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> current().generic()?.argument()</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// \u83B7\u5F97 R \u7684 Class \u5B9E\u4F8B\uFF0C\u5728\u53C2\u6570\u7B2C 1 \u4F4D</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> rClass </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> current().generic()?.argument(index </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">1</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// \u4F60\u8FD8\u53EF\u4EE5\u4F7F\u7528\u5982\u4E0B\u5199\u6CD5</span></span>
<span class="line"><span style="color:#ADBAC7;">        current().generic {</span></span>
<span class="line"><span style="color:#ADBAC7;">             </span><span style="color:#768390;">// \u83B7\u5F97 T \u7684 Class \u5B9E\u4F8B\uFF0C\u5728\u53C2\u6570\u7B2C 0 \u4F4D\uFF0C\u9ED8\u8BA4\u503C\u53EF\u4EE5\u4E0D\u5199</span></span>
<span class="line"><span style="color:#ADBAC7;">            </span><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> tClass </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> argument()</span></span>
<span class="line"><span style="color:#ADBAC7;">            </span><span style="color:#768390;">// \u83B7\u5F97 R \u7684 Class \u5B9E\u4F8B\uFF0C\u5728\u53C2\u6570\u7B2C 1 \u4F4D</span></span>
<span class="line"><span style="color:#ADBAC7;">            </span><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> rClass </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> argument(index </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">1</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">        }</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u5F53\u6211\u4EEC\u60F3\u5728\u5916\u90E8\u8C03\u7528\u8FD9\u4E2A <code>Class</code> \u65F6\uFF0C\u5C31\u53EF\u4EE5\u6709\u5982\u4E0B\u5B9E\u73B0\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u4E2A\u5C31\u662F T \u7684 Class</span></span>
<span class="line"><span style="color:#F47067;">class</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">TI</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">fun</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">foo</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u4E2A\u5C31\u662F T \u7684\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> tInstance</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">TI</span><span style="color:#ADBAC7;">? </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> ...</span></span>
<span class="line"><span style="color:#768390;">// \u83B7\u5F97 T \u7684 Class \u5B9E\u4F8B\uFF0C\u5728\u53C2\u6570\u7B2C 0 \u4F4D\uFF0C\u9ED8\u8BA4\u503C\u53EF\u4EE5\u4E0D\u5199\uFF0C\u5E76\u83B7\u5F97\u5176\u4E2D\u7684\u65B9\u6CD5 foo \u5E76\u8C03\u7528</span></span>
<span class="line"><span style="color:#F69D50;">TestGeneric</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.generic()?.argument()?.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;foo&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    emptyParam()</span></span>
<span class="line"><span style="color:#ADBAC7;">}?.get(tInstance)?.invoke</span><span style="color:#F47067;">&lt;</span><span style="color:#F69D50;">TI</span><span style="color:#F47067;">&gt;</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="custom-container tip"><p class="custom-container-title">\u5C0F\u63D0\u793A</p><p>\u66F4\u591A\u529F\u80FD\u8BF7\u53C2\u8003 <a href="../api/public/com/highcapable/yukireflection/bean/CurrentClass#generic-method">CurrentClass.generic</a>\u3001<a href="../api/public/com/highcapable/yukireflection/factory/ReflectionFactory#class-generic-ext-method">Class.generic</a> \u65B9\u6CD5\u4EE5\u53CA <a href="../api/public/com/highcapable/yukireflection/bean/GenericClass">GenericClass</a>\u3002</p></div><h3 id="\u6CE8\u610F\u8BEF\u533A" tabindex="-1"><a class="header-anchor" href="#\u6CE8\u610F\u8BEF\u533A" aria-hidden="true">#</a> \u6CE8\u610F\u8BEF\u533A</h3><blockquote><p>\u8FD9\u91CC\u5217\u4E3E\u4E86\u4F7F\u7528\u65F6\u53EF\u80FD\u4F1A\u9047\u5230\u7684\u8BEF\u533A\u90E8\u5206\uFF0C\u53EF\u4F9B\u53C2\u8003\u3002</p></blockquote><h4 id="\u9650\u5236\u6027\u67E5\u627E\u6761\u4EF6" tabindex="-1"><a class="header-anchor" href="#\u9650\u5236\u6027\u67E5\u627E\u6761\u4EF6" aria-hidden="true">#</a> \u9650\u5236\u6027\u67E5\u627E\u6761\u4EF6</h4><div class="custom-container danger"><p class="custom-container-title">\u7279\u522B\u6CE8\u610F</p><p>\u5728\u67E5\u627E\u6761\u4EF6\u4E2D\uFF0C\u9664\u4E86 <strong>order</strong> \u4F60\u53EA\u80FD\u4F7F\u7528\u4E00\u6B21 <strong>index</strong> \u529F\u80FD\u3002</p></div><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#ADBAC7;">method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;test&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    param(</span><span style="color:#F69D50;">BooleanType</span><span style="color:#ADBAC7;">).index(num </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">2</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u2757\u9519\u8BEF\u7684\u4F7F\u7528\u65B9\u6CD5\uFF0C\u8BF7\u4EC5\u4FDD\u7559\u4E00\u4E2A index \u65B9\u6CD5</span></span>
<span class="line"><span style="color:#ADBAC7;">    returnType(</span><span style="color:#F69D50;">StringClass</span><span style="color:#ADBAC7;">).index(num </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">1</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u4EE5\u4E0B\u67E5\u627E\u6761\u4EF6\u7684\u4F7F\u7528\u662F\u6CA1\u6709\u4EFB\u4F55\u95EE\u9898\u7684\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#ADBAC7;">method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;test&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    param(</span><span style="color:#F69D50;">BooleanType</span><span style="color:#ADBAC7;">).index(num </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">2</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    order().index(num </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">1</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="\u5FC5\u8981\u7684\u67E5\u627E\u6761\u4EF6" tabindex="-1"><a class="header-anchor" href="#\u5FC5\u8981\u7684\u67E5\u627E\u6761\u4EF6" aria-hidden="true">#</a> \u5FC5\u8981\u7684\u67E5\u627E\u6761\u4EF6</h4><div class="custom-container danger"><p class="custom-container-title">\u7279\u522B\u6CE8\u610F</p><p>\u5728\u666E\u901A\u65B9\u6CD5\u67E5\u627E\u6761\u4EF6\u4E2D\uFF0C<u><strong>\u5373\u4F7F\u662F\u65E0\u53C2\u7684\u65B9\u6CD5\u4E5F\u9700\u8981\u8BBE\u7F6E\u67E5\u627E\u6761\u4EF6</strong></u>\u3002</p></div><p>\u5047\u8BBE\u6211\u4EEC\u6709\u5982\u4E0B\u7684 <code>Class</code>\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-java ext-java"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">class</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">TestFoo</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">void</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">foo</span><span style="color:#ADBAC7;">(String </span><span style="color:#F69D50;">string</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">void</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">foo</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre></div><p>\u6211\u4EEC\u8981\u5F97\u5230\u5176\u4E2D\u7684 <code>public void foo()</code> \u65B9\u6CD5\uFF0C\u53EF\u4EE5\u5199\u4F5C\u5982\u4E0B\u5F62\u5F0F\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F69D50;">TestFoo</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;foo&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u4F46\u662F\uFF0C\u4E0A\u9762\u7684\u4F8B\u5B50<u><strong>\u662F\u9519\u8BEF\u7684</strong></u>\u3002</p><p>\u4F60\u4F1A\u53D1\u73B0\u8FD9\u4E2A <code>Class</code> \u4E2D\u6709\u4E24\u4E2A <code>foo</code> \u65B9\u6CD5\uFF0C\u5176\u4E2D\u4E00\u4E2A\u5E26\u6709\u65B9\u6CD5\u53C2\u6570\u3002</p><p>\u7531\u4E8E\u4E0A\u8FF0\u4F8B\u5B50\u6CA1\u6709\u8BBE\u7F6E <code>param</code> \u7684\u67E5\u627E\u6761\u4EF6\uFF0C\u5F97\u5230\u7684\u7ED3\u679C\u5C06\u4F1A\u662F\u5339\u914D\u540D\u79F0\u4E14\u5339\u914D\u5B57\u8282\u7801\u987A\u5E8F\u7684\u7B2C\u4E00\u4E2A\u65B9\u6CD5 <code>public void foo(String string)</code>\uFF0C\u800C\u4E0D\u662F\u6211\u4EEC\u9700\u8981\u7684\u6700\u540E\u4E00\u4E2A\u65B9\u6CD5\u3002</p><p>\u8FD9\u662F\u4E00\u4E2A<strong>\u7ECF\u5E38\u4F1A\u51FA\u73B0\u7684\u9519\u8BEF</strong>\uFF0C<strong>\u6CA1\u6709\u65B9\u6CD5\u53C2\u6570\u5C31\u4F1A\u4E22\u5931\u65B9\u6CD5\u53C2\u6570\u67E5\u627E\u6761\u4EF6</strong>\u7684\u4F7F\u7528\u95EE\u9898\u3002</p><p>\u6B63\u786E\u7684\u4F7F\u7528\u65B9\u6CD5\u5982\u4E0B\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F69D50;">TestFoo</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.method {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;foo&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u2705 \u6B63\u786E\u7684\u4F7F\u7528\u65B9\u6CD5\uFF0C\u6DFB\u52A0\u8BE6\u7EC6\u7684\u7B5B\u9009\u6761\u4EF6</span></span>
<span class="line"><span style="color:#ADBAC7;">    emptyParam()</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u81F3\u6B64\uFF0C\u4E0A\u8FF0\u7684\u793A\u4F8B\u5C06\u53EF\u4EE5\u5B8C\u7F8E\u5730\u5339\u914D\u5230 <code>public void foo()</code> \u65B9\u6CD5\u3002</p><h4 id="\u53EF\u7B80\u5199\u67E5\u627E\u6761\u4EF6" tabindex="-1"><a class="header-anchor" href="#\u53EF\u7B80\u5199\u67E5\u627E\u6761\u4EF6" aria-hidden="true">#</a> \u53EF\u7B80\u5199\u67E5\u627E\u6761\u4EF6</h4><blockquote><p>\u5728\u6784\u9020\u65B9\u6CD5\u67E5\u627E\u6761\u4EF6\u4E2D\uFF0C<u><strong>\u65E0\u53C2\u7684\u6784\u9020\u65B9\u6CD5\u53EF\u4EE5\u4E0D\u9700\u8981\u586B\u5199\u67E5\u627E\u6761\u4EF6</strong></u>\u3002</p></blockquote><p>\u5047\u8BBE\u6211\u4EEC\u6709\u5982\u4E0B\u7684 <code>Class</code>\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-java ext-java"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">class</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">TestFoo</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">TestFoo</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre></div><p>\u6211\u4EEC\u8981\u5F97\u5230\u5176\u4E2D\u7684 <code>public TestFoo()</code> \u6784\u9020\u65B9\u6CD5\uFF0C\u53EF\u4EE5\u5199\u4F5C\u5982\u4E0B\u5F62\u5F0F\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F69D50;">TestFoo</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.</span><span style="color:#DCBDFB;">constructor</span><span style="color:#ADBAC7;"> { emptyParam() }</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>\u4E0A\u9762\u7684\u4F8B\u5B50\u53EF\u4EE5\u6210\u529F\u83B7\u53D6\u5230 <code>public TestFoo()</code> \u6784\u9020\u65B9\u6CD5\uFF0C\u4F46\u662F\u611F\u89C9\u6709\u4E00\u4E9B\u7E41\u7410\u3002</p><p>\u4E0E\u666E\u901A\u65B9\u6CD5\u4E0D\u540C\uFF0C\u7531\u4E8E\u6784\u9020\u65B9\u6CD5\u4E0D\u9700\u8981\u8003\u8651 <code>name</code> \u540D\u79F0\uFF0C\u5F53\u6784\u9020\u65B9\u6CD5\u6CA1\u6709\u53C2\u6570\u7684\u65F6\u5019\uFF0C\u6211\u4EEC\u53EF\u4EE5\u7701\u7565 <code>emptyParam</code> \u53C2\u6570\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F69D50;">TestFoo</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.java.</span><span style="color:#DCBDFB;">constructor</span><span style="color:#ADBAC7;">()</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h4 id="\u5B57\u8282\u7801\u7C7B\u578B" tabindex="-1"><a class="header-anchor" href="#\u5B57\u8282\u7801\u7C7B\u578B" aria-hidden="true">#</a> \u5B57\u8282\u7801\u7C7B\u578B</h4><div class="custom-container danger"><p class="custom-container-title">\u7279\u522B\u6CE8\u610F</p><p>\u5728\u5B57\u8282\u7801\u8C03\u7528\u7ED3\u679C\u4E2D\uFF0C<strong>cast</strong> \u65B9\u6CD5\u53EA\u80FD\u6307\u5B9A\u5B57\u8282\u7801\u5BF9\u5E94\u7684\u7C7B\u578B\u3002</p></div><p>\u4F8B\u5982\u6211\u4EEC\u60F3\u5F97\u5230\u4E00\u4E2A <code>Boolean</code> \u7C7B\u578B\u7684\u53D8\u91CF\uFF0C\u628A\u4ED6\u8F6C\u6362\u4E3A <code>String</code>\u3002</p><p>\u4EE5\u4E0B\u662F\u9519\u8BEF\u7684\u4F7F\u7528\u65B9\u6CD5\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#ADBAC7;">field {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;test&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    type </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">BooleanType</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get().string() </span><span style="color:#768390;">// \u2757\u9519\u8BEF\u7684\u4F7F\u7528\u65B9\u6CD5\uFF0C\u5FC5\u987B cast \u4E3A\u5B57\u8282\u7801\u76EE\u6807\u7C7B\u578B</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u4EE5\u4E0B\u662F\u6B63\u786E\u7684\u4F7F\u7528\u65B9\u6CD5\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#ADBAC7;">field {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;test&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    type </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">BooleanType</span></span>
<span class="line"><span style="color:#ADBAC7;">}.get().boolean().toString() </span><span style="color:#768390;">// \u2705 \u6B63\u786E\u7684\u4F7F\u7528\u65B9\u6CD5\uFF0C\u5F97\u5230\u7C7B\u578B\u540E\u518D\u8FDB\u884C\u8F6C\u6362</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="\u5E38\u7528\u7C7B\u578B\u6269\u5C55" tabindex="-1"><a class="header-anchor" href="#\u5E38\u7528\u7C7B\u578B\u6269\u5C55" aria-hidden="true">#</a> \u5E38\u7528\u7C7B\u578B\u6269\u5C55</h2><p>\u5728\u67E5\u627E\u65B9\u6CD5\u3001\u53D8\u91CF\u7684\u65F6\u5019\u6211\u4EEC\u901A\u5E38\u9700\u8981\u6307\u5B9A\u6240\u67E5\u627E\u7684\u7C7B\u578B\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#ADBAC7;">field {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;test&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    type </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">Boolean</span><span style="color:#ADBAC7;">::</span><span style="color:#6CB6FF;">class</span><span style="color:#ADBAC7;">.javaPrimitiveType</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u5728 <code>Kotlin</code> \u4E2D\u8868\u8FBE\u51FA <code>Boolean::class.javaPrimitiveType</code> \u8FD9\u4E2A\u7C7B\u578B\u7684\u5199\u6CD5\u5F88\u957F\uFF0C\u611F\u89C9\u5E76\u4E0D\u65B9\u4FBF\u3002</p><p>\u56E0\u6B64\uFF0C<code>YukiReflection</code> \u4E3A\u5F00\u53D1\u8005\u5C01\u88C5\u4E86\u5E38\u89C1\u7684\u7C7B\u578B\u8C03\u7528\uFF0C\u5176\u4E2D\u5305\u542B\u4E86 Android \u7684\u76F8\u5173\u7C7B\u578B\u548C Java \u7684\u5E38\u89C1\u7C7B\u578B\u4E0E<strong>\u539F\u59CB\u7C7B\u578B\u5173\u952E\u5B57</strong>\u3002</p><p>\u8FD9\u4E2A\u65F6\u5019\u4E0A\u9762\u7684\u7C7B\u578B\u5C31\u53EF\u4EE5\u5199\u4F5C\u5982\u4E0B\u5F62\u5F0F\u4E86\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#ADBAC7;">field {</span></span>
<span class="line"><span style="color:#ADBAC7;">    name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;test&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    type </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">BooleanType</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u5728 Java \u5E38\u89C1\u7C7B\u578B\u4E2D\u7684<strong>\u539F\u59CB\u7C7B\u578B (\u6216\u57FA\u672C\u7C7B\u578B) \u5173\u952E\u5B57</strong>\u90FD\u5DF2\u88AB\u5C01\u88C5\u4E3A <strong>\u7C7B\u578B + Type</strong> \u7684\u65B9\u5F0F\uFF0C\u4F8B\u5982 <code>IntType</code>\u3001<code>FloatType</code> (\u5B83\u4EEC\u7684\u5B57\u8282\u7801\u7C7B\u578B\u4E3A <code>int</code>\u3001<code>float</code>)\u3002</p><p>\u76F8\u5E94\u5730\uFF0C\u6570\u7EC4\u7C7B\u578B\u4E5F\u6709\u65B9\u4FBF\u7684\u4F7F\u7528\u65B9\u6CD5\uFF0C\u5047\u8BBE\u6211\u4EEC\u8981\u83B7\u5F97 <code>String[]</code> \u7C7B\u578B\u7684\u6570\u7EC4\u3002</p><p>\u9700\u8981\u5199\u505A <code>java.lang.reflect.Array.newInstance(String::class.java, 0).javaClass</code> \u624D\u80FD\u5F97\u5230\u8FD9\u4E2A\u7C7B\u578B\u3002</p><p>\u611F\u89C9\u662F\u4E0D\u662F\u5F88\u9EBB\u70E6\uFF0C\u8FD9\u4E2A\u65F6\u5019\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528\u65B9\u6CD5 <code>ArrayClass(StringClass)</code> \u6765\u5F97\u5230\u8FD9\u4E2A\u7C7B\u578B\u3002</p><p>\u540C\u65F6\u7531\u4E8E <code>String</code> \u662F\u5E38\u89C1\u7C7B\u578B\uFF0C\u6240\u4EE5\u8FD8\u53EF\u4EE5\u76F4\u63A5\u4F7F\u7528 <code>StringArrayClass</code> \u6765\u5F97\u5230\u8FD9\u4E2A\u7C7B\u578B\u3002</p><p>\u4E00\u4E9B\u5E38\u89C1\u9700\u6C42\u4E2D\u67E5\u627E\u7684\u65B9\u6CD5\uFF0C\u90FD\u6709\u5176\u5BF9\u5E94\u7684\u5C01\u88C5\u7C7B\u578B\u4EE5\u4F9B\u4F7F\u7528\uFF0C\u683C\u5F0F\u4E3A <strong>\u7C7B\u578B + Class</strong>\u3002</p><p>\u4EE5\u4E0B\u662F Java \u4E2D\u4E00\u4E9B\u7279\u4F8B\u7C7B\u578B\u5728 <code>YukiReflection</code> \u4E2D\u7684\u5C01\u88C5\u540D\u79F0\u3002</p><ul><li><p><code>void</code> \u2192 <code>UnitType</code></p></li><li><p><code>java.lang.Void</code> \u2192 <code>UnitClass</code></p></li><li><p><code>java.lang.Object</code> \u2192 <code>AnyClass</code></p></li><li><p><code>java.lang.Integer</code> \u2192 <code>IntClass</code></p></li><li><p><code>java.lang.Character</code> \u2192 <code>CharClass</code></p></li></ul><div class="custom-container warning"><p class="custom-container-title">\u6CE8\u610F</p><p>\u4EE5 <strong>\u7C7B\u578B + Type</strong> \u5C01\u88C5\u7C7B\u578B\u4F1A\u4E14\u4EC5\u4F1A\u8868\u793A\u4E3A Java <strong>\u539F\u59CB\u7C7B\u578B\u5173\u952E\u5B57</strong>\uFF0C\u7531\u4E8E Kotlin \u4E2D\u4E0D\u5B58\u5728<strong>\u539F\u59CB\u7C7B\u578B</strong>\u8FD9\u4E2A\u6982\u5FF5\uFF0C\u6240\u4EE5\u5B83\u4EEC\u90FD\u4F1A\u88AB\u5B9A\u4E49\u4E3A <strong>KClass</strong>\u3002</p><p>Java \u4E2D\u5171\u6709 9 \u4E2A<strong>\u539F\u59CB\u7C7B\u578B\u5173\u952E\u5B57</strong>\uFF0C\u5176\u4E2D 8 \u4E2A\u4E3A<strong>\u539F\u59CB\u7C7B\u578B</strong>\uFF0C\u5206\u522B\u4E3A <strong>boolean</strong>\u3001<strong>char</strong>\u3001<strong>byte</strong>\u3001<strong>short</strong>\u3001<strong>int</strong>\u3001<strong>float</strong>\u3001<strong>long</strong>\u3001<strong>double</strong>\uFF0C\u5176\u4E2D <strong>void</strong> \u7C7B\u578B\u662F\u4E00\u4E2A\u7279\u4F8B\u3002</p><p>\u540C\u65F6\u5B83\u4EEC\u90FD\u6709 Java \u81EA\u8EAB\u5BF9\u5E94\u7684\u5C01\u88C5\u7C7B\u578B\uFF0C\u4F8B\u5982 <strong>java.lang.Boolean</strong>\u3001<strong>java.lang.Integer</strong>\uFF0C\u8FD9\u4E9B\u7C7B\u578B\u662F<u><strong>\u4E0D\u76F8\u7B49\u7684</strong></u>\uFF0C\u8BF7\u6CE8\u610F\u533A\u5206\u3002</p><p>\u540C\u6837\u5730\uFF0C\u6570\u7EC4\u4E5F\u6709\u5BF9\u5E94\u7684\u5C01\u88C5\u7C7B\u578B\uFF0C\u5B83\u4EEC\u4E5F\u9700\u8981\u4E0E Java <strong>\u539F\u59CB\u7C7B\u578B\u5173\u952E\u5B57</strong> \u8FDB\u884C\u533A\u5206\u3002</p><p>\u4F8B\u5982 <strong>byte[]</strong> \u7684\u5C01\u88C5\u7C7B\u578B\u4E3A <strong>ByteArrayType</strong> \u6216 <strong>ArrayClass(ByteType)</strong>\uFF0C\u800C <strong>Byte[]</strong> \u7684\u5C01\u88C5\u7C7B\u578B\u4E3A <strong>ByteArrayClass</strong> \u6216 <strong>ArrayClass(ByteClass)</strong>\uFF0C\u8FD9\u4E9B\u7C7B\u578B\u4E5F\u662F<u><strong>\u4E0D\u76F8\u7B49\u7684</strong></u>\u3002</p></div><div class="custom-container tip"><p class="custom-container-title">\u5C0F\u63D0\u793A</p><p>\u66F4\u591A\u7C7B\u578B\u53EF\u67E5\u770B <a href="../api/public/com/highcapable/yukireflection/type/android/ComponentTypeFactory">ComponentTypeFactory</a>\u3001<a href="../api/public/com/highcapable/yukireflection/type/android/GraphicsTypeFactory">GraphicsTypeFactory</a>\u3001<a href="../api/public/com/highcapable/yukireflection/type/android/ViewTypeFactory">ViewTypeFactory</a>\u3001<a href="../api/public/com/highcapable/yukireflection/type/java/VariableTypeFactory">VariableTypeFactory</a>\u3002</p></div><p>\u540C\u65F6\uFF0C\u6B22\u8FCE\u4F60\u80FD\u8D21\u732E\u66F4\u591A\u7684\u5E38\u7528\u7C7B\u578B\u3002</p>`,330);function v(C,D){const a=e("Badge");return p(),o("div",null,[i,s("h3",d,[y,A,c(a,{type:"tip",text:"Beta",vertical:"middle"})]),u])}const m=l(t,[["render",v],["__file","features.html.vue"]]);export{m as default};
