vineflower icon indicating copy to clipboard operation
vineflower copied to clipboard

Rename entities feature causes many problems and doesn't work correctly

Open jaskarth opened this issue 3 years ago • 2 comments

Rename entities is an old feature with many bugs. As there are a lot of bugs, this issue will track them:

  • [x] Fields and method definitions aren't renamed properly
  • [ ] Inner classes aren't run with the renamer
  • [ ] Renamer too strict on what classes should be renamed
  • [ ] Renaming certain classes fails to output them
  • [ ] Renaming methods automatically due to bad names doesn't rename references to to them

jaskarth avatar May 05 '22 00:05 jaskarth

Renaming certain classes fails to output them

Just to document, it seems like the following error is caused by the StructMethod having the renamed class name, which doesn't exist in the StructContext class cache. Link

Stacktrace
ERROR: Class b/f/j/e/class_8277 couldn't be fully decompiled.
java.lang.NullPointerException: Cannot invoke "org.jetbrains.java.decompiler.struct.StructClass.hasModifier(int)" because the return value of "org.jetbrains.java.decompiler.struct.StructContext.getClass(String)" is null
        at org.jetbrains.java.decompiler.struct.gen.MethodDescriptor.parseDescriptor(MethodDescriptor.java:93)
        at org.jetbrains.java.decompiler.main.ClassWriter.methodToJava(ClassWriter.java:921)
        at org.jetbrains.java.decompiler.main.ClassWriter.classToJava(ClassWriter.java:393)
        at org.jetbrains.java.decompiler.main.ClassesProcessor.writeClass(ClassesProcessor.java:480)
        at org.jetbrains.java.decompiler.main.Fernflower.getClassContent(Fernflower.java:173)
        at org.jetbrains.java.decompiler.struct.ContextUnit.lambda$save$2(ContextUnit.java:145)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
        at java.base/java.lang.Thread.run(Thread.java:831)

rushiiMachine avatar Aug 22 '22 18:08 rushiiMachine

Additionally documenting here; inner classes of renamed parents are not inlined with rename entities enabled and are instead written to a separate file. However, references to them seem to be ok so it's not too high priority.

rushiiMachine avatar Aug 23 '22 05:08 rushiiMachine