Skip to content

Commit 9279adc

Browse files
committed
Switch to Java 22 + add basic test suite
The tests from Java 21 were copied to 22. Inactive ones were activated after their features under test were fixed/implemented. Preview ones were promotes to final ones for unnamed variables and patterns. TODO: Add tests for new Java 22 features and maybe adjust or amend existing feature tests, if preview or final characteristics have changed since Java 21. Signed-off-by: Alexander Kriegisch <[email protected]>
1 parent 08fc5f7 commit 9279adc

File tree

16 files changed

+571
-29
lines changed

16 files changed

+571
-29
lines changed

docs/devguide/ajc.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,11 @@ Limitations which apply to both LTW and CTW modes include:
178178
<Directory> defaults to the current working dir.
179179

180180
// AspectJ_JDK_Update: increment max. version and, if necessary, min. version
181-
`-source <[1.3 to 21]>`::
181+
`-source <[1.3 to 22]>`::
182182
Set source file Java language level
183-
`-target <[1.3 to 21]>`::
183+
`-target <[1.3 to 22]>`::
184184
Set classfile Java bytecode level
185-
`-<[1.3 to 21]>`::
185+
`-<[1.3 to 22]>`::
186186
Set compiler compliance level. Implies identical `-source` and `-target` levels.
187187
E.g., `-11` implies `-source 11` and `-target 11`.
188188

docs/release/README-1.9.21.adoc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
:doctype: book
33
:leveloffset: +1
44

5-
// AspectJ_JDK_Update: Each a.b.c release needs a new release notes document. For a.b.c.d minors, the existing a.b.c
6-
// document can be updated. After copying this document, remove the comment from the previous one.
7-
85
The releases 1.9.21, 1.9.21.1 and 1.9.21.2 are described together in this document.
96

107
= AspectJ 1.9.21.2

org.aspectj.ajdt.core/src/main/resources/org/aspectj/org/eclipse/jdt/internal/compiler/batch/messages_aspectj.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
compiler.name = AspectJ Compiler
22
# AspectJ_JDK_Update: Update not only for new Java versions, but each time JDT Core is updated with an upstream merge.
33
# Always make sure to update to the latest merge commit ID and date of the latest upstream commit.
4-
compiler.version = Eclipse Compiler 8398f6c1210ec3 (13Feb2024) - Java21
4+
compiler.version = Eclipse Compiler b2705b00e91be7 (20Mar2024) - Java22
55
compiler.copyright =
66

77
misc.version = {0} {1} - {2} {3}

taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public String toString() {
253253
// AspectJ_JDK_Update: Check minimum supported ECJ version, currently 1.3
254254
public static final int JAVA_VERSION_MIN = 3;
255255
// AspectJ_JDK_Update: Check maximum supported ECJ version
256-
public static final int JAVA_VERSION_MAX = 21;
256+
public static final int JAVA_VERSION_MAX = 22;
257257

258258
static final String[] SOURCE_INPUTS;
259259
static final String[] TARGET_INPUTS;

tests/features1921/java21/UnnamedPatternsPreview1Aspect.aj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import java.util.stream.Stream;
88
/**
99
* Examples taken from <a href="https://openjdk.org/jeps/443">JEP 443</a>
1010
*/
11-
public class UnnamedPatternsPreview1Aspect {
11+
public aspect UnnamedPatternsPreview1Aspect {
1212
public static void main(String[] args) {}
1313

1414
before() : execution(* main(String[])) {

tests/src/test/java/org/aspectj/systemtest/AllTests19.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.aspectj.systemtest.ajc192.AllTestsAspectJ192;
1414
import org.aspectj.systemtest.ajc1920.AllTestsAspectJ1920;
1515
import org.aspectj.systemtest.ajc1921.AllTestsAspectJ1921;
16+
import org.aspectj.systemtest.ajc1922.AllTestsAspectJ1922;
1617
import org.aspectj.systemtest.ajc193.AllTestsAspectJ193;
1718
import org.aspectj.systemtest.ajc195.AllTestsAspectJ195;
1819
import org.aspectj.systemtest.ajc196.AllTestsAspectJ196;
@@ -43,8 +44,9 @@ public static Test suite() {
4344
suite.addTest(AllTestsAspectJ199.suite());
4445
suite.addTest(AllTestsAspectJ1919.suite());
4546
suite.addTest(AllTestsAspectJ1920.suite());
46-
// AspectJ_JDK_Update
4747
suite.addTest(AllTestsAspectJ1921.suite());
48+
// AspectJ_JDK_Update
49+
suite.addTest(AllTestsAspectJ1922.suite());
4850
suite.addTest(AllTests18.suite());
4951
// $JUnit-END$
5052
return suite;

tests/src/test/java/org/aspectj/systemtest/ajc1921/AllTestsAspectJ1921.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,6 @@
1212
import org.aspectj.tools.ant.taskdefs.AjcTask;
1313
import org.aspectj.util.LangUtil;
1414

15-
// AspectJ_JDK_Update
16-
// - Copy 'ajc*' package with all classes to a new package, incrementing the version number in the package
17-
// - Rename all classes, incrementing version numbers
18-
// - Add this class to the suite in class AllTests19
19-
// - Increment version numbers in strings, method calls and constants to the appropriate values, creating necessary
20-
// methods and constants classes providing them, if they do not exist yet
21-
// - Also increment references to 'ajc*.xml' and 'sanity-tests-*.xml' test definition, copying the previous
22-
// tests/src/test/resources/org/aspectj/systemtest/ajc* directory, incrementing all names and adjusting the XML
23-
// file contents appropriately
24-
// - Search for other 'AspectJ_JDK_Update' hints in the repository, also performing the necessary to-dos there
25-
// - Remove this comment from the previous class version after copying this one
26-
2715
/**
2816
* @author Alexander Kriegisch
2917
*/

tests/src/test/java/org/aspectj/systemtest/ajc1921/Java21PreviewFeaturesTests.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ public void testStringPatternsAspect() {
3232
/**
3333
* Still not implemented with the Java 21 release Eclipse 2023-12 (4.30),
3434
* see <a href="https://github.com/eclipse-jdt/eclipse.jdt.core/issues/893">GitHub issue 893</a>.
35-
* <p>
36-
* TODO: Activate after JDT Core implementation and merge.
3735
*/
3836
public void testUnnamedPatterns() {
3937
//runTest("unnamed patterns");
@@ -43,8 +41,6 @@ public void testUnnamedPatterns() {
4341
/**
4442
* Still not implemented with the Java 21 release Eclipse 2023-12 (4.30),
4543
* see <a href="https://github.com/eclipse-jdt/eclipse.jdt.core/issues/893">GitHub issue 893</a>.
46-
* <p>
47-
* TODO: Activate after JDT Core implementation and merge.
4844
*/
4945
public void testUnnamedPatternsAspect() {
5046
//runTest("unnamed patterns aspect");
@@ -73,8 +69,6 @@ public void testNamedAspectWithSimpleMainMethod() {
7369
/**
7470
* Still not implemented with the Java 21 release Eclipse 2023-12 (4.30),
7571
* see <a href="https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1106">GitHub issue 1106</a>.
76-
* <p>
77-
* TODO: Activate after JDT Core implementation and merge.
7872
*/
7973
public void testUnnamedClassWithSimpleMainMethod() {
8074
//runTest("unnamed class with simple main method");
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2024 Contributors
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v 2.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
7+
*******************************************************************************/
8+
package org.aspectj.systemtest.ajc1922;
9+
10+
import junit.framework.Test;
11+
import org.aspectj.apache.bcel.Constants;
12+
import org.aspectj.systemtest.ajc10x.Ajc10xTests;
13+
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
14+
import org.aspectj.testing.XMLBasedAjcTestCase;
15+
16+
/**
17+
* @author Alexander Kriegisch
18+
*/
19+
public class Ajc1922TestsJava extends JavaVersionSpecificXMLBasedAjcTestCase {
20+
21+
private static final Constants.ClassFileVersion classFileVersion = Constants.ClassFileVersion.of(22);
22+
23+
public Ajc1922TestsJava() {
24+
super(22);
25+
}
26+
27+
public void testUnnamedPatterns() {
28+
runTest("unnamed patterns");
29+
}
30+
31+
public void testUnnamedPatternsAspect() {
32+
runTest("unnamed patterns aspect");
33+
}
34+
35+
/**
36+
* Same as {@link Ajc10xTests#test052()}, but compiled to target 22 instead of 1.4
37+
*/
38+
public void testUnderscoreInPointcutPattern1() {
39+
runTest("underscore can still be used in pointcut patterns on Java 21+ - 1");
40+
}
41+
42+
public void testUnderscoreInPointcutPattern2() {
43+
runTest("underscore can still be used in pointcut patterns on Java 21+ - 2");
44+
}
45+
46+
public static Test suite() {
47+
return XMLBasedAjcTestCase.loadSuite(Ajc1922TestsJava.class);
48+
}
49+
50+
@Override
51+
protected java.net.URL getSpecFile() {
52+
return getClassResource("ajc1922.xml");
53+
}
54+
55+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2024 Contributors
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v 2.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
7+
*******************************************************************************/
8+
package org.aspectj.systemtest.ajc1922;
9+
10+
import junit.framework.Test;
11+
import junit.framework.TestSuite;
12+
import org.aspectj.tools.ant.taskdefs.AjcTask;
13+
import org.aspectj.util.LangUtil;
14+
15+
// AspectJ_JDK_Update
16+
// - Copy 'ajc*' package with all classes to a new package, incrementing the version number in the package
17+
// - Rename all classes, incrementing version numbers
18+
// - Add this class to the suite in class AllTests19
19+
// - Increment version numbers in strings, method calls and constants to the appropriate values, creating necessary
20+
// methods and constants classes providing them, if they do not exist yet
21+
// - Also increment references to 'ajc*.xml' and 'sanity-tests-*.xml' test definition, copying the previous
22+
// tests/src/test/resources/org/aspectj/systemtest/ajc* directory, incrementing all names and adjusting the XML
23+
// file contents appropriately
24+
// - Search for other 'AspectJ_JDK_Update' hints in the repository, also performing the necessary to-dos there
25+
// - Remove this comment from the previous class version after copying this one
26+
27+
/**
28+
* @author Alexander Kriegisch
29+
*/
30+
public class AllTestsAspectJ1922 {
31+
32+
private static final int JAVA_VERSION = 22;
33+
34+
public static Test suite() {
35+
TestSuite suite = new TestSuite("AspectJ 1.9.22 tests");
36+
suite.addTest(Bugs1922Tests.suite());
37+
if (LangUtil.isVMGreaterOrEqual(JAVA_VERSION)) {
38+
suite.addTest(SanityTestsJava22.suite());
39+
suite.addTest(Ajc1922TestsJava.suite());
40+
}
41+
42+
// Do not run tests using a previous compiler's preview features anymore. They would all fail.
43+
if (AjcTask.JAVA_VERSION_MAX == JAVA_VERSION) {
44+
if (LangUtil.isVMGreaterOrEqual(JAVA_VERSION) && LangUtil.isVMLessOrEqual(JAVA_VERSION)) {
45+
suite.addTest(Java22PreviewFeaturesTests.suite());
46+
}
47+
}
48+
return suite;
49+
}
50+
}

0 commit comments

Comments
 (0)