Bug 385462 - @DeclareError results in java.lang.StackOverflowError
Summary: @DeclareError results in java.lang.StackOverflowError
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.7.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 1.7.1   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-19 04:32 EDT by bodrin CLA
Modified: 2013-06-25 12:26 EDT (History)
1 user (show)

See Also:


Attachments
part of the ajcore...txt file (78.80 KB, text/plain)
2012-07-19 04:32 EDT, bodrin CLA
no flags Details
ajcore.txt (157.36 KB, text/plain)
2012-08-29 05:15 EDT, bodrin CLA
no flags Details
ajcore.txt (111.82 KB, text/plain)
2012-08-29 05:17 EDT, bodrin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description bodrin CLA 2012-07-19 04:32:35 EDT
Created attachment 218907 [details]
part of the ajcore...txt file

In my pom.xml I have :
...
<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>aspectj-maven-plugin</artifactId>
				<configuration>
					<source>1.6</source>
					<target>1.6</target>
					<XnoInline>true</XnoInline>
					<aspectLibraries>
						<aspectLibrary>
							<groupId>org.springframework</groupId>
							<artifactId>spring-aspects</artifactId>
						</aspectLibrary>
					</aspectLibraries>
					<verbose>true</verbose>
					<showWeaveInfo>true</showWeaveInfo>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>compile</goal>
							<goal>test-compile</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
...
		<dependency>
			<groupId>org.aspectj</groupId>
			<artifactId>aspectjrt</artifactId>
			<version>1.6.7</version>
		</dependency>
...

At aspectj:test-compile maven step (strange that I do not get it under aspectj:compile) I get java.lang.StackOverflowError. I have only a single aspect which has a number of @Ppointcuts and a number of @DeclareErrors (no advises) like:

@Aspect
public class YyyArchitectureValidator {

   @Pointcut("within(com.xxx.yyy.facade.amqp..*)")
   public void inAmqpFacade() {
   }

   @Pointcut("within(com.xxx.yyy.facade.rest..*)")
   public void inRestFacade() {
   }

   @Pointcut("inAmqpFacade() || inRestFacade()")
   public void inPresentationLayer() {
   }

   @Pointcut("within(com.xxx.yyy.domainmodel..*)")
   public void inDomainModelLayer() {
   }

@DeclareError("inDomainModelLayer() && presentationLayerCall()")
   static final String domainModelLayerCannotCallPresentationLayer =
         "Domain Model Layer cannot call Presentaion Layer!";

I see into the exception stack that there is the same pattern which occurs many times:
	at org.aspectj.weaver.bcel.BcelWorld.buildBcelDelegate(BcelWorld.java:382)
	at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:377)
	at org.aspectj.weaver.World.resolveToReferenceType(World.java:411)
	at org.aspectj.weaver.World.resolve(World.java:296)
	at org.aspectj.weaver.World.resolve(World.java:209)
	at org.aspectj.weaver.UnresolvedType.resolve(UnresolvedType.java:645)
	at org.aspectj.weaver.ResolvedMemberImpl.isVisible(ResolvedMemberImpl.java:631)
	at org.aspectj.weaver.patterns.ReferencePointcut.resolveBindings(ReferencePointcut.java:173)
	at org.aspectj.weaver.patterns.AndPointcut.resolveBindings(AndPointcut.java:75)
	at org.aspectj.weaver.patterns.Pointcut.resolve(Pointcut.java:186)
	at org.aspectj.weaver.patterns.DeclareErrorOrWarning.resolve(DeclareErrorOrWarning.java:102)
	at org.aspectj.weaver.bcel.BcelObjectType.resolveAnnotationDeclares(BcelObjectType.java:464)
	at org.aspectj.weaver.bcel.BcelObjectType.ensureAspectJAttributesUnpacked(BcelObjectType.java:397)
	at org.aspectj.weaver.bcel.BcelObjectType.<init>(BcelObjectType.java:159)


Note that I have tried using aspectjrt 1.6.8, 1.6.12 and 1.7.0 under win7 and ubuntu and I always got the same error.

The full exception trace is attached
Comment 1 bodrin CLA 2012-07-19 04:46:07 EDT
Also tried increasing memory via 

MAVEN_OPTS=-Xms512m -Xmx1024m -XX:MaxPermSize=256m -XX:+UseParNewGC -XX:+UseConcMarkSweepGC 

but got the same error
Comment 2 bodrin CLA 2012-07-19 04:47:15 EDT
some more pointcuts from this Aspect

   @Pointcut("call(* com.vmware.hcs.facade.amqp..*.*(..))")
   public void amqpFacadeCall() {
   }

   @Pointcut("call(* com.vmware.hcs.facade.rest..*.*(..))")
   public void restFacadeCall() {
   }

   @Pointcut("amqpFacadeCall() || restFacadeCall()")
   public void presentationLayerCall() {
   }
Comment 3 Andrew Clement CLA 2012-08-23 15:51:29 EDT
This bug looks awfully similar to bug 364380, which was fixed in AspectJ 1.7.0.

I recreated the issue with your testcode below on 1.6.7 then tried it on 1.6.12, still failed, then tried it on 1.7.0 - and it started working.  Are you absolutely sure you tried it on the 1.7.0 release?  If so, can you attach an ajcore from that release so I can verify the line numbers. thanks!
Comment 4 bodrin CLA 2012-08-29 05:15:15 EDT
Created attachment 220434 [details]
ajcore.txt

using aspectjrt-1.7.0.jar I get this dump most of the time
Comment 5 bodrin CLA 2012-08-29 05:17:53 EDT
Created attachment 220437 [details]
ajcore.txt

using aspectjrt-1.7.0.jar - this was a single shot.. a different one
Comment 6 bodrin CLA 2012-08-29 05:18:45 EDT
I have attached (ajcore.2.txt) a dump using 1.7.0. Thanks.
Comment 7 Andrew Clement CLA 2012-08-29 10:29:42 EDT
Hi.  It isn't about what version of aspectjrt.jar you use as the error is coming from the compiler/weaver, not during runtime - if you look at the first two lines of the ajcore files you have attached, you will see it is still using AspectJ 1.6.7 (compiler or weaver jar).  Can you change the compiler version you are using to 1.7.0?
Comment 8 bodrin CLA 2012-08-30 08:39:06 EDT
I see. I have removed the dependency on aspectjrt and added

		<dependency>
			<groupId>org.aspectj</groupId>
			<artifactId>aspectjtools</artifactId>
			<version>1.7.0</version>
		</dependency>

but I again get 

---- AspectJ Properties ---
AspectJ Compiler 1.6.7 built on Friday Jan 1, 2010 at 03:49:38 GMT

into the dump. I'm not sure how aspectj-maven-plugin decides which version of ajc to use. Do you have any idea how to ?

Also is it posible to use ajc 1.7.0 with jdk 1.6?
Comment 9 Andrew Clement CLA 2012-08-30 11:19:57 EDT
I'm no maven expert but in the example I was just looking at I see that the dependency block is inside the plugin block for the aspectj-maven-plugin:

<plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>aspectj-maven-plugin</artifactId>
                        <version>1.2</version>
                        <configuration>
                            <outxml>true</outxml>
                            <aspectLibraries>
                                <aspectLibrary>
                                    <groupId>org.springframework</groupId>
                                    <artifactId>spring-aspects</artifactId>
                                </aspectLibrary>
                                <aspectLibrary>
                                    <groupId>org.springframework.data</groupId>
                                    <artifactId>spring-data-neo4j-aspects</artifactId>
                                </aspectLibrary>
                            </aspectLibraries>
                            <source>1.6</source>
                            <target>1.6</target>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>compile</goal>
                                    <goal>test-compile</goal>
                                </goals>
                            </execution>
                        </executions>
                        <dependencies>
                            <dependency>
                                <groupId>org.aspectj</groupId>
                                <artifactId>aspectjrt</artifactId>
                                <version>${aspectj.version}</version>
                            </dependency>
                            <dependency>
                                <groupId>org.aspectj</groupId>
                                <artifactId>aspectjtools</artifactId>
                                <version>${aspectj.version}</version>
                            </dependency>
                        </dependencies>
                    </plugin>

maybe try that?

> Also is it posible to use ajc 1.7.0 with jdk 1.6?

Yep, AspectJ 1.7.0 supports source/target 1.6/1.5/1.4 - the java runtime required to execute AspectJ is 1.5 or later.
Comment 10 bodrin CLA 2012-08-30 16:01:50 EDT
I see that you can configure the (AspectJ Compiler) ajc version into the aspectj-maven-plugin via dependency block inside the plugin block. It seems that you are a maven expert too :) Thanks!

I have tested it with 1.7.0 - there is no problem!
(With 1.6.12, 1.6.11 the problem is present)
Thanks!
Comment 11 Andrew Clement CLA 2013-06-25 12:26:07 EDT
believed fixed in the 1.7 stream