Kotlin Decompiler生成错误代码-是否可以防止? [英] Kotlin Decompiler generates erroneous code - Is it possible to prevent?

查看:75
本文介绍了Kotlin Decompiler生成错误代码-是否可以防止?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

class CheckInventory(target: Target) : Command(target) {

}

使用IntelliJ的 Show Kotlin字节码反编译上述Kotlin代码时,选项,它会继续在 super()调用上方生成一条语句:

When decompiling the above Kotlin code using the IntelliJ's "Show Kotlin bytecode" option, it keeps generating a statement above the super() call:

class CheckInventory extends Command {
    public CheckInventory(Target target) {
        Intrinsic.checkParameterIsNotNull(target, "target");
        super(target); //error, must be first call
    }
}

还有其他一些问题,例如使用WhenMapping的访问修饰符生成顶级类:

There are a few other issues, such as generating top-level classes with an access modifier for WhenMapping:

public class MyClass {

}

public final class MyClass$WhenMappings { //error, shouldn't be public

}

我同时检查了Kotlin和IntelliJ更新,并且我都使用了最新版本。

I checked for both Kotlin and IntelliJ updates, and I'm using the latest version for both.

起初,我认为这可能与编写不良的Kotlin代码有关,但即使最简单的代码文件似乎也需要某种检查/生成,这在Java中是非法的。

At first I thought it may had to do with poorly written Kotlin code, but even the simplest code files seem to require some sort of check/generation that's illegal in Java.

有什么方法可以确保

推荐答案

否。 IntelliJ IDEA中的Java反编译器旨在反编译Java源代码。 Kotlin编译器与Java编译器会生成不同的字节码模式,因此Java反编译器并不总是生成有效的Java代码的输出。

No. The Java decompiler in IntelliJ IDEA is designed for decompiling Java source code. The Kotlin compiler generates different bytecode patterns from the Java compiler, so the Java decompiler does not always produce output which is valid Java code.

这篇关于Kotlin Decompiler生成错误代码-是否可以防止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆