leibnitz27 / cfr

This is the public repository for the CFR Java decompiler
https://www.benf.org/other/cfr
MIT License
2.01k stars 259 forks source link

Local variable names in lambdas can collide when using --usenametable false #59

Open Marcono1234 opened 4 years ago

Marcono1234 commented 4 years ago

CFR version

0.149-SNAPSHOT (commit 06539a4)

Description

When decompiling with --usenametable false, it is possible that the local variable name inside a lamba is the same as the name of a variable in the enclosing method.

Example code

public class LambdaNameCollision {
    void test() {
        String string = "";

        Runnable r = () -> {
            // Becomes `string` as well
            String s = System.getProperty("key");
        };
    }
}
leibnitz27 commented 4 years ago

Nasty. That's going to require a pretty savage renaming pass, as names for locals are generated at the point they're separate methods, before bootstrap elimination & inlining.