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

Decompiling class files from Java bytecode source - switch issue #69

Open
ambergorzynski opened this issue Nov 27, 2023 · 0 comments
Open

Comments

@ambergorzynski
Copy link

Hello, I am running some tests in Java bytecode (using Jasmin) and attempting to decompile the resulting class files using Procyon. I have run into a problem whereby Procyon inserts unreachable break statements within switch statements. I understand that this is not the typical use case for Procyon but it would be interesting to know whether the decompilation failure is due to the bytecode switch statements being constructed in a way that is out-of-scope for Procyon, or something else.

Thanks!

Version info

Procyon decompiler 0.6.0
OpenJDK 19.0.2 2023-01-17
x86_64 Ubuntu 22.04

Example

A simple example bytecode file is below, which I compile to a class file (here: TestCase.zip).

.class public TestCase
.super java/lang/Object

; default constructor
.method public <init>()V
	aload_0
	invokespecial java/lang/Object/<init>()V
	return
.end method

.method public static main([Ljava/lang/String;)V
	.limit stack 5
	.limit locals 6

block_0:

    bipush 3

    ; switch
    lookupswitch
    	0: block_2
    	default : block_2

block_2:
   
    bipush 3

   ; switch
    lookupswitch
   	 0: block_3
   	 default: block_3

block_3:
   return
   	 
  	 
.end method

The decompiled Procyon output is this:

//
// Decompiled by Procyon v0.6.0
//

public class TestCase
{
	public static void main(final String[] array) {
    	switch (3) {
        	default: {
            	switch (3) {
                	default: {
                    	return;
                	}
            	}
            	break;
        	}
    	}
	}
}


Recompiling this gives the following error:

TestCase.java:15: error: unreachable statement
            	break;
            	^
1 error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant