vineflower icon indicating copy to clipboard operation
vineflower copied to clipboard

Error while decompiling

Open DenaryDev opened this issue 2 years ago • 2 comments

I am using QuiltFlower Plugin for Intellij IDEA

The error is below (I don't have the source code):

    public static void a(String param0) {
        // $FF: Couldn't be decompiled
        // Please report this to the Quiltflower issue tracker, at https://github.com/QuiltMC/quiltflower/issues with a copy of the class file (if you have the rights to distribute it!)
        // java.lang.RuntimeException: parsing failure!
        //   at org.jetbrains.java.decompiler.modules.decompiler.DomHelper.parseGraph(DomHelper.java:203)
        //   at org.jetbrains.java.decompiler.main.rels.MethodProcessorRunnable.codeToJava(MethodProcessorRunnable.java:130)
        //
        // Bytecode:
        // 00: getstatic _/bJ.a Ljava/util/List;
        // 03: dup
        // 04: astore 2
        // 05: monitorenter
        // 06: new java/util/ArrayList
        // 09: dup
        // 0a: getstatic _/bJ.a Ljava/util/List;
        // 0d: invokespecial java/util/ArrayList.<init> (Ljava/util/Collection;)V
        // 10: astore 1
        // 11: getstatic _/bJ.a Ljava/util/List;
        // 14: invokeinterface java/util/List.clear ()V 1
        // 19: aload 2
        // 1a: monitorexit
        // 1b: getstatic _/bJ.a I
        // 1e: bipush 1
        // 1f: iadd
        // 20: getstatic _/bJ.a I
        // 23: bipush 1
        // 24: iadd
        // 25: ifeq 1e
        // 28: ifne 31
        // 2b: return
        // 2c: astore 3
        // 2d: aload 2
        // 2e: monitorexit
        // 2f: aload 3
        // 30: athrow
        // 31: aload 1
        // 32: aload 0
        // 33: invokestatic _/cY.a (Ljava/util/List;Ljava/lang/String;)V
        // 36: return
        // 37: invokevirtual java/lang/Throwable.printStackTrace ()V
        // 3a: return
        // 3b: invokevirtual java/lang/Throwable.getCause ()Ljava/lang/Throwable;
        // 3e: invokevirtual java/lang/Throwable.printStackTrace ()V
        // 41: getstatic _/bJ.a I
        // 44: bipush 1
        // 45: iadd
        // 46: ifeq 11
        // 49: getstatic _/bJ.a I
        // 4c: ifne 36
        // 4f: getstatic _/bJ.a I
        // 52: bipush 1
        // 53: iadd
        // 54: ifeq 1b
        // 57: getstatic _/bJ.a I
        // 5a: ifne 19
        // 5d: return
        // 5e: invokevirtual java/lang/Throwable.printStackTrace ()V
        // 61: return
        // 62: invokevirtual java/lang/Throwable.getCause ()Ljava/lang/Throwable;
        // 65: invokevirtual java/lang/Throwable.printStackTrace ()V
        // 68: return
        // 69: invokevirtual java/lang/Throwable.printStackTrace ()V
        // 6c: return
        // 6d: invokevirtual java/lang/Throwable.printStackTrace ()V
        // 70: return
        // 71: invokevirtual java/lang/Throwable.getCause ()Ljava/lang/Throwable;
        // 74: invokevirtual java/lang/Throwable.printStackTrace ()V
        // 77: return
        // 78: invokevirtual java/lang/Throwable.printStackTrace ()V
        // 7b: return
        // 7c: invokevirtual java/lang/Throwable.printStackTrace ()V
        // 7f: return
        // 80: invokevirtual java/lang/Throwable.getCause ()Ljava/lang/Throwable;
        // 83: invokevirtual java/lang/Throwable.printStackTrace ()V
        // 86: return
    }

DenaryDev avatar May 19 '22 21:05 DenaryDev

Looking at the bytecode in the error message, I can already tell you that that code is heavily obfuscated. My best guess at a decompilation by hand is

public static void a(String param0) {
  List var1;
  synchronized(_.bJ.aList) {
    var1 = new ArrayList(_.bJ.aList);
    _.bJ.aList.clear();
  }

  _.cY.a(var1, param0);
}

I did rename the list cause BJ has multiple a fields.

The problem is (most likely) that this code relies on an integer static field, which I assume is always 0. This isn't something we can rely upon in the QuitFlower code, and as a result, it has to take many more branches and exception handlers into account who jump all over the place, both inside and outside the synchronized statement, which is probably where it finally dies.

However to be absolutely sure and to try make a more graceful failure case it would be helpful to have a class file of this class, as the error doesn't provide us with the exception ranges which are quite important here. If you can't share it, due to copyright reasons, we'll try to build our own version.

Kroppeb avatar May 19 '22 22:05 Kroppeb

I put bJ.class in a zip archive bJ.zip

What types of obfuscation are there? Are there programs to deobfuscate them?

DenaryDev avatar May 20 '22 08:05 DenaryDev

There is javadeobfuscator. I don't really have any experience with it, and I think it needs the full jar to work with, so I can't test it myself.

Kroppeb avatar May 20 '22 19:05 Kroppeb

Full jar in zip archive: pl-mod.zip

DenaryDev avatar May 20 '22 22:05 DenaryDev