0

I use JAD to decompile Java .class files.

It works fine for this program here:

class HelloWorldPlain {
  public static void main(String[] paramArrayOfString) {
    System.out.println("Hello, World!");
  }
}

Compiles nicely, runs nicely, decompiles nicely:

$ javac HelloWorldPlain.java && java HelloWorldPlain
Hello, World!
✓

$ jad -p HelloWorldPlain.class
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)
// Source File Name:   HelloWorldPlain.java

import java.io.PrintStream;

class HelloWorldPlain
{

    HelloWorldPlain()
    {
    }

    public static void main(String args[])
    {
        System.out.println("Hello, World!");
    }
}
✓

But it fails for this program here:

class HelloWorldLambda {
  public static void main(String[] paramArrayOfString) {
    System.out.println("Hello, World!");
    StringFunction stringFunction = paramString -> "Hello, " + paramString + "!";
    printwithlambda("Lambda functions", stringFunction);
  }
  
  public static void printwithlambda(String paramString, StringFunction paramStringFunction) {
    String str = paramStringFunction.run(paramString);
    System.out.println(str);
  }
}

Compiles nicely, runs nicely, does NOT decompile:

$ javac HelloWorldLambda.java && java HelloWorldLambda
Hello, World!
Hello, Lambda functions!
✓

$ jad -p HelloWorldLambda.class
JavaClassFileParseException: Invalid tag value 0x12
✗
StackzOfZtuff
  • 2,534
  • 1
  • 28
  • 25

1 Answers1

1

JAD is too old for Java Lambda expressions

Answering my own question.

JAD is very old. Java 8 in 2014 introduced Lambda expressions. And inside the compiled Java class files they will generate a constant called CONSTANT_InvokeDynamic with value 0x12 (or 18 in decimal). (So this 18 in java.io.IOException: invalid constant type: 18 in another question also refers to this same thing.)

JAD can not handle this and fails.

Try a newer decompiler. JD-CLI works fine for my example.

StackzOfZtuff
  • 2,534
  • 1
  • 28
  • 25