Skip to content

[core] Jadx generates incorrect code for NULL pointer #1828

@xxh160

Description

@xxh160

Hi! I am an undergraduate, and I am doing some research based on Jadx.

I found a problem related to the NULL pointer, and here is an example:

class T2 {
    public long l;
}
class T1<H, P extends Byte> {
    public T2 t2;
    public T1(T2 t2) {
        this.t2 = t2;
    }
}
public class Demo {
    static public final Long foo(Double d1) {
        T1<T2, Byte> t1 = (T1<T2, Byte>) null;
        return t1.t2.l;
    }
}

I decompiled the classes.dex the code above compiled into, and I got this:

package defpackage;
public class Demo {
    public static final Long foo(Double d) {
        return Long.valueOf(null.t2.l);
    }
}

The null.t2 raised a compilation error:

./out/sources/defpackage/Demo.java:6: error: <null> cannot be dereferenced
        return Long.valueOf(null.t2.l);
                                ^
1 error

Would you please take a look at this? It is important for me!
Thanks a lot!

Jadx version: the newest jadx binary in Arch Linux.
Java version: 11.0.18
I also attach the source files and the decompilation results and I hope they will be helpful: demo.zip.

Metadata

Metadata

Assignees

No one assigned

    Labels

    CoreIssues in jadx-core modulebug

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions