diff --git a/src/org/jetbrains/java/decompiler/main/ClassWriter.java b/src/org/jetbrains/java/decompiler/main/ClassWriter.java index 3f2f177..a24464c 100644 --- a/src/org/jetbrains/java/decompiler/main/ClassWriter.java +++ b/src/org/jetbrains/java/decompiler/main/ClassWriter.java @@ -749,13 +749,6 @@ public class ClassWriter { buffer.append(' '); String parameterName = methodWrapper.varproc.getVarName(new VarVersionPair(index, 0)); - if (methodParameters != null && i < methodParameters.size()) { - String myName = methodParameters.get(i).myName; - if (myName != null) { - parameterName = myName; - methodWrapper.varproc.setVarName(new VarVersionPair(index, 0), myName); - } - } buffer.append(parameterName == null ? "param" + index : parameterName); // null iff decompiled with errors paramCount++; diff --git a/src/org/jetbrains/java/decompiler/main/rels/ClassWrapper.java b/src/org/jetbrains/java/decompiler/main/rels/ClassWrapper.java index ca63ad5..5c6da7c 100644 --- a/src/org/jetbrains/java/decompiler/main/rels/ClassWrapper.java +++ b/src/org/jetbrains/java/decompiler/main/rels/ClassWrapper.java @@ -14,14 +14,14 @@ import org.jetbrains.java.decompiler.modules.decompiler.vars.VarProcessor; import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPair; import org.jetbrains.java.decompiler.struct.StructClass; import org.jetbrains.java.decompiler.struct.StructMethod; +import org.jetbrains.java.decompiler.struct.attr.StructGeneralAttribute; import org.jetbrains.java.decompiler.struct.attr.StructLocalVariableTableAttribute; +import org.jetbrains.java.decompiler.struct.attr.StructMethodParametersAttribute; import org.jetbrains.java.decompiler.struct.gen.MethodDescriptor; import org.jetbrains.java.decompiler.util.InterpreterUtil; import org.jetbrains.java.decompiler.util.VBStyleCollection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; public class ClassWrapper { private final StructClass classStruct; @@ -139,13 +139,37 @@ public class ClassWrapper { classStruct.getFields().forEach(f -> namesCollector.addName(f.getName())); varProc.refreshVarNames(namesCollector); + Map paramNames = new HashMap<>(); + + if (DecompilerContext.getOption(IFernflowerPreferences.USE_METHOD_PARAMETERS)) { + StructMethodParametersAttribute attr = mt.getAttribute(StructGeneralAttribute.ATTRIBUTE_METHOD_PARAMETERS); + if (attr != null) { + List entries = attr.getEntries(); + int index = mt.hasModifier(CodeConstants.ACC_STATIC) ? 0 : 1; + for (int i = 0; i < md.params.length && i < entries.size(); i++) { + String myName = entries.get(i).myName; + if (myName != null) { + paramNames.put(index, myName); + } + index += md.params[i].stackSize; + } + } + } + // if debug information present and should be used if (DecompilerContext.getOption(IFernflowerPreferences.USE_DEBUG_VAR_NAMES)) { StructLocalVariableTableAttribute attr = mt.getLocalVariableAttr(); if (attr != null) { // only param names here - varProc.setDebugVarNames(attr.getMapParamNames()); + paramNames.putAll(attr.getMapParamNames()); + } + } + + varProc.setDebugVarNames(paramNames); + if (DecompilerContext.getOption(IFernflowerPreferences.USE_DEBUG_VAR_NAMES)) { + StructLocalVariableTableAttribute attr = mt.getLocalVariableAttr(); + if (attr != null) { // the rest is here methodWrapper.getOrBuildGraph().iterateExprents(exprent -> { List lst = exprent.getAllExprents(true);