Skip to content

白名单规则的BUG #790

@fanshidong1993

Description

@fanshidong1993

com.tencent.shadow.core.loader.classloaders.PluginClassLoader
PackageNameTrie
isMatch(packageName) (第172行)

这里的 packageName 是去掉了最后的类名的
如果规则 设置, a.b.c.*
想要加载类名 a.b.c.d 是没办法加载到宿主的类的
循环只有3次, lastindex == index 的时候 node 其实还是 b, 他的subnode 是c 而不是*

for ((index, name) in split.withIndex()) {
           // 只要下级包名规则中有**,就完成了匹配
           val twoStars = node.subNodes["**"]
           if (twoStars != null) {
               return true
           }

           // 剩最后一级包名时,如果规则是*则完成比配
           if (index == lastIndex) {
               val oneStar = node.subNodes["*"]
               if (oneStar != null) {
                   return true
               }
           }

           // 找不到下级包名时即匹配失败
           val subNode = node.subNodes[name]
           if (subNode == null) {
               return false
           } else {
               node = subNode
           }
       }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions