Browse Source

Add regression test reproducing GitHub #214

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
tags/V1_9_20
Alexander Kriegisch 1 year ago
parent
commit
782cd415e2

+ 11
- 0
tests/bugs1919/github_214/Application.java View File

@@ -0,0 +1,11 @@
public class Application {
@MarkerTwo
@MarkerOne
public void greet(String name) {
System.out.println("Hello " + name + "!");
}

public static void main(String[] args) {
new Application().greet("world");
}
}

+ 11
- 0
tests/bugs1919/github_214/FirstAspect.java View File

@@ -0,0 +1,11 @@
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;

@Aspect
public class FirstAspect {
@Before("execution(@MarkerOne * *(..))")
public void beforeAdvice(JoinPoint joinPoint){
System.out.println("FirstAspect: " + joinPoint);
}
}

+ 1
- 0
tests/bugs1919/github_214/MarkerOne.java View File

@@ -0,0 +1 @@
public @interface MarkerOne { }

+ 1
- 0
tests/bugs1919/github_214/MarkerTwo.java View File

@@ -0,0 +1 @@
public @interface MarkerTwo { }

+ 12
- 0
tests/bugs1919/github_214/SecondAspect.java View File

@@ -0,0 +1,12 @@
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

@Aspect
public class SecondAspect {
@Around("execution(@MarkerTwo * *(..))")
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
System.out.println("SecondAspect: " + joinPoint);
return joinPoint.proceed();
}
}

+ 4
- 0
tests/src/test/java/org/aspectj/systemtest/ajc1919/Bugs1919Tests.java View File

@@ -47,6 +47,10 @@ public class Bugs1919Tests extends XMLBasedAjcTestCase {
runTest("fuzzy array type matching, aspect compiled separately from target class");
}

public void test_GitHub_214() {
runTest("ArrayIndexOutOfBoundsException with Xlint unorderedAdviceAtShadow=warning");
}

public static Test suite() {
return XMLBasedAjcTestCase.loadSuite(Bugs1919Tests.class);
}

+ 28
- 0
tests/src/test/resources/org/aspectj/systemtest/ajc1919/ajc1919.xml View File

@@ -357,4 +357,32 @@
</run>
</ajc-test>

<!--
https://github.com/eclipse/org.aspectj/issues/214
https://github.com/mojohaus/aspectj-maven-plugin/issues/164
Problem with multiple, subsequent weaving steps and '-Xlint:warning' or '-Xlint:unorderedAdviceAtShadow=warning'
java.lang.ArrayIndexOutOfBoundsException: 1
[ERROR] at org.aspectj.weaver.bcel.BcelShadow.prepareForMungers(BcelShadow.java:379)
[ERROR] at org.aspectj.weaver.Shadow.implement(Shadow.java:546)
-->
<ajc-test dir="bugs1919/github_214" vm="1.5" title="ArrayIndexOutOfBoundsException with Xlint unorderedAdviceAtShadow=warning">
<compile files="FirstAspect.java MarkerOne.java" options="-1.8 -showWeaveInfo -Xlint:warning" outjar="first-aspect.jar">
<message kind="warning" text="can not build thisJoinPoint lazily for this advice since it has no suitable guard [Xlint:noGuardForLazyTjp]"/>
<message kind="warning" text="advice defined in FirstAspect has not been applied [Xlint:adviceDidNotMatch]"/>
</compile>
<compile files="Application.java MarkerTwo.java" options="-1.5 -showWeaveInfo -Xlint:warning" classpath="first-aspect.jar" outjar="application.jar"/>
<compile files="SecondAspect.java" options="-1.5 -showWeaveInfo -Xlint:warning" aspectpath="first-aspect.jar" inpath="application.jar" outjar="second-aspect.jar">
<message kind="warning" text="can not build thisJoinPoint lazily for this advice since it has no suitable guard [Xlint:noGuardForLazyTjp]"/>
<message kind="warning" text="at this shadow method-execution(void Application.greet(java.lang.String)) no precedence is specified between advice applying from aspect FirstAspect and aspect SecondAspect [Xlint:unorderedAdviceAtShadow]"/>
<message kind="warning" text="can not implement lazyTjp at joinpoint method-execution(void Application.greet(java.lang.String)) because of advice conflicts, see secondary locations to find conflicting advice [Xlint:multipleAdviceStoppingLazyTjp]"/>
<message kind="weave" text="method-execution(void Application.greet(java.lang.String))' in Type 'Application' (Application.java:4) advised by around advice from 'SecondAspect'"/>
<message kind="weave" text="method-execution(void Application.greet(java.lang.String))' in Type 'Application' (Application.java:4) advised by before advice from 'FirstAspect'"/>
</compile>
<run class="Application" classpath="second-aspect.jar first-aspect.jar">
<stdout>
<line text="Hello world!"/>
</stdout>
</run>
</ajc-test>

</suite>

Loading…
Cancel
Save