vineflower
vineflower copied to clipboard
Rename entities feature causes many problems and doesn't work correctly
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
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)
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.