intellij-community icon indicating copy to clipboard operation
intellij-community copied to clipboard

Field Declaration Order Fix for Fernflower

Open jonatino opened this issue 9 years ago • 11 comments

This fixes an issue I had when decompiling an obfuscated class. (testData/classes/pkg/Class8.class).

Fernflower did not properly order the fields in which the order they are initialized therefore causing the program to break.

Ex:

Output from Fernflower (no field sorting DOESNT WORK):

    int anInt140 = Class126_Sub5.method1715(24) + 1;

    int anInt141 = Class126_Sub5.method1715(24);

    int anInt142 = Class126_Sub5.method1715(24);

    int anInt143 = Class126_Sub5.method1715(8);

    int anInt144 = Class126_Sub5.method1715(6) + 1;

    int anInt145 = Class126_Sub5.method1715(16);

    int[] anIntArray146;

Output from Fernflower (with field sorting WORKING):

   int anInt145 = Class126_Sub5.method1715(16);

   int anInt141 = Class126_Sub5.method1715(24);

   int anInt142 = Class126_Sub5.method1715(24);

   int anInt140 = Class126_Sub5.method1715(24) + 1;

   int anInt144 = Class126_Sub5.method1715(6) + 1;

   int anInt143 = Class126_Sub5.method1715(8);

   int[] anIntArray146;

jonatino avatar Apr 21 '16 21:04 jonatino

Have you submitted a contributor license agreement? If not, please download the PDF from http://www.jetbrains.org/display/IJOS/Contributor+Agreement and then print it out, sign (mention you github account name there), scan and email to [email protected]

klikh avatar Apr 25 '16 13:04 klikh

I've just completed the required documentation and sent it in via email. I'm excited to start helping the community :)

jonatino avatar Apr 25 '16 18:04 jonatino

We've received the CLA. Thanks.

klikh avatar Apr 25 '16 18:04 klikh

Hi, you've added fdo preference to control this, any ideas when it shouldn't be turned on?

gorrus avatar Jun 03 '16 10:06 gorrus

Please also add a test into SingleClassesTest with the corresponding .dec file (and preferably .java source).

gorrus avatar Jun 03 '16 10:06 gorrus

@Jonatino any updates on this?

gorrus avatar Apr 19 '17 10:04 gorrus

@gorrus I completely forgot about this. Looking at it now I bet there is a much more elegant solution. I will work on it soon.

jonatino avatar Apr 19 '17 22:04 jonatino

Any updates on this? It would be extremely helpful to have this fix merged in because it fixes a major issue that I'm dealing with and frustratingly I'm my restricted to only using master branches... @Jonatino @gorrus

ccarpenter04 avatar Sep 11 '17 05:09 ccarpenter04

@ccarpenter04 I keep forgetting about this issue. I'll finish it within the next couple days. 👍

jonatino avatar Sep 11 '17 13:09 jonatino

@Jonatino I'd really appreciate that, contact me if there's anyway that I can help. I've worked with the fernflower source in the past and have also signed the CLA here exclusively for making contributions to fernflower (although it's been a while)

ccarpenter04 avatar Sep 11 '17 16:09 ccarpenter04

@ccarpenter04 Do you have any example of .class files that current Fernflower doesn't sort fields in the order they are initialized in bytecode? Would help me with testing :)

jonatino avatar Sep 12 '17 15:09 jonatino