vineflower icon indicating copy to clipboard operation
vineflower copied to clipboard

Inconsistent renaming when LVT entries clash

Open PiTheGuy opened this issue 2 months ago • 0 comments

Vineflower version

1.11.1

Describe the bug

Conflicting LVT's within inner classes can cause variable references to reference the wrong variable

Additional information

in.jar.zip

The JAR file enclosed in the above zip generates the following code when decompiled:

public class Util {
   public static <T, R> Function<T, R> memoize(final Function<T, R> $$0) {
      return new Function<T, R>() {
         private final Map<T, R> cache = new ConcurrentHashMap<>();

         @Override
         public R apply(T $$0x) {
            return this.cache.computeIfAbsent($$0, $$0);
         }
      };
   }
}

The first parameter to computeIfAbsent should be $$0x (the apply parameter), not $$0 (the function parameter in the enclosing method). The parameter's name in the LVT for the apply method is $$0, but because it conflicted with an outside variable, Vineflower renamed it to $$0x, but it didn't rename it's usage.

PiTheGuy avatar Oct 24 '25 21:10 PiTheGuy