我发现混淆会导致字节码中出现奇怪的语法错误,我尝试了多种方法使其正常工作,但是每次都遇到问题。我在IntelliJ中检查了编译后的代码,这就是我可以在此处发布的内容。问题似乎出在Companion对象中,并且它们在混淆过程中可能已损坏。
原始代码:(有效)
companion object {
lateinit var instance: GTAnticheat
private set
val DEBUG = false
}
原始编译代码:(有效)
public static final GTAnticheat.Companion Companion = new GTAnticheat.Companion((DefaultConstructorMarker)null);
// $FF: synthetic method
@NotNull
public static final GTAnticheat access$getInstance$cp() {
GTAnticheat var10000 = instance;
if (instance == null) {
Intrinsics.throwUninitializedPropertyAccessException("instance");
}
return var10000;
}
@Metadata(
mv = {1, 1, 11},
bv = {1, 0, 2},
k = 1,
d1 = {"\u0000\u001c\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0006\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002R\u0014\u0010\u0003\u001a\u00020\u0004X\u0086D¢\u0006\b\n\u0000\u001a\u0004\b\u0005\u0010\u0006R$\u0010\t\u001a\u00020\b2\u0006\u0010\u0007\u001a\u00020\b@BX\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\b\n\u0010\u000b\"\u0004\b\f\u0010\r¨\u0006\u000e"},
d2 = {"Lgac/GTAnticheat$Companion;", "", "()V", "DEBUG", "", "getDEBUG", "()Z", "<set-?>", "Lgac/GTAnticheat;", "instance", "getInstance", "()Lgac/GTAnticheat;", "setInstance", "(Lgac/GTAnticheat;)V", "NukkitAC"}
)
public static final class Companion {
@NotNull
public final GTAnticheat getInstance() {
return GTAnticheat.access$getInstance$cp();
}
private final void setInstance(GTAnticheat var1) {
GTAnticheat.instance = var1;
}
public final boolean getDEBUG() {
return GTAnticheat.DEBUG;
}
private Companion() {
}
// $FF: synthetic method
public Companion(DefaultConstructorMarker $constructor_marker) {
this();
}
}
模糊的编译代码:(确实在工作)
public static final GTAnticheat.a a = new GTAnticheat.a;
// $FF: synthetic method
@NotNull
public static final GTAnticheat a() {
GTAnticheat var10000 = a;
if (a == null) {
Intrinsics.throwUninitializedPropertyAccessException("instance");
}
return var10000;
}
// $FF: synthetic method
public static final boolean a() {
return false;
}
@Metadata(
mv = {1, 1, 11},
bv = {1, 0, 2},
k = 1,
d1 = {"\u0000\u001c\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0006\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002R\u0014\u0010\u0003\u001a\u00020\u0004X\u0086D¢\u0006\b\n\u0000\u001a\u0004\b\u0005\u0010\u0006R$\u0010\t\u001a\u00020\b2\u0006\u0010\u0007\u001a\u00020\b@BX\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\b\n\u0010\u000b\"\u0004\b\f\u0010\r¨\u0006\u000e"},
d2 = {"Lgac/GTAnticheat$Companion;", "", "()V", "DEBUG", "", "getDEBUG", "()Z", "<set-?>", "Lgac/GTAnticheat;", "instance", "getInstance", "()Lgac/GTAnticheat;", "setInstance", "(Lgac/GTAnticheat;)V", "NukkitAC"}
)
public static final class a {
@NotNull
public static GTAnticheat b() {
return GTAnticheat.a();
}
private static void b(GTAnticheat var0) {
GTAnticheat.a = var0;
}
public static boolean b() {
return GTAnticheat.a();
}
private a() {
}
// $FF: synthetic method
public a(byte var1) {
}
}
如果我尝试运行混淆的jar,它将引发VerifyError https://hastebin.com/xipixihozi.sql
@Metadata批注是here
我对如何编译kotlin不太了解,但是正如您所看到的,有两种名为a()的方法在Java中是不允许的,而第三个与同伴无关。而且在创建伴侣实例的行上缺少“()”