Skip to content

Commit

Permalink
Update descriptors for moved insns to lambda methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Su5eD committed Apr 25, 2024
1 parent bd1d9b2 commit f8d3664
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public interface ParamModification {
ParameterTransformer asParameterTransformer();
}

record InsertParam(int index, Type type) implements ParamModification {
public record InsertParam(int index, Type type) implements ParamModification {
@Override
public ParamModification offset(int offset) {
return new InsertParam(this.index + offset, this.type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,19 @@ private void findMovedInsnsToLambdas(List<? super Patch> patches, MethodNode cle
}
}
if (!redirectInjectionPoints.isEmpty()) {
// TODO handle method desc changes or filter injectors
LOGGER.info("MOVED INSNS TO LAMBDA");
LOGGER.info(" {}", dirtyMethod.name + dirtyMethod.desc);
LOGGER.info("\\> {}", lambdaMethod.name + lambdaMethod.desc);
LOGGER.info("===");
Patch.ClassPatchBuilder patch = Patch.builder()
.targetClass(this.dirtyNode.name)
.targetMethod(dirtyMethod.name + dirtyMethod.desc)
.modifyTarget(lambdaMethod.name + lambdaMethod.desc);
redirectInjectionPoints.forEach(patch::targetInjectionPoint);
LayeredParamsDiffSnapshot diff = EnhancedParamsDiff.compareMethodParameters(dirtyMethod, lambdaMethod);
if (!diff.isEmpty() && diff.modifications().stream().allMatch(m -> m instanceof LayeredParamsDiffSnapshot.InsertParam)) {
patch.transform(diff.asParameterTransformer(ParamTransformTarget.METHOD, true));
}
patches.add(patch.build());
}
}
Expand Down

0 comments on commit f8d3664

Please sign in to comment.