Skip to content

Commit

Permalink
1、完善替换方法调用切面
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyJingFish committed Apr 2, 2024
1 parent 9b83281 commit a9dd14d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,27 +170,29 @@ abstract class AssembleAndroidAopTask : DefaultTask() {
}

private fun searchJoinPointLocation(){
val androidConfig = AndroidConfig(project)
val list: List<File> = 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<File> = 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()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,14 +319,18 @@ object WovenInfoUtils {
return lastAopMatchCuts != aopMatchCuts
}

private var invokeMethodCutCache : MutableList<AopReplaceCut>?= 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<AopReplaceCut>?= null
fun addExtendsReplace(className:String){
if (!isHasExtendsReplace()){
return
}
val ctClass = try {
Expand Down

0 comments on commit a9dd14d

Please sign in to comment.