quarantin / beautiful-java

This is a tool to help reverse-engineering Java code. It's meant to help with reversing the source code from the game Project Zomboid.
GNU Affero General Public License v3.0
15 stars 2 forks source link

Fernflower errors #1

Open Poltergeist-ix opened 1 year ago

Poltergeist-ix commented 1 year ago

IntelliJ IDEA 2023.1.2 (Community Edition) - Build #IC-231.9011.34, built on May 16, 2023 Project Zomboid .41.78.16

Error while decompiling:

Decompiling class zombie/AmbientStreamManager
WARN:           Method addRandomAmbient ()V couldn't be decompiled.
java.lang.NullPointerException: Cannot read field "type" because the return value of "org.jetbrains.java.decompiler.modules.decompiler.exps.InvocationExprent.getInstance()" is null
        at org.jetbrains.java.decompiler.modules.decompiler.SwitchHelper$SwitchRecognizer$JavacRecognizer.recognize(SwitchHelper.java:268)
        at org.jetbrains.java.decompiler.modules.decompiler.SwitchHelper.collectSwitchesOnString(SwitchHelper.java:67)
        at org.jetbrains.java.decompiler.modules.decompiler.SwitchHelper.collectSwitchesOnString(SwitchHelper.java:80)
        at org.jetbrains.java.decompiler.modules.decompiler.SwitchHelper.collectSwitchesOnString(SwitchHelper.java:80)
        at org.jetbrains.java.decompiler.modules.decompiler.SwitchHelper.collectSwitchesOnString(SwitchHelper.java:80)
        at org.jetbrains.java.decompiler.modules.decompiler.SwitchHelper.collectSwitchesOnString(SwitchHelper.java:80)
        at org.jetbrains.java.decompiler.modules.decompiler.SwitchHelper.collectSwitchesOnString(SwitchHelper.java:80)
        at org.jetbrains.java.decompiler.modules.decompiler.SwitchHelper.collectSwitchesOnString(SwitchHelper.java:80)
        at org.jetbrains.java.decompiler.modules.decompiler.SwitchHelper.simplifySwitchesOnString(SwitchHelper.java:50)
        at org.jetbrains.java.decompiler.main.rels.MethodProcessorRunnable.codeToJava(MethodProcessorRunnable.java:202)
        at org.jetbrains.java.decompiler.main.rels.ClassWrapper.init(ClassWrapper.java:64)
        at org.jetbrains.java.decompiler.main.ClassesProcessor.initWrappers(ClassesProcessor.java:396)
        at org.jetbrains.java.decompiler.main.ClassesProcessor.writeClass(ClassesProcessor.java:350)
        at org.jetbrains.java.decompiler.main.Fernflower.getClassContent(Fernflower.java:114)
        at org.jetbrains.java.decompiler.struct.ContextUnit.save(ContextUnit.java:100)
        at org.jetbrains.java.decompiler.struct.StructContext.saveContext(StructContext.java:57)
        at org.jetbrains.java.decompiler.main.Fernflower.decompileContext(Fernflower.java:87)
        at org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler.decompileContext(ConsoleDecompiler.java:120)
        at org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler.main(ConsoleDecompiler.java:82)

File output

   public void addRandomAmbient() {
      // $FF: Couldn't be decompiled
   }
quarantin commented 1 year ago

Looks like the IntelliJ decompiler is failing there. Does it work if you try from IntelliJ?

Poltergeist-ix commented 1 year ago

It used to work until I updated Intellij some time this year.

quarantin commented 1 year ago

I would try to delete your IntelliJ, fetch new version online and just unzip to the same location (update your beautiful java config accordingly in case the folder name changed). Then it should work. There's still a few class that can't be fully decompiled. I'll have to fix the broken java code from pz to make the decompiler work better. Just let me know if some piece of code you need can't be decompiled

Poltergeist-ix commented 1 year ago

Thank you, hopefully Intellij or PZ fixes this by the time the next version is released.

quarantin commented 1 year ago

So you got it working?

Poltergeist-ix commented 1 year ago

No.

There's still a few class that can't be fully decompile

This is what I had before. I tried reinstalling when I first encountered the issue.

However, I have the files from when I decompiled before I updated Intellij.

CyberSys commented 1 year ago

Can you tell plz which version did you use before?

quarantin commented 1 year ago

@Poltergeistzx Have you tried to compare the java version shipped with IntelliJ with the one pz is using?

Poltergeist-ix commented 1 year ago

I've tried with different versions of java. The problem seems to be fernflower update.

https://github.com/fesh0r/fernflower/commits/master

They made some changes in Feb and Jan that I think cause the issue.

Poltergeist-ix commented 1 year ago

For java I now use Azul Zulu 17.0.7

The version of intellij worked was one from last year, I don't have more details about that.

quarantin commented 1 year ago

It really sounds like a regression on IntelliJ side. Do you know if this issue is tracked somewhere? Except for the wrapping around, BeautifulJava is simply processing the output of their decompiler basically, so there's not much I can do about it.