Browse Source

Fix Bug 550696 - ClassCastException during load time weaving: InstructionHandle cannot be cast to BranchHandle

tags/V1_9_5
Andy Clement 4 years ago
parent
commit
589e3dc730
1 changed files with 3 additions and 3 deletions
  1. 3
    3
      weaver/src/main/java/org/aspectj/weaver/bcel/BcelShadow.java

+ 3
- 3
weaver/src/main/java/org/aspectj/weaver/bcel/BcelShadow.java View File

import org.aspectj.apache.bcel.classfile.ConstantPool; import org.aspectj.apache.bcel.classfile.ConstantPool;
import org.aspectj.apache.bcel.classfile.Field; import org.aspectj.apache.bcel.classfile.Field;
import org.aspectj.apache.bcel.generic.ArrayType; import org.aspectj.apache.bcel.generic.ArrayType;
import org.aspectj.apache.bcel.generic.BranchHandle;
import org.aspectj.apache.bcel.generic.FieldInstruction; import org.aspectj.apache.bcel.generic.FieldInstruction;
import org.aspectj.apache.bcel.generic.INVOKEINTERFACE; import org.aspectj.apache.bcel.generic.INVOKEINTERFACE;
import org.aspectj.apache.bcel.generic.Instruction; import org.aspectj.apache.bcel.generic.Instruction;
.forName("org.aspectj.runtime.internal.AroundClosure"), Modifier.PUBLIC, "unlink", .forName("org.aspectj.runtime.internal.AroundClosure"), Modifier.PUBLIC, "unlink",
"()V"))); "()V")));


InstructionHandle jumpOverHandler = advice.append(InstructionConstants.NOP);

BranchHandle jumpOverHandler = advice.append(new InstructionBranch(Constants.GOTO, null));
// Call unlink in finally block // Call unlink in finally block


// Do not POP the exception off, we need to rethrow it // Do not POP the exception off, we need to rethrow it
// After that exception is on the top of the stack again // After that exception is on the top of the stack again
advice.append(InstructionConstants.ATHROW); advice.append(InstructionConstants.ATHROW);
InstructionHandle jumpTarget = advice.append(InstructionConstants.NOP); InstructionHandle jumpTarget = advice.append(InstructionConstants.NOP);
jumpOverHandler.setInstruction(InstructionFactory.createBranchInstruction(Constants.GOTO, jumpTarget));
jumpOverHandler.setTarget(jumpTarget);
enclosingMethod.addExceptionHandler(tryUnlinkPosition, unlinkInsn, handlerStart, null/* ==finally */, false); enclosingMethod.addExceptionHandler(tryUnlinkPosition, unlinkInsn, handlerStart, null/* ==finally */, false);
} }
} }

Loading…
Cancel
Save