Bug 121385 - around advice does not work when LTW
Summary: around advice does not work when LTW
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.0RC1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.5.1   Edit
Assignee: Andrew Clement CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-19 05:32 EST by liu wen zhong CLA
Modified: 2006-02-15 06:17 EST (History)
1 user (show)

See Also:


Attachments
Failing LTW testcase (7.35 KB, application/octet-stream)
2005-12-21 11:03 EST, Matthew Webster CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description liu wen zhong CLA 2005-12-19 05:32:32 EST
I defined a aop.xml and a aspect, I have already copy aspectjweaver.jar D:\work\BTM\lib\aspectjweaver.jar, and added -javaagent:D:\work\BTM\lib\aspectjweaver.jar option to the JVM in Eclipse, it works fine if there are before and after advice in aspect, but it will be wrong once I used around advice. if I use compile-time weaving, this around advice works fine.
my Eclipse env: eclipse 3.0.2 + AJDT 1.2.1 RC1 release + Sun JDK 1.5.0.

aspect file:
import org.aspectj.lang.Signature;
import org.aspectj.lang.JoinPoint;
public abstract aspect World { 
    //private Object result;
	pointcut greeting() : execution(* Hello.sayWorld(..)); 
    
	Object around(): greeting() {
    	System.out.println("around start!");
    	Object result = proceed();
    	System.out.println("around end!");
    	return result;
	}
    
//    before() : greeting() { 
//    	Signature signature = thisJoinPoint.getSignature();
//        System.out.println("before " + signature.getName()); 
//    } 
    
//    after() returning () : greeting() { 
//    	Signature signature = thisJoinPoint.getSignature();
//        System.out.println("after " + signature.getName()); 
//    } 

} 

aop.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<aspectj>
	<aspects>
		<aspect name="World"/>
		<concrete-aspect name="World1" extends="World">
          <pointcut name="greeting" expression="execution(* Hello.sayWorld(..)) ||
          execution(* Hello.sayHello(..))"/>
        </concrete-aspect>
	</aspects>
	<weaver options="-Xreweavable -verbose -XlazyTjp -showWeaveInfo">
		<include within="Hello"/>
	</weaver>
</aspectj>

around advice error message in eclipse console as below:
info register aspect World
info generating class 'World1'
info weaving 'Hello'
info weaver operating in reweavable mode.  Need to verify any required types exist.
abort trouble in: 
public class Hello extends java.lang.Object:
  public void <init>():
                    ALOAD_0     // Hello this   (line 2)
                    INVOKESPECIAL java.lang.Object.<init> ()V
    constructor-execution(void Hello.<init>())
    |               RETURN
    constructor-execution(void Hello.<init>())
  end public void <init>()

  public static void main(String[])    org.aspectj.weaver.MethodDeclarationLineNumber: 7:75
:
                    INVOKESTATIC Hello.sayHello ()V   (line 9)
                    RETURN   (line 10)
  end public static void main(String[])

  public static void sayHello()    org.aspectj.weaver.MethodDeclarationLineNumber: 12:180
:
  end public static void sayHello()

  public static int sayWorld()    org.aspectj.weaver.MethodDeclarationLineNumber: 17:268
:
    method-execution(int Hello.sayWorld())
    |               GETSTATIC java.lang.System.out Ljava/io/PrintStream;   (line 18)
    |               LDC "World"
    |               INVOKEVIRTUAL java.io.PrintStream.println (Ljava/lang/String;)V
    |               ICONST_0   (line 19)
    |               IRETURN
    method-execution(int Hello.sayWorld())
  end public static int sayWorld()

  static final void sayHello_aroundBody0():
                    GETSTATIC java.lang.System.out Ljava/io/PrintStream;   (line 13)
                    LDC "Hello"
                    INVOKEVIRTUAL java.io.PrintStream.println (Ljava/lang/String;)V
                    INVOKESTATIC Hello.sayWorld ()I   (line 14)
                    POP
                    RETURN   (line 15)
  end static final void sayHello_aroundBody0()
end public class Hello

public class Hello$AjcClosure1 extends org.aspectj.runtime.internal.AroundClosure:
  public void <init>(Object[]):
                    ALOAD_0
                    ALOAD_1
                    INVOKESPECIAL org.aspectj.runtime.internal.AroundClosure.<init> ([Ljava/lang/Object;)V
                    RETURN
  end public void <init>(Object[])

  public Object run(Object[]):
                    ALOAD_0
                    GETFIELD org.aspectj.runtime.internal.AroundClosure.state [Ljava/lang/Object;
                    ASTORE_2
                    INVOKESTATIC Hello.sayHello_aroundBody0 ()V
                    ACONST_NULL
                    ARETURN
  end public Object run(Object[])
end public class Hello$AjcClosure1
 -- (NullPointerException) null
null
java.lang.NullPointerException
	at org.aspectj.weaver.bcel.BcelAdvice.getAdviceArgSetup(BcelAdvice.java:457)
	at org.aspectj.weaver.bcel.BcelShadow.weaveAroundClosure(BcelShadow.java:2685)
	at org.aspectj.weaver.bcel.BcelAdvice.implementOn(BcelAdvice.java:230)
	at org.aspectj.weaver.Shadow.implementMungers(Shadow.java:588)
	at org.aspectj.weaver.Shadow.implement(Shadow.java:405)
	at org.aspectj.weaver.bcel.BcelClassWeaver.implement(BcelClassWeaver.java:2146)
	at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:467)
	at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:102)
	at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1543)
	at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump(BcelWeaver.java:1494)
	at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify(BcelWeaver.java:1275)
	at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1097)
	at org.aspectj.weaver.tools.WeavingAdaptor.getWovenBytes(WeavingAdaptor.java:263)
	at org.aspectj.weaver.tools.WeavingAdaptor.weaveClass(WeavingAdaptor.java:196)
	at org.aspectj.weaver.loadtime.Aj.preProcess(Aj.java:65)
	at org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter.transform(ClassPreProcessorAgentAdapter.java:52)
	at sun.instrument.TransformerManager.transform(TransformerManager.java:122)
	at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:155)
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

Message: abort trouble in: 
public class Hello extends java.lang.Object:
  public void <init>():
                    ALOAD_0     // Hello this   (line 2)
                    INVOKESPECIAL java.lang.Object.<init> ()V
    constructor-execution(void Hello.<init>())
    |               RETURN
    constructor-execution(void Hello.<init>())
  end public void <init>()

  public static void main(String[])    org.aspectj.weaver.MethodDeclarationLineNumber: 7:75
:
                    INVOKESTATIC Hello.sayHello ()V   (line 9)
                    RETURN   (line 10)
  end public static void main(String[])

  public static void sayHello()    org.aspectj.weaver.MethodDeclarationLineNumber: 12:180
:
  end public static void sayHello()

  public static int sayWorld()    org.aspectj.weaver.MethodDeclarationLineNumber: 17:268
:
    method-execution(int Hello.sayWorld())
    |               GETSTATIC java.lang.System.out Ljava/io/PrintStream;   (line 18)
    |               LDC "World"
    |               INVOKEVIRTUAL java.io.PrintStream.println (Ljava/lang/String;)V
    |               ICONST_0   (line 19)
    |               IRETURN
    method-execution(int Hello.sayWorld())
  end public static int sayWorld()

  static final void sayHello_aroundBody0():
                    GETSTATIC java.lang.System.out Ljava/io/PrintStream;   (line 13)
                    LDC "Hello"
                    INVOKEVIRTUAL java.io.PrintStream.println (Ljava/lang/String;)V
                    INVOKESTATIC Hello.sayWorld ()I   (line 14)
                    POP
                    RETURN   (line 15)
  end static final void sayHello_aroundBody0()
end public class Hello

public class Hello$AjcClosure1 extends org.aspectj.runtime.internal.AroundClosure:
  public void <init>(Object[]):
                    ALOAD_0
                    ALOAD_1
                    INVOKESPECIAL org.aspectj.runtime.internal.AroundClosure.<init> ([Ljava/lang/Object;)V
                    RETURN
  end public void <init>(Object[])

  public Object run(Object[]):
                    ALOAD_0
                    GETFIELD org.aspectj.runtime.internal.AroundClosure.state [Ljava/lang/Object;
                    ASTORE_2
                    INVOKESTATIC Hello.sayHello_aroundBody0 ()V
                    ACONST_NULL
                    ARETURN
  end public Object run(Object[])
end public class Hello$AjcClosure1
 -- (NullPointerException) null
null
java.lang.NullPointerException
	at org.aspectj.weaver.bcel.BcelAdvice.getAdviceArgSetup(BcelAdvice.java:457)
	at org.aspectj.weaver.bcel.BcelShadow.weaveAroundClosure(BcelShadow.java:2685)
	at org.aspectj.weaver.bcel.BcelAdvice.implementOn(BcelAdvice.java:230)
	at org.aspectj.weaver.Shadow.implementMungers(Shadow.java:588)
	at org.aspectj.weaver.Shadow.implement(Shadow.java:405)
	at org.aspectj.weaver.bcel.BcelClassWeaver.implement(BcelClassWeaver.java:2146)
	at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:467)
	at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:102)
	at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1543)
	at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump(BcelWeaver.java:1494)
	at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify(BcelWeaver.java:1275)
	at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1097)
	at org.aspectj.weaver.tools.WeavingAdaptor.getWovenBytes(WeavingAdaptor.java:263)
	at org.aspectj.weaver.tools.WeavingAdaptor.weaveClass(WeavingAdaptor.java:196)
	at org.aspectj.weaver.loadtime.Aj.preProcess(Aj.java:65)
	at org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter.transform(ClassPreProcessorAgentAdapter.java:52)
	at sun.instrument.TransformerManager.transform(TransformerManager.java:122)
	at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:155)
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

org.aspectj.bridge.AbortException: trouble in: 
public class Hello extends java.lang.Object:
  public void <init>():
                    ALOAD_0     // Hello this   (line 2)
                    INVOKESPECIAL java.lang.Object.<init> ()V
    constructor-execution(void Hello.<init>())
    |               RETURN
    constructor-execution(void Hello.<init>())
  end public void <init>()

  public static void main(String[])    org.aspectj.weaver.MethodDeclarationLineNumber: 7:75
:
                    INVOKESTATIC Hello.sayHello ()V   (line 9)
                    RETURN   (line 10)
  end public static void main(String[])

  public static void sayHello()    org.aspectj.weaver.MethodDeclarationLineNumber: 12:180
:
  end public static void sayHello()

  public static int sayWorld()    org.aspectj.weaver.MethodDeclarationLineNumber: 17:268
:
    method-execution(int Hello.sayWorld())
    |               GETSTATIC java.lang.System.out Ljava/io/PrintStream;   (line 18)
    |               LDC "World"
    |               INVOKEVIRTUAL java.io.PrintStream.println (Ljava/lang/String;)V
    |               ICONST_0   (line 19)
    |               IRETURN
    method-execution(int Hello.sayWorld())
  end public static int sayWorld()

  static final void sayHello_aroundBody0():
                    GETSTATIC java.lang.System.out Ljava/io/PrintStream;   (line 13)
                    LDC "Hello"
                    INVOKEVIRTUAL java.io.PrintStream.println (Ljava/lang/String;)V
                    INVOKESTATIC Hello.sayWorld ()I   (line 14)
                    POP
                    RETURN   (line 15)
  end static final void sayHello_aroundBody0()
end public class Hello

public class Hello$AjcClosure1 extends org.aspectj.runtime.internal.AroundClosure:
  public void <init>(Object[]):
                    ALOAD_0
                    ALOAD_1
                    INVOKESPECIAL org.aspectj.runtime.internal.AroundClosure.<init> ([Ljava/lang/Object;)V
                    RETURN
  end public void <init>(Object[])

  public Object run(Object[]):
                    ALOAD_0
                    GETFIELD org.aspectj.runtime.internal.AroundClosure.state [Ljava/lang/Object;
                    ASTORE_2
                    INVOKESTATIC Hello.sayHello_aroundBody0 ()V
                    ACONST_NULL
                    ARETURN
  end public Object run(Object[])
end public class Hello$AjcClosure1

	at org.aspectj.bridge.MessageWriter.handleMessage(MessageWriter.java:47)
	at org.aspectj.weaver.tools.WeavingAdaptor$WeavingAdaptorMessageHandler.handleMessage(WeavingAdaptor.java:395)
	at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1554)
	at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump(BcelWeaver.java:1494)
	at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify(BcelWeaver.java:1275)
	at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1097)
	at org.aspectj.weaver.tools.WeavingAdaptor.getWovenBytes(WeavingAdaptor.java:263)
	at org.aspectj.weaver.tools.WeavingAdaptor.weaveClass(WeavingAdaptor.java:196)
	at org.aspectj.weaver.loadtime.Aj.preProcess(Aj.java:65)
	at org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter.transform(ClassPreProcessorAgentAdapter.java:52)
	at sun.instrument.TransformerManager.transform(TransformerManager.java:122)
	at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:155)
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
Hello
World
Comment 1 liu wen zhong CLA 2005-12-19 05:45:11 EST
my test Hello class:


public class Hello {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		sayHello();
	} 
	 
	public static void sayHello() {
		System.out.println("Hello");
		sayWorld();
	} 
	
	public static int sayWorld() {
		System.out.println("World");
		return 0;
	}
}
Comment 2 Andrew Clement CLA 2005-12-19 06:14:11 EST
Matthew is going to try and recreate this with the supplied info.
Comment 3 Matthew Webster CLA 2005-12-19 09:29:56 EST
This can easily be reproduces with supplied testcase (thanks). The priority should be to find a good workaround if possible.
1. User confirms that before/after rather than works 
2. I can confirm that defining a concrete sub-aspect using code style (rather than XML) also works but defining one using annotation style fails in a similar way. I also get the failure with both source and binary weaving.
3. It may work if the abstract aspect is defined using annotation style
Comment 4 Matthew Webster CLA 2005-12-19 09:36:06 EST
This can easily be reproduced with supplied testcase (thanks). The priority
should be to find a good workaround if possible.
1. User confirms that before/after rather than around advice works 
2. I can confirm that defining a concrete sub-aspect using code style (rather
than XML) also works but defining one using annotation style fails in a similar
way. I also get the failure with both source and binary weaving.
3. It may work if the abstract aspect is defined using annotation style
Comment 5 Matthew Webster CLA 2005-12-19 10:12:24 EST
BTW looking at the weaver options "-XlazyTjp" is unecessary because it is now the default (although ironically it does not apply to around advice) and -Xreweavable should not be used (-XnotReweavable is the default for LTW) because it is unlikely that the code will need to be rewoven before going straight into the JVM and probably hurts performance (see Bug 114897).
Comment 6 Andrew Clement CLA 2005-12-20 09:32:16 EST
It does occur because of the mixing of styles.  The abstract aspect being code style, then the concrete sub-aspect (generated from the XML) being annotation style.  The problem is that when 'collecting' up the advice as part of processing the sub-aspect, the super aspect is returning 'true' for hasExtraParameter() and yet the extraVar is null.  A simple guard on the null value gets us over the problem in this case - but there is possibly something to look into, examining why hasExtraParameter() is returning true.

the null guard is in 1.5.0 final.
Comment 7 Matthew Webster CLA 2005-12-21 11:03:11 EST
Created attachment 32085 [details]
Failing LTW testcase

Unfortunately while the NPE is cured we have a VerifyError instead. The World1 sub-aspect is generated and defined. The test is woven but cannot be defined.

java.lang.VerifyError: (class: Hello, method: sayWorld signature: ()I) Unable to pop operand off an empty stack
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2365)
	at java.lang.Class.getMethod0(Class.java:2611)
	at java.lang.Class.getMethod(Class.java:1579)
	at org.aspectj.tools.ajc.AjcTestCase.run(AjcTestCase.java:608)
	at org.aspectj.testing.RunSpec.execute(RunSpec.java:56)
	at org.aspectj.testing.AjcTest.runTest(AjcTest.java:68)
	at org.aspectj.testing.XMLBasedAjcTestCase.runTest(XMLBasedAjcTestCase.java:111)
	at org.aspectj.systemtest.ajc150.Ajc150Tests.testNPEInBcelAdviceWithConcreteAspect_pr121385(Ajc150Tests.java:873)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at junit.framework.TestCase.runTest(TestCase.java:154)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

info AspectJ Weaver Version DEVELOPMENT built on 
info register classloader org.aspectj.weaver.loadtime.WeavingURLClassLoader
info using /C:/temp/ajcSandbox/ajcTest24128.tmp/META-INF/aop.xml
info generating class 'World1'
info weaving 'Hello'
info weaver operating in reweavable mode.  Need to verify any required types exist.
weaveinfo Join point 'method-execution(void Hello.sayHello())' in Type 'Hello' (Hello.java:7) advised by around advice from 'World1' (World.aj:7)
weaveinfo Join point 'method-execution(int Hello.sayWorld())' in Type 'Hello' (Hello.java:12) advised by around advice from 'World1' (World.aj:7)
info generating class 'Hello$AjcClosure1'
info generating class 'Hello$AjcClosure3'
Comment 8 Andrew Clement CLA 2005-12-21 11:13:51 EST
Interesting that there is something missing off the stack and the code now commented out with a null check would load a value onto the stack.
Comment 9 Matthew Webster CLA 2005-12-21 11:32:16 EST
The problem may lie with trying to define the sub-aspect while initializing the weaving adaptor. When running in a different environment (AOSGi) I noticed that when World1 is defined the super-aspect World is loaded and weaving is attempted. In the harness this does not happen as the WeavingURLClassLoader uses a flag to avoid recursion during adaptor initialization. However although aspect World1 is woven during the generation process, World will not be woven (see Bug 119657).

There are 2 other concrete aop.xml tests in the harness in AtAjLTWTests . Changing them to use around instead of before advice only causes the AspectJ test to fail with a VerifyError; the @AspectJ one passes. So this may be a problem with around advice and/or mixing styles. However these tests use inner aspects so are not the same as the new test.
Comment 10 Andrew Clement CLA 2005-12-21 11:33:22 EST
Matthew - here is a patch - can you apply it to the weaver project and see if it helps your situation?
==========8<================
Index: src/org/aspectj/weaver/bcel/BcelAdvice.java
===================================================================
RCS file: /home/technology/org.aspectj/modules/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java,v
retrieving revision 1.43
diff -u -r1.43 BcelAdvice.java
--- src/org/aspectj/weaver/bcel/BcelAdvice.java	19 Dec 2005 15:06:51 -0000	1.43
+++ src/org/aspectj/weaver/bcel/BcelAdvice.java	21 Dec 2005 16:33:35 -0000
@@ -400,7 +400,8 @@
 		if (exposedState.getAspectInstance() != null) {
 			il.append(BcelRenderer.renderExpr(fact, world, exposedState.getAspectInstance()));
 		}
-        final boolean isAnnotationStyleAspect = getConcreteAspect()!=null && getConcreteAspect().isAnnotationStyleAspect();
+		boolean x = this.getDeclaringAspect().resolve(world).isAnnotationStyleAspect();
+        final boolean isAnnotationStyleAspect = getConcreteAspect()!=null && getConcreteAspect().isAnnotationStyleAspect() && x;
         boolean previousIsClosure = false;
         for (int i = 0, len = exposedState.size(); i < len; i++) {
         	if (exposedState.isErroneousVar(i)) continue; // Erroneous vars have already had error msgs reported!
@@ -455,12 +456,14 @@
 	                } else if (hasExtraParameter()) {
                         previousIsClosure = false;
                         //extra var can be null here (@Aj aspect extends abstract code style, advice in code style)
-                        if (extraVar != null) {
+//                        if (extraVar != null) {
                             extraVar.appendLoadAndConvert(
                                 il,
                                 fact,
                                 getExtraParameterType().resolve(world));
-                        }
+                        
+//                        } else
+//                            il.append(InstructionConstants.ACONST_NULL);
                     } else {
                         previousIsClosure = false;
                         getConcreteAspect().getWorld().getMessageHandler().handleMessage(
Index: src/org/aspectj/weaver/bcel/BcelShadow.java
===================================================================
RCS file: /home/technology/org.aspectj/modules/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java,v
retrieving revision 1.86
diff -u -r1.86 BcelShadow.java
--- src/org/aspectj/weaver/bcel/BcelShadow.java	12 Dec 2005 10:48:46 -0000	1.86
+++ src/org/aspectj/weaver/bcel/BcelShadow.java	21 Dec 2005 16:33:36 -0000
@@ -2221,7 +2221,7 @@
 				munger.getAdviceArgSetup(
 					this,
 					null,
-                    (munger.getConcreteAspect().isAnnotationStyleAspect())?
+                    (munger.getConcreteAspect().isAnnotationStyleAspect() && munger.getDeclaringAspect().resolve(world).isAnnotationStyleAspect())?
                         this.loadThisJoinPoint():
 					    new InstructionList(InstructionConstants.ACONST_NULL)));
 		    // adviceMethodInvocation =
==========8<================
Comment 11 Andrew Clement CLA 2005-12-21 12:05:12 EST
the bug appears to be that we use two mechanisms to build the arguments for an around advice call - which mechanism we use depends on whether the advice was declared in a code style aspect or an annotation style aspect.

The problem here is that we ask the advice for the style used by the concrete aspect and the concrete aspect is annotation style.  But of course the advice was declared in a code style aspect.  We shouldn't check the concrete aspect but the declaring aspect for the advice.  Changing the code to do this check fixes this problem and we can remove the null check that was added just before 1.5.0 final.
Comment 12 Andrew Clement CLA 2005-12-21 12:21:13 EST
proper fix checked in. will be in the next dev build.
Comment 13 Andrew Clement CLA 2006-02-15 06:17:51 EST
fix available.