ecd-plugin / ecd

An Eclipse Plugin to integrate different Class Decompiler seamlessly into the development workflow
Eclipse Public License 1.0
258 stars 58 forks source link

CFR option uses FernFlower #87

Open TheKodeToad opened 1 year ago

TheKodeToad commented 1 year ago

This is quite weird, and also quite annoying since CFR is one of the better decompilers. The decompilation report also has no decompiler present, like it's some kind of fallback.


/*
    DECOMPILATION REPORT

    Decompiled from: /my/jar/file.jar
    Total time: 11 ms

*/
jpstotz commented 1 year ago

The decompiler names were simply missing for some decompilers. I added them in fd5ef2de5624061cd59cb0e1b98b31ae92971d4a

But I wasn't able to reproduce your problem with CFR/FernFlower. Neither when I set CFR as default decompiler nor when I manually select a class to be decompiled by CFR it was always CFR decompiler used.

As FernFlower already had it's name in the DECOMPILATION REPORT I would assume that the used decompiler was really CFR and not FernFlower.

TheKodeToad commented 1 year ago

For me it is definitely FernFlower being used, as #88 was also an issue and the output identical.

jpstotz commented 1 year ago

Which ECD and Eclipse version do you use?

TheKodeToad commented 1 year ago

ECD 3.2.2 on Eclipse IDE for Java Developers 2022-06. This seems to be the latest stable version.

In some cases there are some comments in this format

// $FF: Mission failed
jpstotz commented 1 year ago

Could you please test the latest version ECD 3.3.0?

TheKodeToad commented 1 year ago

It still has the same issue.

jpstotz commented 1 year ago

Just to make sure please to the following:

  1. Make sure you are not in Debug perspective in Eclipse (no decompilation repot when in Debug perspective).
  2. Open a project and there got to the referenced libraries
  3. Select a class file and open it's context menu and select Open Class With-> CFR
TheKodeToad commented 1 year ago

Yep, same thing is happening

jpstotz commented 1 year ago

Can you please describe in detail what "same thing happens" means?

What actual decompiled code do you get? Would it be possible that you upload the Jar file or the class file(s) you try to decompile or a sample Eclipse project/workspace?

TheKodeToad commented 1 year ago

In this case I was testing with Gradle's API, and I got the same decompiled code with both CFR and FernFlower!

jpstotz commented 1 year ago

I finally found the code that causes fallback to FernFlower: https://github.com/ecd-plugin/ecd/blob/master/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/BaseDecompilerSourceMapper.java#L160-L168

Looks like this happens if the selected decompiler has not returned any decompiled code.

jpstotz commented 3 months ago

The reason for this behavior is that CFR has no option to provide code where the line numbers match the original line numbers (thus the code is useful for debugging).

Therefore ECD does not make use of CFR in debugger mode (debugging perspective?). But it seems that the debugger detection doesn't work as expected in some Eclipse versions. If you try to use CFR in debugging mode, then it will fall back to a different decompiler like FernFlower.

nbauma109 commented 1 month ago

See also this discussion on CFR: https://github.com/leibnitz27/cfr/issues/73