是否有一些Kotlin文件的反编译器可以反编译成kotlin * .kt文件

问题描述 投票:1回答:1

我尝试学习如何反编译Android程序(APK),并发现此网站Decompilers online。它对java代码起作用,但是当有Kotlin文件代码时,反编译器产生java代码并且它混合了Kotlin和java。

这是我从文件ColorCircle.kt看到的。如你所见,Kotlin Lazy和其他Kotlin代码一样。我的问题是:Kotlin文件是否有其他反编译器反编译成kotlin * .kt文件? 我可以在*.java文件中进行Kotlin导入而没有问题吗?

package io.coolbe.vai.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;
import io.coolbe.vai.C1300R;
import java.util.HashMap;
import kotlin.Lazy;
import kotlin.Metadata;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.PropertyReference1Impl;
import kotlin.jvm.internal.Reflection;
import kotlin.reflect.KProperty;
import org.jetbrains.annotations.NotNull;

@Metadata(bv = {1, 0, 3}, d1 = {"\u0000>\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0007\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\u0018\u00002\u00020\u0001B\u000f\b\u0016\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004B\u0017\b\u0016\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0005\u001a\u00020\u0006¢\u0006\u0002\u0010\u0007J\u0010\u0010\u0014\u001a\u00020\u00152\u0006\u0010\u0016\u001a\u00020\u0017H\u0014R\u000e\u0010\b\u001a\u00020\tX\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\tX\u000e¢\u0006\u0002\n\u0000R\u001b\u0010\u000b\u001a\u00020\f8BX\u0002¢\u0006\f\n\u0004\b\u000f\u0010\u0010\u001a\u0004\b\r\u0010\u000eR\u000e\u0010\u0011\u001a\u00020\u0012X\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0013\u001a\u00020\tX\u000e¢\u0006\u0002\n\u0000¨\u0006\u0018"}, d2 = {"Lio/coolbe/vai/view/ColoredCircle;", "Landroid/view/View;", "context", "Landroid/content/Context;", "(Landroid/content/Context;)V", "attrs", "Landroid/util/AttributeSet;", "(Landroid/content/Context;Landroid/util/AttributeSet;)V", "offsetX", "", "offsetY", "paint", "Landroid/graphics/Paint;", "getPaint", "()Landroid/graphics/Paint;", "paint$delegate", "Lkotlin/Lazy;", "strokeColor", "", "strokeWidth", "onDraw", "", "canvas", "Landroid/graphics/Canvas;", "app_release"}, k = 1, mv = {1, 1, 13})
/* compiled from: ColoredCircle.kt */
public final class ColoredCircle extends View {
    static final /* synthetic */ KProperty[] $$delegatedProperties = new KProperty[]{Reflection.property1(new PropertyReference1Impl(Reflection.getOrCreateKotlinClass(ColoredCircle.class), "paint", "getPaint()Landroid/graphics/Paint;"))};
    private HashMap _$_findViewCache;
    private float offsetX;
    private float offsetY;
    private final Lazy paint$delegate;
    private int strokeColor;
    private float strokeWidth;

    private final Paint getPaint() {
        Lazy lazy = this.paint$delegate;
        KProperty kProperty = $$delegatedProperties[0];
        return (Paint) lazy.getValue();
    }

    public vaid _$_clearFindViewByIdCache() {
        HashMap hashMap = this._$_findViewCache;
        if (hashMap != null) {
            hashMap.clear();
        }
    }

    public View _$_findCachedViewById(int i) {
        if (this._$_findViewCache == null) {
            this._$_findViewCache = new HashMap();
        }
        View view = (View) this._$_findViewCache.get(Integer.valueOf(i));
        if (view != null) {
            return view;
        }
        view = findViewById(i);
        this._$_findViewCache.put(Integer.valueOf(i), view);
        return view;
    }

    public ColoredCircle(@NotNull Context context) {
        Intrinsics.checkParameterIsNotNull(context, "context");
        super(context);
        this.strokeColor = -7829368;
        this.strokeWidth = 10.0f;
        this.paint$delegate = LazyKt__LazyJVMKt.lazy((Function0) new ColoredCircle$paint$2(this));
    }

    public ColoredCircle(@NotNull Context context, @NotNull AttributeSet attributeSet) {
        Intrinsics.checkParameterIsNotNull(context, "context");
        Intrinsics.checkParameterIsNotNull(attributeSet, "attrs");
        super(context, attributeSet);
        this.strokeColor = -7829368;
        this.strokeWidth = 10.0f;
        this.paint$delegate = LazyKt__LazyJVMKt.lazy(new ColoredCircle$paint$2(this));
        context = context.getTheme().obtainStyledAttributes(attributeSet, C1300R.styleable.ColoredCircle, 0, 0);
        try {
            this.offsetX = context.getDimension(0, this.offsetX);
            this.offsetY = context.getDimension(1, this.offsetY);
            this.strokeColor = context.getColor(2, this.strokeColor);
            this.strokeWidth = context.getDimension(3, this.strokeWidth);
        } finally {
            context.recycle();
        }
    }

    protected vaid onDraw(@NotNull Canvas canvas) {
        Intrinsics.checkParameterIsNotNull(canvas, "canvas");
        super.onDraw(canvas);
        float f = (float) getLayoutParams().width;
        float f2 = (float) getLayoutParams().height;
        float f3 = (float) 2;
        float min = (Math.min(f, f2) / f3) - (this.strokeWidth / f3);
        canvas.save();
        canvas.translate(this.offsetX, this.offsetY);
        canvas.drawCircle(f / f3, f2 / f3, min, getPaint());
        canvas.restore();
    }
}
android kotlin decompiling
1个回答
2
投票

是否有其他反编译器为Kotlin文件反编译成kotlin * .kt文件?

目前,没有“舒适”的反编译器来做.class -> .kt

有几个着名的反编译器做.class -> .java,但它们只适合生成的字节码Java编译器。如果您尝试使用它们来反编译Kotlin生成的一些字节码,您可以看到奇怪的甚至是错误。这是由用于编写和编译Kotlin的一些技巧引起的。

然后,在大多数情况下,您不能直接使用反编译器输出。

我可以在* .java文件中进行Kotlin导入吗?

这是一个与"100% interoperable with the Java"有关的问题。 Kotlin可以在.java文件中导入几乎没有问题(我不确定当我们将Java Lambda传递给Kotlin时是否会有问题,但函数调用的常见方法肯定没有问题)。

© www.soinside.com 2019 - 2024. All rights reserved.