Skip to content

Commit

Permalink
fix for malformatted lambda (#225)
Browse files Browse the repository at this point in the history
Co-authored-by: nbauma109 <nbauma109@github.com>
  • Loading branch information
nbauma109 and nbauma109 authored Apr 9, 2023
1 parent 0714058 commit 2fe6488
Show file tree
Hide file tree
Showing 12 changed files with 640 additions and 606 deletions.
9 changes: 9 additions & 0 deletions src/main/java/jd/core/model/classfile/Field.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class Field extends Base
private FieldOrMethod fieldOrMethod;
private ValueAndMethod valueAndMethod;
private ConstantPool constantPool;
private boolean outerLocalVariable;
/*
* Attributs pour l'affichage des champs synthetique des classes anonymes.
* Champs modifié par:
Expand Down Expand Up @@ -113,4 +114,12 @@ public ConstantPool getConstantPool() {
public void setConstantPool(ConstantPool constantPool) {
this.constantPool = constantPool;
}

public boolean isOuterLocalVariable() {
return outerLocalVariable;
}

public void setOuterLocalVariable(boolean outerLocalVariable) {
this.outerLocalVariable = outerLocalVariable;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public abstract class Instruction
private final int offset;
private int lineNumber;
private Instruction next; // comma-separated instruction in for and declarations
private boolean hidden;

protected Instruction(int opcode, int offset, int lineNumber)
{
Expand Down Expand Up @@ -80,16 +79,4 @@ public Instruction getNext() {
public void setNext(Instruction next) {
this.next = next;
}

public boolean isHidden() {
return hidden;
}

public void setHidden(boolean hidden) {
this.hidden = hidden;
}

public boolean holdsLambda() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,4 @@ public Instruction getValueref() {
public void setValueref(Instruction valueref) {
this.valueref = valueref;
}

@Override
public boolean holdsLambda() {
return valueref instanceof LambdaInstruction;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,4 @@ public Instruction getValueref() {
public void setValueref(Instruction valueref) {
this.valueref = valueref;
}

@Override
public boolean holdsLambda() {
return valueref instanceof LambdaInstruction;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import jd.core.model.classfile.LocalVariable;
import jd.core.model.classfile.LocalVariables;
import jd.core.model.instruction.bytecode.instruction.Instruction;
import jd.core.model.instruction.bytecode.instruction.StoreInstruction;
import jd.core.model.instruction.fast.FastConstants;

/** List & while(true). */
Expand Down Expand Up @@ -88,13 +87,4 @@ public int getLastOffset() {
.map(Instruction::getLastOffset)
.orElseGet(super::getLastOffset);
}

@Override
public boolean holdsLambda() {
if (instruction instanceof StoreInstruction) {
StoreInstruction si = (StoreInstruction) instruction;
return si.holdsLambda();
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public int create(
List<String> localVariableNames = localVariables == null ? Collections.emptyList() : localVariables.getFormalParameterNames(constants);
ClassFileAnalyzer.postAnalyzeSingleMethod(classFile, lambdaMethod);
List<String> lambdaParameterNames = prepareLambdaParameterNames(localVariableNames, parameterCount);
stack.push(new LambdaInstruction(opcode, offset, lineNumber, lambdaParameterNames, indyMethodTypes.getReturnedType(), lambdaMethod, classFile));
stack.push(new LambdaInstruction(opcode, offset+1, lineNumber, lambdaParameterNames, indyMethodTypes.getReturnedType(), lambdaMethod, classFile));
return Const.getNoOfOperands(opcode);

}
Expand Down
Loading

0 comments on commit 2fe6488

Please sign in to comment.