jadx icon indicating copy to clipboard operation
jadx copied to clipboard

[java-input] Negative register number

Open Mister-leo opened this issue 6 months ago • 2 comments

Issue details

When i decompile the aar file, Jadx compliant the next information。

    /*  JADX ERROR: JadxRuntimeException in pass: CheckCode
        jadx.core.utils.exceptions.JadxRuntimeException: Incorrect negative register number in instruction: 0x0047: RETURN (r-1 I:iv)
        	at jadx.core.dex.visitors.CheckCode.checkInstructions(CheckCode.java:76)
        	at jadx.core.dex.visitors.CheckCode.visit(CheckCode.java:33)
        */

Relevant log output or stacktrace

jadx.core.utils.exceptions.JadxRuntimeException: Incorrect negative register number in instruction: 0x0420: SWITCH (r-1 I:??)
 case 3: goto 0x00c4
 case 56: goto 0x0371
 default: goto 0x00c4
	at jadx.core.dex.visitors.CheckCode.checkInstructions(CheckCode.java:76)
	at jadx.core.dex.visitors.CheckCode.visit(CheckCode.java:33)
	at jadx.core.dex.visitors.DepthTraversal.visit(DepthTraversal.java:25)
	at jadx.core.dex.visitors.DepthTraversal.lambda$visit$1(DepthTraversal.java:13)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at jadx.core.dex.visitors.DepthTraversal.visit(DepthTraversal.java:13)
	at jadx.core.ProcessClass.process(ProcessClass.java:74)
	at jadx.core.ProcessClass.generateCode(ProcessClass.java:117)
	at jadx.core.dex.nodes.ClassNode.generateClassCode(ClassNode.java:403)
	at jadx.core.dex.nodes.ClassNode.decompile(ClassNode.java:391)
	at jadx.core.dex.nodes.ClassNode.decompile(ClassNode.java:311)
	at jadx.gui.treemodel.JClass.lambda$getLoadTask$0(JClass.java:86)
	at jadx.core.utils.tasks.TaskExecutor.wrapTask(TaskExecutor.java:168)
	at jadx.core.utils.tasks.TaskExecutor.runStages(TaskExecutor.java:143)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:842)
WARN : Code restructure failed: missing block: B:20:?, code lost:


Provide sample and class/method full name

    public static synchronized defpackage.iv a(android.content.Context r5) {
        /*
            goto L3d
        L5:
            r0 = r5
            if (r0 != 0) goto Le
            goto L13
        Le:
            goto L15
        L13:
            r0 = 0
            return r0
        L15:
            iv r0 = defpackage.iv.j
            if (r0 != 0) goto L20
            goto L25
        L20:
            goto L35
        L25:
            iv r0 = new iv
            r1 = r0
            r2 = r5
            r1.<init>(r2)
            defpackage.iv.j = r0
            goto L35
        L35:
            iv r0 = defpackage.iv.j
            goto L77
        L3d:
            r0 = 2
            r1 = 2
            int r0 = r0 % r1
            goto L48
        L46:
            return r-1
        L48:
            int r0 = defpackage.iv.t
            r1 = 97
            int r0 = r0 + r1
            r1 = r0
            r2 = 128(0x80, float:1.794E-43)
            int r1 = r1 % r2
            defpackage.iv.w = r1
            r1 = 2
            int r0 = r0 % r1
            if (r0 != 0) goto L60
            goto Ldf
        L60:
            goto Ld8
        L65:
            throw r0
        L66:
            r0 = r5
            r1 = 0
            int r1 = r1.length     // Catch: java.lang.Throwable -> L65
            if (r0 != 0) goto L72
            goto Lb6
        L72:
            goto Lb0
        L77:
            int r1 = defpackage.iv.w     // Catch: java.lang.Throwable -> L65
            r2 = 85
            int r1 = r1 + r2
            r2 = r1
            r3 = 128(0x80, float:1.794E-43)
            int r2 = r2 % r3
            defpackage.iv.t = r2
            r2 = 2
            int r1 = r1 % r2
            if (r1 == 0) goto L8f
            goto L94
        L8f:
            goto L46
        L94:
            goto L46
        L99:
            switch(r0) {
                case 0: goto L15;
                case 1: goto L13;
                default: goto L15;
            }
        Lb0:
            r0 = 0
            goto L99
        Lb6:
            r0 = 1
            goto L99
        Lbc:
            switch(r0) {
                case 36: goto L66;
                case 57: goto L5;
                default: goto L5;
            }
        Ld8:
            r0 = 57
            goto Lbc
        Ldf:
            r0 = 36
            goto Lbc
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.iv.a(android.content.Context):iv");
    }

Jadx version

1.5.2

Mister-leo avatar Jun 17 '25 06:06 Mister-leo

@Mister-leo please share a sample aar, jar or class file. Without a sample I will not be able to reproduce and fix this issue.

Also as a workaround you can try switching to dx/d8 conversion with Preferences -> Decompile -> Use dx/d8 to convert java bytecode or --use-dx in jadx-cli.

skylot avatar Jun 17 '25 21:06 skylot

@Mister-leo please share a sample aar, jar or class file. Without a sample I will not be able to reproduce and fix this issue.

Also as a workaround you can try switching to dx/d8 conversion with Preferences -> Decompile -> Use dx/d8 to convert java bytecode or --use-dx in jadx-cli.

gh.class.zip This is the sample class

Mister-leo avatar Jun 25 '25 03:06 Mister-leo