Skip to content

Commit e53395f

Browse files
committed
Avoid that empty method could be followed by another frame of exit advice that would be added at the same offset and therefore break an assumption on that two frames cannot be written to the same offset. Instead, write a padding NOP byte code when a method returns void to substitute for the single RETURN statement.
1 parent 1564e89 commit e53395f

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

byte-buddy-dep/src/main/java/net/bytebuddy/asm/Advice.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10710,7 +10710,9 @@ public void apply() {
1071010710
methodVisitor.visitVarInsn(Opcodes.FSTORE, isExitAdvice() ? argumentHandler.exit() : argumentHandler.enter());
1071110711
} else if (adviceMethod.getReturnType().represents(double.class)) {
1071210712
methodVisitor.visitVarInsn(Opcodes.DSTORE, isExitAdvice() ? argumentHandler.exit() : argumentHandler.enter());
10713-
} else if (!adviceMethod.getReturnType().represents(void.class)) {
10713+
} else if (adviceMethod.getReturnType().represents(void.class)) {
10714+
methodVisitor.visitInsn(Opcodes.NOP);
10715+
} else {
1071410716
methodVisitor.visitVarInsn(Opcodes.ASTORE, isExitAdvice() ? argumentHandler.exit() : argumentHandler.enter());
1071510717
}
1071610718
methodSizeHandler.requireStackSize(postProcessor

byte-buddy-dep/src/main/java/net/bytebuddy/utility/visitor/StackAwareMethodVisitor.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,6 @@ public void visitLabel(Label label) {
411411
super.visitLabel(label);
412412
}
413413

414-
@Override
415-
public void visitLineNumber(int line, Label start) {
416-
super.visitLineNumber(line, start);
417-
}
418-
419414
@Override
420415
public void visitTableSwitchInsn(int minimum, int maximum, Label defaultOption, Label... option) {
421416
adjustStack(-1);

0 commit comments

Comments
 (0)