Skip to content
/ Recaf Public

ALOAD 0 instead of ALOAD THIS #137

@artemking4

Description

@artemking4

While opening the code in Assembler shows me ALOAD 0 instead of ALOAD THIS, and after saving this code the decompiler gets weird, but on runtime this seems to work.

Example:
Function in assembler:
ALOAD 0 FLOAD 1 INVOKEVIRTUAL com/desertkun/brainout/AuX/aux/jh.setX(F)V ALOAD 0 FLOAD 2 INVOKEVIRTUAL com/desertkun/brainout/AuX/aux/jh.setY(F)V RETURN

Function in decompiler:
public void setPosition(float f2, float f3) { this.setX(f2); this.setY(f3); }

Function after saving:
public void setPosition(float f2, float f3) { jh jh2; jh2.setX(f2); jh2.setY(f3); }

To Reproduce
Steps to reproduce the behavior:

  1. Open any function that uses 'this'
  2. Open it in assembler
  3. (You can just press space at the end of file) change something
  4. Save and decompile

Activity

Col-E

Col-E commented on Jun 17, 2019

@Col-E
Owner

If ALOAD 0 is being emitted, then the local variable debug table does not have the name for the 0th variable set to this. However since this is a common case I'll add a condition to make sure this is used.

Note: ALOAD 0 and ALOAD this (this is all lower-case) are the same if the method is not static.

Note: When sharing multi-line code snippets you can use the following for better formatting: (Remove that first \ shown below)

\```
code
with
lines
\```
Col-E

Col-E commented on Jun 17, 2019

@Col-E
Owner

Labeling enhancement for since this behavior of 0 vs this isn't a bug.
Labeling bug because of the wrong decompilation, which is likely caused by the fact that the assembler isn't properly regenerating the type of this in the local variable table after the assembly is saved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @artemking4@Col-E

        Issue actions