Skip to content

Commit f9725d1

Browse files
authored
Release 1.9.2
2 parents efd17a7 + f79b263 commit f9725d1

File tree

64 files changed

+1005
-308
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1005
-308
lines changed

build.gradle

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ compileJava {
2323
group = 'org.vineflower'
2424
archivesBaseName = 'vineflower'
2525

26-
version = '1.9.1'
26+
version = '1.9.2'
2727

2828
def ENV = System.getenv()
2929
version = version + (ENV.GITHUB_ACTIONS ? "" : "+local")
@@ -242,9 +242,11 @@ nexusPublishing {
242242
}
243243

244244
signing {
245-
def signingKey = ENV.SIGNING_KEY
246-
def signingPassword = ENV.SIGNING_KEY_PASSPHRASE
245+
if (ENV.SIGNING_KEY) {
246+
def signingKey = ENV.SIGNING_KEY
247+
def signingPassword = ENV.SIGNING_KEY_PASSPHRASE
247248

248-
useInMemoryPgpKeys(signingKey, signingPassword)
249-
sign publishing.publications.mavenJava
249+
useInMemoryPgpKeys(signingKey, signingPassword)
250+
sign publishing.publications.mavenJava
251+
}
250252
}

src/org/jetbrains/java/decompiler/main/ClassWriter.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ private static boolean invokeProcessors(TextBuffer buffer, ClassNode node) {
101101
EnumProcessor.clearEnum(wrapper);
102102
}
103103

104+
// FIXME: when 1.10 merge, this needs to be removed
105+
for (MethodWrapper mw : wrapper.getMethods()) {
106+
if (mw.root != null) {
107+
mw.varproc.rerunClashing(mw.root);
108+
}
109+
}
110+
104111
if (DecompilerContext.getOption(IFernflowerPreferences.DECOMPILE_ASSERTIONS)) {
105112
AssertProcessor.buildAssertions(node);
106113
}
@@ -189,9 +196,14 @@ public void classLambdaToJava(ClassNode node, TextBuffer buffer, Exprent method_
189196
if (!firstParameter) {
190197
buffer.append(", ");
191198
}
199+
VarType type = md_content.params[i];
192200

193201
String parameterName = methodWrapper.varproc.getVarName(new VarVersionPair(index, 0));
194-
buffer.append(parameterName == null ? "param" + index : parameterName); // null iff decompiled with errors
202+
if (parameterName == null) {
203+
parameterName = "param" + index; // null iff decompiled with errors
204+
}
205+
parameterName = methodWrapper.methodStruct.getVariableNamer().renameParameter(mt.getAccessFlags(), ExprProcessor.getCastTypeName(type), parameterName, index);
206+
buffer.append(parameterName);
195207

196208
firstParameter = false;
197209
}
@@ -835,7 +847,11 @@ private static void methodLambdaToJava(ClassNode lambdaNode,
835847
buffer.append(" ");
836848

837849
String parameterName = methodWrapper.varproc.getVarName(new VarVersionPair(index, 0));
838-
buffer.append(parameterName == null ? "param" + index : parameterName); // null iff decompiled with errors
850+
if (parameterName == null) {
851+
parameterName = "param" + index; // null iff decompiled with errors
852+
}
853+
parameterName = methodWrapper.methodStruct.getVariableNamer().renameParameter(mt.getAccessFlags(), typeName, parameterName, index);
854+
buffer.append(parameterName);
839855

840856
firstParameter = false;
841857
}
@@ -1104,11 +1120,11 @@ else if (methodWrapper.varproc.getVarFinal(new VarVersionPair(index, 0)) == VarT
11041120
parameterName = methodWrapper.varproc.getVarName(new VarVersionPair(index, 0));
11051121
}
11061122

1107-
if ((flags & (CodeConstants.ACC_ABSTRACT | CodeConstants.ACC_NATIVE)) != 0) {
1108-
String newParameterName = methodWrapper.methodStruct.getVariableNamer().renameAbstractParameter(parameterName, index);
1109-
parameterName = !newParameterName.equals(parameterName) ? newParameterName : DecompilerContext.getStructContext().renameAbstractParameter(methodWrapper.methodStruct.getClassQualifiedName(), mt.getName(), mt.getDescriptor(), index - (((flags & CodeConstants.ACC_STATIC) == 0) ? 1 : 0), parameterName);
1110-
1123+
String newParameterName = methodWrapper.methodStruct.getVariableNamer().renameParameter(flags, typeName, parameterName, index);
1124+
if ((flags & (CodeConstants.ACC_ABSTRACT | CodeConstants.ACC_NATIVE)) != 0 && Objects.equals(newParameterName, parameterName)) {
1125+
newParameterName = DecompilerContext.getStructContext().renameAbstractParameter(methodWrapper.methodStruct.getClassQualifiedName(), mt.getName(), mt.getDescriptor(), index - (((flags & CodeConstants.ACC_STATIC) == 0) ? 1 : 0), parameterName);
11111126
}
1127+
parameterName = newParameterName;
11121128

11131129
buffer.append(parameterName == null ? "param" + index : parameterName); // null iff decompiled with errors
11141130

src/org/jetbrains/java/decompiler/main/ClassesProcessor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,11 @@ public int compareTo(ClassNode o) {
686686
return this.classStruct.qualifiedName.compareTo(o.classStruct.qualifiedName);
687687
}
688688

689+
@Override
690+
public String toString() {
691+
return type + " class " + classStruct.qualifiedName;
692+
}
693+
689694
public static class LambdaInformation {
690695
public String method_name;
691696
public String method_descriptor;

src/org/jetbrains/java/decompiler/main/Fernflower.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ public Fernflower(IBytecodeProvider provider, IResultSaver saver, Map<String, Ob
7272
}
7373
if (renamerFactory == null) {
7474
if("1".equals(properties.get(IFernflowerPreferences.USE_JAD_VARNAMING))) {
75-
renamerFactory = new JADNameProvider.JADNameProviderFactory();
75+
boolean renameParams = "1".equals(properties.get(IFernflowerPreferences.USE_JAD_PARAMETER_NAMING));
76+
renamerFactory = new JADNameProvider.JADNameProviderFactory(renameParams);
7677
} else {
7778
renamerFactory = new IdentityRenamerFactory();
7879
}

src/org/jetbrains/java/decompiler/main/extern/IFernflowerPreferences.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,13 @@ public interface IFernflowerPreferences {
223223
String LINE_SEPARATOR_UNX = "\n";
224224

225225
@Name("JAD-Style Variable Naming")
226-
@Description("Use JAD-style variable naming for local variables, instead of var<index>_<version>A.")
226+
@Description("Use JAD-style variable naming for local variables, instead of var<index>_<version>.")
227227
String USE_JAD_VARNAMING = "jvn";
228228

229+
@Name("JAD-Style Parameter Naming")
230+
@Description("Use JAD-style variable naming for parameters.")
231+
String USE_JAD_PARAMETER_NAMING = "jpr";
232+
229233
@Name("Skip Extra Files")
230234
@Description("Skip copying non-class files from the input folder or file to the output")
231235
String SKIP_EXTRA_FILES = "sef";
@@ -319,6 +323,7 @@ static Map<String, Object> getDefaults() {
319323
defaults.put(DUMP_ORIGINAL_LINES, "0");
320324
defaults.put(THREADS, String.valueOf(Runtime.getRuntime().availableProcessors()));
321325
defaults.put(USE_JAD_VARNAMING, "0");
326+
defaults.put(USE_JAD_PARAMETER_NAMING, "0");
322327
defaults.put(SKIP_EXTRA_FILES, "0");
323328
defaults.put(WARN_INCONSISTENT_INNER_CLASSES, "1");
324329
defaults.put(DUMP_BYTECODE_ON_ERROR, "1");

src/org/jetbrains/java/decompiler/main/extern/IVariableNameProvider.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,21 @@
1717

1818
import java.util.Map;
1919

20+
import org.jetbrains.java.decompiler.code.CodeConstants;
2021
import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPair;
2122

2223
public interface IVariableNameProvider {
2324
public Map<VarVersionPair,String> rename(Map<VarVersionPair,String> variables);
24-
public String renameAbstractParameter(String abstractParam, int index);
25+
default String renameAbstractParameter(String name, int index) {
26+
return name;
27+
}
28+
29+
default String renameParameter(int flags, String type, String name, int index) {
30+
if ((flags & (CodeConstants.ACC_ABSTRACT | CodeConstants.ACC_NATIVE)) != 0) {
31+
return renameAbstractParameter(name, index);
32+
}
33+
34+
return name;
35+
}
2536
public void addParentContext(IVariableNameProvider renamer);
2637
}

src/org/jetbrains/java/decompiler/main/rels/NestedClassProcessor.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,20 @@ private static void setLambdaVars(ClassNode parent, ClassNode child) {
270270

271271
// rename colliding local variables
272272
for (VarVersionPair local : varProc.getUsedVarVersions()) {
273-
String name = varProc.getVarName(local);
273+
String name = null;
274+
LocalVariable lvt = varProc.getVarLVT(local);
275+
if (lvt != null) {
276+
name = lvt.getName();
277+
}
278+
if (name == null) {
279+
name = varProc.getVarName(local);
280+
}
274281
if (usedBefore.contains(name) && !"this".equals(name)) {
275-
mapNewNames.put(local, enclosingCollector.getFreeName(name));
282+
name = enclosingCollector.getFreeName(name);
283+
mapNewNames.put(local, name);
284+
if (lvt != null) {
285+
lvts.put(local, lvt.rename(name));
286+
}
276287
}
277288
}
278289

@@ -332,7 +343,7 @@ else if (!mapNewNames.containsKey(varVersion)) {
332343
VarVersionPair pair = entry.getKey();
333344
LocalVariable lvt = lvts.get(pair);
334345

335-
varProc.setVarName(pair, entry.getValue());
346+
varProc.setInheritedName(pair, entry.getValue());
336347
if (lvt != null) {
337348
varProc.setVarLVT(pair, lvt);
338349
}
@@ -723,7 +734,7 @@ private static void insertLocalVars(ClassNode parent, ClassNode child) {
723734
VarType type = mapNewTypes.get(pair);
724735
LocalVariable lvt = mapNewLVTs.get(pair);
725736

726-
method.varproc.setVarName(pair, entry.getValue());
737+
method.varproc.setInheritedName(pair, entry.getValue());
727738
if (type != null) {
728739
method.varproc.setVarType(pair, type);
729740
}

src/org/jetbrains/java/decompiler/modules/decompiler/FinallyProcessor.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,7 @@ private boolean compareBasicBlocksEx(ControlFlowGraph graph,
780780
List<int[]> lstStoreVars) {
781781
InstructionSequence seqPattern = pattern.getSeq();
782782
InstructionSequence seqSample = sample.getSeq();
783+
List<Integer> instrOldOffsetsSample = sample.getInstrOldOffsets();
783784

784785
if (type != 0) {
785786
seqPattern = seqPattern.clone();
@@ -822,6 +823,9 @@ private boolean compareBasicBlocksEx(ControlFlowGraph graph,
822823
seq.addInstruction(0, seqSample.getInstr(i), -1);
823824
oldOffsets.addFirst(sample.getOldOffset(i));
824825
seqSample.removeInstruction(i);
826+
if (i < instrOldOffsetsSample.size()) {
827+
instrOldOffsetsSample.remove(i);
828+
}
825829
}
826830

827831
BasicBlock newblock = new BasicBlock(++graph.last_id);
@@ -1010,26 +1014,31 @@ private static void deleteArea(ControlFlowGraph graph, Area area) {
10101014

10111015
private static void removeExceptionInstructionsEx(BasicBlock block, int blocktype, int finallytype) {
10121016
InstructionSequence seq = block.getSeq();
1017+
List<Integer> instrOldOffsets = block.getInstrOldOffsets();
10131018

10141019
if (finallytype == 3) { // empty finally handler
10151020
for (int i = seq.length() - 1; i >= 0; i--) {
10161021
seq.removeInstruction(i);
1022+
instrOldOffsets.remove(i);
10171023
}
10181024
}
10191025
else {
10201026
if ((blocktype & 1) > 0) { // first
10211027
if (finallytype == 2 || finallytype == 1) { // astore or pop
10221028
seq.removeInstruction(0);
1029+
instrOldOffsets.remove(0);
10231030
}
10241031
}
10251032

10261033
if ((blocktype & 2) > 0) { // last
10271034
if (finallytype == 2 || finallytype == 0) {
10281035
seq.removeLast();
1036+
instrOldOffsets.remove(instrOldOffsets.size() - 1);
10291037
}
10301038

10311039
if (finallytype == 2) { // astore
10321040
seq.removeLast();
1041+
instrOldOffsets.remove(instrOldOffsets.size() - 1);
10331042
}
10341043
}
10351044
}

src/org/jetbrains/java/decompiler/modules/decompiler/LabelHelper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public static void identifyLabels(RootStatement root) {
3030

3131
setExplicitEdges(root);
3232

33-
hideDefaultSwitchEdges(root);
33+
// TODO: is this correct? we don't want to mess with case statements while processing still happens!
34+
// hideDefaultSwitchEdges(root);
3435

3536
processStatementLabel(root);
3637

src/org/jetbrains/java/decompiler/modules/decompiler/TryWithResourcesProcessor.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ public static boolean makeTryWithResourceJ11(CatchStatement tryStatement) {
109109
return false;
110110
}
111111

112+
if (!tryStatement.getVars().get(0).getVarType().value.equals("java/lang/Throwable")) {
113+
return false;
114+
}
115+
112116
Statement inner = tryStatement.getStats().get(1); // Get catch block
113117

114118
VarExprent closeable = null;
@@ -125,6 +129,11 @@ public static boolean makeTryWithResourceJ11(CatchStatement tryStatement) {
125129
return false;
126130
}
127131

132+
CatchStatement innerTry = (CatchStatement)inner;
133+
if (!innerTry.getVars().get(0).getVarType().value.equals("java/lang/Throwable")) {
134+
return false;
135+
}
136+
128137
Statement inTry = inner.getStats().get(0);
129138

130139
// Catch block contains a basic block inside which has the closeable invocation
@@ -164,6 +173,15 @@ public static boolean makeTryWithResourceJ11(CatchStatement tryStatement) {
164173

165174
// Process try catch inside of if statement
166175
if (inner instanceof CatchStatement && !inner.getStats().isEmpty()) {
176+
if (inner.getStats().isEmpty()) {
177+
return false;
178+
}
179+
180+
CatchStatement innerTry = (CatchStatement)inner;
181+
if (!innerTry.getVars().get(0).getVarType().value.equals("java/lang/Throwable")) {
182+
return false;
183+
}
184+
167185
Statement inTry = inner.getStats().get(0);
168186

169187
if (inTry instanceof BasicBlockStatement && !inTry.getExprents().isEmpty()) {
@@ -192,6 +210,9 @@ public static boolean makeTryWithResourceJ11(CatchStatement tryStatement) {
192210
}
193211

194212
Set<Statement> destinations = findExitpoints(tryStatement);
213+
if (destinations.isEmpty()) {
214+
return false;
215+
}
195216

196217
Statement check = tryStatement;
197218
List<StatEdge> preds = new ArrayList<>();

0 commit comments

Comments
 (0)