Proguard中-if的含义
Meaning of -if in Proguard
对于以下 Proguard 规则(取 Kotlin Serialization)
-if @kotlinx.serialization.Serializable class **
-keepclassmembers class <1> {
static <1>$Companion Companion;
}
在上述规则的上下文中,-if
的含义是什么?我尝试查看官方混淆器文档,但无法轻松找到相关信息
我写了那些 ProGuard 规则。 :) pull request discussion about these changes may provide relevant background.
我理解你的困惑,ProGuard rules documentation is quite sparse。
-if
class_specification
Specifies classes and class members that must be present
to activate the subsequent keep option (-keep
,
-keepclassmembers
,...). The condition and the subsequent keep option can share wildcards and references to wildcards. For example, you can
keep classes on the condition that classes with related names exist in
your project, with frameworks like Dagger and Butterknife.
正如您从以下位置复制的规则评论中所写:
# Keep `Companion` object fields of serializable classes.
# This avoids serializer lookup through `getDeclaredClasses` as done for named companion objects.
-if @kotlinx.serialization.Serializable class **
...
因此,-if @kotlinx.serialization.Serializable class **
应理解为:对于应用了 @Serializable
注释的所有 classes(即“可序列化 classes”)。 -keepmembers
中的 <1>
随后引用 **
通配符,即完全限定的 class 名称。
对于以下 Proguard 规则(取 Kotlin Serialization)
-if @kotlinx.serialization.Serializable class **
-keepclassmembers class <1> {
static <1>$Companion Companion;
}
在上述规则的上下文中,-if
的含义是什么?我尝试查看官方混淆器文档,但无法轻松找到相关信息
我写了那些 ProGuard 规则。 :) pull request discussion about these changes may provide relevant background.
我理解你的困惑,ProGuard rules documentation is quite sparse。
-if
class_specificationSpecifies classes and class members that must be
present
to activate the subsequent keep option (-keep
,-keepclassmembers
,...). The condition and the subsequent keep option can share wildcards and references to wildcards. For example, you can keep classes on the condition that classes with related names exist in your project, with frameworks like Dagger and Butterknife.
正如您从以下位置复制的规则评论中所写:
# Keep `Companion` object fields of serializable classes.
# This avoids serializer lookup through `getDeclaredClasses` as done for named companion objects.
-if @kotlinx.serialization.Serializable class **
...
因此,-if @kotlinx.serialization.Serializable class **
应理解为:对于应用了 @Serializable
注释的所有 classes(即“可序列化 classes”)。 -keepmembers
中的 <1>
随后引用 **
通配符,即完全限定的 class 名称。