From a9dd14d7e20306c0eb4e94349450fad67f40a8ec Mon Sep 17 00:00:00 2001 From: FlyJingFish Date: Tue, 2 Apr 2024 22:17:09 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=AE=8C=E5=96=84=E6=9B=BF=E6=8D=A2?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E8=B0=83=E7=94=A8=E5=88=87=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AssembleAndroidAopTask.kt | 38 ++++++++++--------- .../utils/WovenInfoUtils.kt | 10 +++-- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/android-aop-plugin/src/main/kotlin/com/flyjingfish/android_aop_plugin/AssembleAndroidAopTask.kt b/android-aop-plugin/src/main/kotlin/com/flyjingfish/android_aop_plugin/AssembleAndroidAopTask.kt index 1b89c938..bc8a71f1 100644 --- a/android-aop-plugin/src/main/kotlin/com/flyjingfish/android_aop_plugin/AssembleAndroidAopTask.kt +++ b/android-aop-plugin/src/main/kotlin/com/flyjingfish/android_aop_plugin/AssembleAndroidAopTask.kt @@ -170,27 +170,29 @@ abstract class AssembleAndroidAopTask : DefaultTask() { } private fun searchJoinPointLocation(){ - val androidConfig = AndroidConfig(project) - val list: List = androidConfig.getBootClasspath() - for (file in list) { - try { - val jarFile = JarFile(file) - val enumeration = jarFile.entries() - while (enumeration.hasMoreElements()) { - val jarEntry = enumeration.nextElement() - try { - val entryName = jarEntry.name - if (entryName.endsWith(Utils._CLASS)) { - val className = entryName.replace(".class","") - WovenInfoUtils.addExtendsReplace(Utils.slashToDot(className)) - } - } catch (_: Exception) { + if (WovenInfoUtils.isHasExtendsReplace()){ + val androidConfig = AndroidConfig(project) + val list: List = androidConfig.getBootClasspath() + for (file in list) { + try { + val jarFile = JarFile(file) + val enumeration = jarFile.entries() + while (enumeration.hasMoreElements()) { + val jarEntry = enumeration.nextElement() + try { + val entryName = jarEntry.name + if (entryName.endsWith(Utils._CLASS)) { + val className = entryName.replace(".class","") + WovenInfoUtils.addExtendsReplace(Utils.slashToDot(className)) + } + } catch (_: Exception) { + } } + jarFile.close() + } catch (e: Exception) { + e.printStackTrace() } - jarFile.close() - } catch (e: Exception) { - e.printStackTrace() } } diff --git a/android-aop-plugin/src/main/kotlin/com/flyjingfish/android_aop_plugin/utils/WovenInfoUtils.kt b/android-aop-plugin/src/main/kotlin/com/flyjingfish/android_aop_plugin/utils/WovenInfoUtils.kt index 754ea4c0..356394ea 100644 --- a/android-aop-plugin/src/main/kotlin/com/flyjingfish/android_aop_plugin/utils/WovenInfoUtils.kt +++ b/android-aop-plugin/src/main/kotlin/com/flyjingfish/android_aop_plugin/utils/WovenInfoUtils.kt @@ -319,14 +319,18 @@ object WovenInfoUtils { return lastAopMatchCuts != aopMatchCuts } - private var invokeMethodCutCache : MutableList?= null - fun addExtendsReplace(className:String){ + fun isHasExtendsReplace():Boolean{ if (invokeMethodCutCache == null){ invokeMethodCutCache = invokeMethodCuts.filter { it.matchType != AopMatchCut.MatchType.SELF.name }.toMutableList() } - if (invokeMethodCutCache?.isEmpty() == true){ + return !invokeMethodCutCache.isNullOrEmpty() + } + + private var invokeMethodCutCache : MutableList?= null + fun addExtendsReplace(className:String){ + if (!isHasExtendsReplace()){ return } val ctClass = try {