question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Option to not inline inner classes?

See original GitHub issue

Hi, I’m the dexpatcher user that started the discussion in https://github.com/DexPatcher/dexpatcher-tool/issues/33

Thanks so much for the patch made in response to that!

I’m testing out a build from master with that, hoping to compare the difference with the new checks vs --usesignatures however I’m running into some decompilation failures with other parts of the app.

The new issue seems to be caused by an inner class (obfuscated to the name a06$a) being inlined. One of this inner class’ functions then tries to create an instance of itself and cfr responds with ig62 = new /* invalid duplicate definition of identical inner class */;

I more often work with jadx with the arg --no-inline-anonymous to keep inline classes in their separate named form. The decompilation from that looks a little like:

public final class a06 extends td {
    public static final class a extends sf6 implements ig6<il6, xe6<? super cd6>, Object> {
        public final xe6<cd6> create(Object obj, xe6<?> xe6) {
            a aVar = new a(this.this$0, this.$block, xe6);
        }
    }
}

However cfr is inlining the inner class a into the outer class function that uses it.

public final class a06 extends td {
    public final rm6 a(hg6<? super xe6<? super List<DebugFirmwareData>>, ? extends Object> hg62) {
        return gk6.b((il6)jl6.a((af6)zl6.a()), null, null, (ig6)new ig6<il6, xe6<? super cd6>, Object>((a06)this, hg62, null){

            public final xe6<cd6> create(Object object, xe6<?> ig62) {
                ig62 = new /* invalid duplicate definition of identical inner class */;
            }
        }
    }
}

Is there an arg for CFR to not inline inner classes? I’ve tried a lot from --help but haven’t found anything that works.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
andrewleechcommented, Apr 28, 2020

Hi, no pressure on backlog I know exactly what it’s like!

I seem to have crafted a test case that represents it, I think the key features are the inner class with a function that needs to create another instance of the same inner class. jadx:

package com.test;

public final class outer {

    public static final class inner {
        public final Object create(Object obj) {
            return new inner(this.this$0);
        }
    }

    public final Object func() {
        return new inner(this);
    }
}

cfr:

/*
 * Decompiled with CFR 0.150-SNAPSHOT.
 */
package com.test;

public final class outer {
    public final Object func() {
        return new Object(this){

            public final Object create(Object object) {
                return new /* invalid duplicate definition of identical inner class */;
            }
        };
    }
}

jar attached 😃 testcase-inner-recursive.zip

0reactions
andrewleechcommented, May 17, 2020

Very interesting, I wonder how the original code was generated this way! Thanks for the added options though, that sounds perfect. I’ll give them a try next time I rework my project!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java inner class and static nested class - Stack Overflow
A nested class could be nonstatic or static and in each case is a class defined within another class. A nested class should...
Read more >
Nested Classes - Learning the Java Language
A nested class is a member of its enclosing class. Non-static nested classes (inner classes) have access to other members of the enclosing...
Read more >
Anonymous Inner Class in Java - GeeksforGeeks
Like local classes, anonymous classes can capture variables; they have the same access to local variables of the enclosing scope: An anonymous  ......
Read more >
Java Inner Class | DigitalOcean
Any non-static nested class is known as inner class in java. Java inner class is associated with the object of the class and...
Read more >
Refactor inner class to its own class
There is a "Extract Class..." option in the refactor menu which sounded promising but it appears to be aimed at extracting a handul...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found