From: aclement Date: Mon, 8 Dec 2008 19:35:50 +0000 (+0000) Subject: 257833: test and fix: anno atArgs and null X-Git-Tag: V1_6_3rc1~42 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d2e0feacc5c46d3d0c975e61d547fd8ebb35aa0d;p=aspectj.git 257833: test and fix: anno atArgs and null --- diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelRenderer.java b/weaver/src/org/aspectj/weaver/bcel/BcelRenderer.java index b55d00545..f46980be5 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelRenderer.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelRenderer.java @@ -140,11 +140,21 @@ public final class BcelRenderer implements ITestVisitor, IExprVisitor { // in Java: // foo.class.isAnnotationPresent(annotationClass); // in bytecode: + + // ifnull? skip to the end if it is as getClass() will fail (see pr 257833) + // load var onto the stack (done for us later) // invokevirtual java/lang/Object.getClass:()Ljava/lang/Class // ldc_w annotationClass // invokevirtual java/lang/Class.isAnnotationPresent:(Ljava/lang/Class;)Z InstructionList il = new InstructionList(); + + // If it is null jump past the advice call + il.append(fact.createBranchInstruction(Constants.IFNULL, fk)); + + // Load up the var again + il.append(((BcelVar) hasAnnotation.getVar()).createLoad(fact)); + Member getClass = MemberImpl.method(UnresolvedType.OBJECT, 0, UnresolvedType.JAVA_LANG_CLASS, "getClass", UnresolvedType.NONE); il.append(Utility.createInvoke(fact, world, getClass));