Col-E / Col-E/Recaf

"Goto definition" in decompiler mode may not match bytecode reference due to name shadowing

Open
#389 5 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
Java
Stars
7.4k
Forks
538
PR merge metrics
No merged PRs in 30d

Description

While I was working on an obfuscated jar, I found a bug that causes you to find yourself in a random class that is not even relevant to what you would expect. Let me introduce a few images to explain.

I was on a pretty clean class and I though there was no problem to use "Goto definiton" option.
![image](https://user-images.githubusercontent.com/69322376/119928040-71744b80-bf83-11eb-93cb-1767c1beae45.png)

I used it and... I was here...
![image](https://user-images.githubusercontent.com/69322376/119928145-ada7ac00-bf83-11eb-8371-20e29c3d392c.png)
I was expecting a Packet class but I found a Predicate, my mind just blowed first time I faced this bug

Fortunately, I found a way to find the actual class after I let go of my persistent thoughts about a "clean class". I just opened it in the assembler.
![image](https://user-images.githubusercontent.com/69322376/119929321-f2ccdd80-bf85-11eb-981c-0dcccaab0672.png)
It was the actual class. But it was in the **default package**. This is where the problem starts...
As Java do not allow importing classes in **default package** from a non-default package class and the other way around (since Java 1.5), we can't import like that. So, CFR couldn't put the import statement of that class. But Recaf somehow recognizes this class as a **same-package** class I guess (because there is no import statement for that) and redirects me to the **same-package**d class. (Both Predicate class named **j1** and it's initializer class are in the `net.minecraft` package)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.