Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BytecodeListing.java:34-38: Decompile Bytecode Listing.... #865

Open
0pdd opened this issue Nov 13, 2024 · 5 comments
Open

BytecodeListing.java:34-38: Decompile Bytecode Listing.... #865

0pdd opened this issue Nov 13, 2024 · 5 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers not urgent

Comments

@0pdd
Copy link

0pdd commented Nov 13, 2024

The puzzle 845-380c5294 from #845 has to be resolved:

* @todo #845:90min Decompile Bytecode Listing.
* Currently we print bytecode listing to XMIR without decompiling it.
* It's just raw, but human-readable bytecode.
* We can make one step forward and try to decompile this code to Java.
* This would be a great improvement for readability of this listing.

The puzzle was created by volodya-lombrozo on 13-Nov-24.

Estimate: 90 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

@h1alexbel
Copy link
Contributor

@volodya-lombrozo can I take this?

@volodya-lombrozo
Copy link
Member

@h1alexbel sure! Please, go ahead.

@h1alexbel
Copy link
Contributor

h1alexbel commented Nov 20, 2024

@volodya-lombrozo should we decompile bytecode listing obtained after ASM transformation? For instance, this is the listing for MethodByte.class:

// class version 55.0 (55)
// access flags 0x21
public class org/eolang/jeo/MethodByte {

  // compiled from: MethodByte.java

  // access flags 0x1
  public <init>()V
   L0
    LINENUMBER 3 L0
    ALOAD 0
    INVOKESPECIAL java/lang/Object.<init> ()V
    RETURN
    MAXSTACK = 1
    MAXLOCALS = 1

  // access flags 0x9
  public static main([Ljava/lang/String;)V
   L0
    LINENUMBER 5 L0
    GETSTATIC java/lang/System.out : Ljava/io/PrintStream;
    INVOKESTATIC org/eolang/jeo/MethodByte.method ()B
    INVOKEVIRTUAL java/io/PrintStream.println (I)V
   L1
    LINENUMBER 6 L1
    GETSTATIC java/lang/System.out : Ljava/io/PrintStream;
    LDC "passed"
    INVOKEVIRTUAL java/io/PrintStream.println (Ljava/lang/String;)V
   L2
    LINENUMBER 7 L2
    RETURN
    MAXSTACK = 2
    MAXLOCALS = 1

  // access flags 0x8
  static method()B
   L0
    LINENUMBER 9 L0
    BIPUSH 52
    IRETURN
    MAXSTACK = 1
    MAXLOCALS = 0
}

or we should decompile the original bytecode instead? This is original MethodByte.class:

package org.eolang.jeo;

public class MethodByte {
    public MethodByte() {
    }

    public static void main(String[] var0) {
        System.out.println(method());
        System.out.println("passed");
    }

    static byte method() {
        return 52;
    }
}

@h1alexbel
Copy link
Contributor

h1alexbel commented Nov 20, 2024

@volodya-lombrozo Also, I think we can maintain both listings: <listing/> (bytecode listing), and <decompiled/> (decompiled Java code). WDYT?

@volodya-lombrozo
Copy link
Member

@h1alexbel I've already added bytecode listing, as you can see. The purpose of this issue is to try to decompile it to a Java, or at least to try it. We can do it by using https://github.com/fesh0r/fernflower or https://github.com/Storyyeller/Krakatau, or something else.

As for <decompiled/>, we just can't add it, we are limited by XMIR format that allows only <listing/>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers not urgent
Projects
None yet
Development

No branches or pull requests

3 participants