-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to not inline inner classes? #139
Comments
Hey @andrewleech (sorry, I'm a little backed up on issues, heh). Do you have an example case? I don't have any current flags to stop this (because it's not the sort of thing that I've seen in the wild) - however I can certainly imagine it happening.... A synthetic example to add to the test cases (i.e. not something with copyright attached) would help! Cheers! |
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. 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 :-) |
Ahhhhhhhh - I see - so - this SHOULD be totally impossible - this is an anonymous class, i.e. it can only be created at the call site. So I guess at this point, it's necessary to detect that an anonymous inner class is being used 'illegally', and instead give it an explicit name..... ( i.e. your point about |
K - so I'm not a huge fan of options that can't be automatically set by recovery passes - I think it's possible to detect anonymous classes being abused, but it's suprisingly impractical. Also, because of the propagation of the hidden instance variables, this is never going to generate "nice" code ;). So I've added a couple of new options, but they WON'T be used by recovery passes - they are explicit.
These generate
and
|
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! |
Hi,
I'm the dexpatcher user that started the discussion in DexPatcher/dexpatcher-tool#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:However cfr is inlining the inner class
a
into the outer class function that uses it.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.The text was updated successfully, but these errors were encountered: