From d2e0feacc5c46d3d0c975e61d547fd8ebb35aa0d Mon Sep 17 00:00:00 2001 From: aclement Date: Mon, 8 Dec 2008 19:35:50 +0000 Subject: [PATCH] 257833: test and fix: anno atArgs and null --- weaver/src/org/aspectj/weaver/bcel/BcelRenderer.java | 10 ++++++++++ 1 file changed, 10 insertions(+) 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)); -- 2.39.5