123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388 |
- <!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>
-
- <!--
- Java 19: no new final language features, only preview/incubator ones:
- - "JEP 427: Pattern Matching for switch (Third Preview)" (syntax change, introducing 'when')
- - "JEP 405: Record Patterns (Preview)"
- - "JEP 425: Virtual Threads (Preview)" (API only)
- - "JEP 428: Structured Concurrency (Incubator)" (API only)
- -->
- <suite>
-
- <!-- Java ?? final, Java 17, 18, 19 preview -->
- <ajc-test dir="features1919/java19" vm="19" title="switch pattern matching preview 3 java">
- <compile files="SwitchPatternPreview3OK.java" options="--enable-preview -19" />
- <run class="SwitchPatternPreview3OK" vmargs="--enable-preview">
- <message></message>
- <stdout>
- <line text="null" />
- <line text="int 123" />
- <line text="long 999" />
- <line text="double 12.340000" />
- <line text="String foo" />
- <line text="[123, foo, 999, 12.34]" />
- <line text="Non-circle" />
- <line text="Small circle" />
- <line text="Large circle" />
- <line text="Sealed sub-class A" />
- <line text="Sealed sub-class B" />
- <line text="Sealed sub-record C" />
- <line text="absolute value 1: -1" />
- <line text="other integer: 0" />
- <line text="positive integer: 42" />
- <line text="other integer: -99" />
- <line text="positive integer: 123" />
- <line text="value unavailable: null" />
- </stdout>
- </run>
- </ajc-test>
-
- <!-- Java ?? final, Java 17, 18, 19 preview -->
- <ajc-test dir="features1919/java19" vm="19" title="switch pattern matching preview 3 aspect">
- <compile files="SwitchPatternPreview3Aspect.aj" options="--enable-preview -19" />
- <run class="Application" vmargs="--enable-preview">
- <stdout>
- <line text="null" />
- <line text="int 123" />
- <line text="long 999" />
- <line text="double 12.340000" />
- <line text="String foo" />
- <line text="[123, foo, 999, 12.34]" />
- <line text="Non-circle" />
- <line text="Small circle" />
- <line text="Large circle" />
- <line text="Sealed sub-class A" />
- <line text="Sealed sub-class B" />
- <line text="Sealed sub-record C" />
- <line text="absolute value 1: -1" />
- <line text="other integer: 0" />
- <line text="positive integer: 42" />
- <line text="other integer: -99" />
- <line text="positive integer: 123" />
- <line text="value unavailable: null" />
- </stdout>
- </run>
- </ajc-test>
-
- <!-- Java ?? final, Java 17, 18, 19 preview -->
- <ajc-test dir="features198/java17" vm="19" title="switch pattern matching error">
- <compile files="SwitchPatternError.java" options="--enable-preview -19">
- <!-- TODO: Add correct compiler error message, as soon as JDT Core supports it -->
- <message kind="error" file="SwitchPatternError.java" text="This case label is dominated by one of the preceding case label"/>
- </compile>
- </ajc-test>
-
- <!-- Java ?? final, Java 17, 18, 19 preview -->
- <ajc-test dir="features1919/java19" vm="19" title="switch pattern matching preview 3 error 1">
- <compile files="SwitchPatternPreview3Error1.java" options="--enable-preview -19">
- <!-- TODO: Add correct compiler error message, as soon as JDT Core supports it -->
- <message kind="error" file="SwitchPatternPreview3Error1.java" text="This case label is dominated by one of the preceding case label"/>
- </compile>
- </ajc-test>
-
- <!-- Java ?? final, Java 17, 18, 19 preview -->
- <ajc-test dir="features1919/java19" vm="19" title="switch pattern matching preview 3 error 2">
- <compile files="SwitchPatternPreview3Error2.java" options="--enable-preview -19">
- <!-- TODO: Add correct compiler error message, as soon as JDT Core supports it -->
- <message kind="error" file="SwitchPatternPreview3Error2.java" text="This case label is dominated by one of the preceding case label"/>
- </compile>
- </ajc-test>
-
- <!-- Java ?? final, Java 19 preview -->
- <ajc-test dir="features1919/java19" vm="19" title="record patterns">
- <compile files="RecordPatternsPreview1OK.java" options="--enable-preview -19"/>
- </ajc-test>
-
- <!-- Java ?? final, Java 19 preview -->
- <ajc-test dir="features1919/java19" vm="19" title="record patterns error">
- <compile files="RecordPatternsPreview1Error.java" options="--enable-preview -19">
- <message kind="error" file="RecordPatternsPreview1Error.java" text="Raw types are not allowed in record patterns"/>
- <message kind="error" file="RecordPatternsPreview1Error.java" text="Raw types are not allowed in record patterns"/>
- </compile>
- </ajc-test>
-
- <!-- Java ?? final, Java 19 preview -->
- <ajc-test dir="features1919/java19" vm="19" title="record patterns exhaustiveness 1">
- <compile files="RecordPatternsPreview1ExhaustivenessOK1.java" options="--enable-preview -19"/>
- <run class="RecordPatternsPreview1ExhaustivenessOK1" vmargs="--enable-preview">
- <stdout>
- <line text="y"/>
- <line text="a"/>
- </stdout>
- </run>
- </ajc-test>
-
- <!-- Java ?? final, Java 19 preview -->
- <ajc-test dir="features1919/java19" vm="19" title="record patterns exhaustiveness aspect">
- <compile files="RecordPatternsPreview1ExhaustivenessAspect.aj" options="--enable-preview -19"/>
- <!--
- TODO: Remove redundant default clause when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455
- has been fixed. But even with the default clause, it generates wrong byte code and throws runtime error:
- NoSuchMethodError: 'I Pair.x()'
- -->
- <!--run class="RecordPatternsPreview1ExhaustivenessAspect" vmargs="-XXX-enable-preview">
- <stdout>
- <line text="y"/>
- <line text="a"/>
- <line text="Pair[x=C@000, y=D@000]"/>
- </stdout>
- </run-->
- </ajc-test>
-
- <!-- Java ?? final, Java 19 preview -->
- <ajc-test dir="features1919/java19" vm="19" title="record patterns aspect">
- <compile files="RecordPatternsPreview1Aspect.aj" options="--enable-preview -19"/>
- <run class="RecordPatternsPreview1Aspect" vmargs="--enable-preview">
- <stdout>
- <line text="9"/>
- <line text="14"/>
- <line text="Doing something with Point[x=2, y=7]"/>
- <line text="Upper-left color: RED"/>
- <line text="Upper-left color: RED"/>
- <line text="Upper-left x coordinate: 1"/>
- <line text="Doing something with Rectangle[upperLeft=ColoredPoint[p=Point[x=1, y=6], c=RED], lowerRight=ColoredPoint[p=Point[x=4, y=6], c=BLUE]]"/>
- </stdout>
- </run>
- </ajc-test>
-
- <!-- Java ?? final, Java 19 preview -->
- <ajc-test dir="features1919/java19" vm="19" title="record patterns exhaustiveness error">
- <compile files="RecordPatternsPreview1ExhaustivenessError.java" options="--enable-preview -19">
- <message kind="error" file="RecordPatternsPreview1ExhaustivenessError.java" text="An enhanced switch statement should be exhaustive; a default label expected"/>
- </compile>
- </ajc-test>
-
- <!-- Java ?? final, Java 19 preview -->
- <ajc-test dir="features1919/java19" vm="19" title="record patterns exhaustiveness 2">
- <compile files="RecordPatternsPreview1ExhaustivenessOK2.java" options="--enable-preview -19"/>
- <run class="RecordPatternsPreview1ExhaustivenessOK2" vmargs="--enable-preview">
- <stdout>
- <line text="Bob 12"/>
- </stdout>
- </run>
- </ajc-test>
-
- <!-- Weaver error when declaring annotation with SOURCE retention, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=366085 -->
- <ajc-test dir="bugs1919/366085" vm="1.5" title="declare annotation with SOURCE retention">
- <compile files="Application.java DeclareAnnotationsAspect.aj ToString.java Marker.java" options="-1.5 -showWeaveInfo">
- <message kind="weave" text="'Application' (Application.java:1) is annotated with @Marker type annotation from 'DeclareAnnotationsAspect'"/>
- <message kind="weave" text="'public void Application.new(int)' (Application.java:4) is annotated with @Marker constructor annotation from 'DeclareAnnotationsAspect'"/>
- <message kind="weave" text="'public int Application.getNumber()' (Application.java:8) is annotated with @Marker method annotation from 'DeclareAnnotationsAspect'"/>
- <message kind="weave" text="'public int number' of type 'Application' (Application.java) is annotated with @Marker field annotation from 'DeclareAnnotationsAspect'"/>
- </compile>
- </ajc-test>
-
- <!-- RuntimeException in BcelWeaver, see https://github.com/eclipse/org.aspectj/issues/190 -->
- <ajc-test dir="bugs1919/github_190" vm="1.5" title="switch with Integer.MAX_VALUE case">
- <compile files="SwitchCaseWith_Integer_MAX_VALUE.java" options="-1.5 -showWeaveInfo">
- <message kind="weave" text="Join point 'method-execution(java.lang.String SwitchCaseWith_Integer_MAX_VALUE.switchTest(int))'"/>
- </compile>
- <run class="SwitchCaseWith_Integer_MAX_VALUE">
- <stdout>
- <line text="execution(String SwitchCaseWith_Integer_MAX_VALUE.switchTest(int))"/>
- <line text="CASE_1"/>
- </stdout>
- </run>
- </ajc-test>
-
- <!--
- 'Syntax error, insert "Expression" to complete Expression' when compiling parenthesised expressions
- containing AspectJ keywords, e.g. '(before)', see https://github.com/eclipse/org.aspectj/issues/20
- -->
- <ajc-test dir="bugs1919/github_20" vm="1.5" title="parenthesised expression with AspectJ keyword">
- <compile files="ParenthesisedAJKeywords.java" options="-1.5 -showWeaveInfo"/>
- <run class="ParenthesisedAJKeywords">
- <stdout>
- <line text="before"/>
- <line text="after"/>
- <line text="around"/>
- <line text="aspect"/>
- <line text="pointcut"/>
- <line text="declare"/>
- <line text="privileged"/>
- </stdout>
- </run>
- </ajc-test>
-
- <!--
- 'inner aspects must be static' when compiling an interface with an inner aspect which was not explicitly declared
- static, see https://github.com/eclipse/org.aspectj/issues/162
- -->
- <ajc-test dir="bugs1919/github_162" vm="1.5" title="inner aspect of interface is implicitly static">
- <compile files="InterfaceWithInnerClass.java" options="-1.5 -showWeaveInfo">
- <message kind="weave" text="method-execution(int InterfaceWithInnerClass$ImplicitlyStatic.getNumber())' in Type 'InterfaceWithInnerClass$ImplicitlyStatic'"/>
- <message kind="weave" text="method-execution(void InterfaceWithInnerClass$ImplicitlyStatic.main(java.lang.String[]))' in Type 'InterfaceWithInnerClass$ImplicitlyStatic'"/>
- </compile>
- <run class="InterfaceWithInnerClass$ImplicitlyStatic">
- <stdout>
- <line text="execution(void InterfaceWithInnerClass.ImplicitlyStatic.main(String[]))"/>
- <line text="execution(int InterfaceWithInnerClass.ImplicitlyStatic.getNumber())"/>
- <line text="11"/>
- </stdout>
- </run>
- </ajc-test>
-
- <!--
- When compiling aspect and target class together, matching works as expected,
- see https://github.com/eclipse/org.aspectj/issues/24
- -->
- <ajc-test dir="bugs1919/github_24" vm="1.5" title="exact array type matching, aspect compiled together with target class">
- <compile files="ExactlyMatchingAspect.aj MaybeMissingClass.java" options="-1.5 -showWeaveInfo">
- <!-- Even before the bugfix, in this case weaving worked as expected -->
- <message kind="weave" text="method-execution(MaybeMissingClass MaybeMissingClass.f1())"/>
- <message kind="weave" text="method-execution(MaybeMissingClass[] MaybeMissingClass.f2())"/>
- <message kind="weave" text="method-execution(MaybeMissingClass[][] MaybeMissingClass.f3())"/>
- <message kind="weave" text="method-execution(int MaybeMissingClass.f4())"/>
- <message kind="weave" text="method-execution(int[] MaybeMissingClass.f5())"/>
- <message kind="weave" text="method-execution(int[][] MaybeMissingClass.f6())"/>
- </compile>
- <run class="MaybeMissingClass">
- <stdout>
- <line text="MaybeMissingClass.f1"/>
- <line text="execution(MaybeMissingClass MaybeMissingClass.f1())"/>
- <line text="MaybeMissingClass.f2"/>
- <line text="execution(MaybeMissingClass[] MaybeMissingClass.f2())"/>
- <line text="MaybeMissingClass.f3"/>
- <line text="execution(MaybeMissingClass[][] MaybeMissingClass.f3())"/>
- <line text="MaybeMissingClass.f4"/>
- <line text="execution(int MaybeMissingClass.f4())"/>
- <line text="MaybeMissingClass.f5"/>
- <line text="execution(int[] MaybeMissingClass.f5())"/>
- <line text="MaybeMissingClass.f6"/>
- <line text="execution(int[][] MaybeMissingClass.f6())"/>
- </stdout>
- </run>
- </ajc-test>
-
- <!--
- When compiling aspect and target class separately, too many joinpoints are matched,
- see https://github.com/eclipse/org.aspectj/issues/24
- -->
- <ajc-test dir="bugs1919/github_24" vm="1.5" title="exact array type matching, aspect compiled separately from target class">
- <compile files="ExactlyMatchingAspect.aj" options="-1.5 -showWeaveInfo" outjar="aspect.jar">
- <message kind="warning" text="no match for this type name: MaybeMissingClass [Xlint:invalidAbsoluteTypeName]"/>
- <message kind="warning" text="advice defined in ExactlyMatchingAspect has not been applied [Xlint:adviceDidNotMatch]"/>
- </compile>
- <compile files="MaybeMissingClass.java" options="-1.5 -showWeaveInfo" aspectpath="aspect.jar">
- <!-- Before the bugfix, f1 would be woven twice, f2 not at all-->
- <message kind="weave" text="method-execution(MaybeMissingClass MaybeMissingClass.f1())"/>
- <message kind="weave" text="method-execution(MaybeMissingClass[] MaybeMissingClass.f2())"/>
- <message kind="weave" text="method-execution(MaybeMissingClass[][] MaybeMissingClass.f3())"/>
- <message kind="weave" text="method-execution(int MaybeMissingClass.f4())"/>
- <message kind="weave" text="method-execution(int[] MaybeMissingClass.f5())"/>
- <message kind="weave" text="method-execution(int[][] MaybeMissingClass.f6())"/>
- </compile>
- <run class="MaybeMissingClass" classpath="aspect.jar">
- <stdout>
- <line text="MaybeMissingClass.f1"/>
- <line text="execution(MaybeMissingClass MaybeMissingClass.f1())"/>
- <line text="MaybeMissingClass.f2"/>
- <line text="execution(MaybeMissingClass[] MaybeMissingClass.f2())"/>
- <line text="MaybeMissingClass.f3"/>
- <line text="execution(MaybeMissingClass[][] MaybeMissingClass.f3())"/>
- <line text="MaybeMissingClass.f4"/>
- <line text="execution(int MaybeMissingClass.f4())"/>
- <line text="MaybeMissingClass.f5"/>
- <line text="execution(int[] MaybeMissingClass.f5())"/>
- <line text="MaybeMissingClass.f6"/>
- <line text="execution(int[][] MaybeMissingClass.f6())"/>
- </stdout>
- </run>
- </ajc-test>
-
- <!--
- When compiling aspect and target class together, too many joinpoints are matched,
- see https://github.com/eclipse/org.aspectj/issues/24
- -->
- <ajc-test dir="bugs1919/github_24" vm="1.5" title="fuzzy array type matching, aspect compiled together with target class">
- <compile files="FuzzilyMatchingAspect.aj MaybeMissingClass.java" options="-1.5 -showWeaveInfo">
- <!-- Before the bugfix, both f1 and f2 would be woven twice -->
- <message kind="weave" text="method-execution(MaybeMissingClass MaybeMissingClass.f1())"/>
- <message kind="weave" text="method-execution(MaybeMissingClass[] MaybeMissingClass.f2())"/>
- <message kind="weave" text="method-execution(MaybeMissingClass[][] MaybeMissingClass.f3())"/>
- <message kind="weave" text="method-execution(int MaybeMissingClass.f4())"/>
- <message kind="weave" text="method-execution(int[] MaybeMissingClass.f5())"/>
- <message kind="weave" text="method-execution(int[][] MaybeMissingClass.f6())"/>
- </compile>
- <run class="MaybeMissingClass">
- <stdout>
- <line text="MaybeMissingClass.f1"/>
- <line text="execution(MaybeMissingClass MaybeMissingClass.f1())"/>
- <line text="MaybeMissingClass.f2"/>
- <line text="execution(MaybeMissingClass[] MaybeMissingClass.f2())"/>
- <line text="MaybeMissingClass.f3"/>
- <line text="execution(MaybeMissingClass[][] MaybeMissingClass.f3())"/>
- <line text="MaybeMissingClass.f4"/>
- <line text="execution(int MaybeMissingClass.f4())"/>
- <line text="MaybeMissingClass.f5"/>
- <line text="execution(int[] MaybeMissingClass.f5())"/>
- <line text="MaybeMissingClass.f6"/>
- <line text="execution(int[][] MaybeMissingClass.f6())"/>
- </stdout>
- </run>
- </ajc-test>
-
- <!--
- When compiling aspect and target class separately, too many joinpoints are matched,
- see https://github.com/eclipse/org.aspectj/issues/24
- -->
- <ajc-test dir="bugs1919/github_24" vm="1.5" title="fuzzy array type matching, aspect compiled separately from target class">
- <compile files="FuzzilyMatchingAspect.aj" options="-1.5 -showWeaveInfo" outjar="aspect.jar">
- <message kind="warning" text="advice defined in FuzzilyMatchingAspect has not been applied [Xlint:adviceDidNotMatch]"/>
- </compile>
- <compile files="MaybeMissingClass.java" options="-1.5 -showWeaveInfo" aspectpath="aspect.jar">
- <!-- Before the bugfix, both f1 and f2 would be woven twice -->
- <message kind="weave" text="method-execution(MaybeMissingClass MaybeMissingClass.f1())"/>
- <message kind="weave" text="method-execution(MaybeMissingClass[] MaybeMissingClass.f2())"/>
- <message kind="weave" text="method-execution(MaybeMissingClass[][] MaybeMissingClass.f3())"/>
- <message kind="weave" text="method-execution(int MaybeMissingClass.f4())"/>
- <message kind="weave" text="method-execution(int[] MaybeMissingClass.f5())"/>
- <message kind="weave" text="method-execution(int[][] MaybeMissingClass.f6())"/>
- </compile>
- <run class="MaybeMissingClass" classpath="aspect.jar">
- <stdout>
- <line text="MaybeMissingClass.f1"/>
- <line text="execution(MaybeMissingClass MaybeMissingClass.f1())"/>
- <line text="MaybeMissingClass.f2"/>
- <line text="execution(MaybeMissingClass[] MaybeMissingClass.f2())"/>
- <line text="MaybeMissingClass.f3"/>
- <line text="execution(MaybeMissingClass[][] MaybeMissingClass.f3())"/>
- <line text="MaybeMissingClass.f4"/>
- <line text="execution(int MaybeMissingClass.f4())"/>
- <line text="MaybeMissingClass.f5"/>
- <line text="execution(int[] MaybeMissingClass.f5())"/>
- <line text="MaybeMissingClass.f6"/>
- <line text="execution(int[][] MaybeMissingClass.f6())"/>
- </stdout>
- </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>
|