Skip to content

Commit

Permalink
Switch to Java 22 + add basic test suite
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
kriegaex committed Mar 22, 2024
1 parent 08fc5f7 commit 9279adc
Show file tree
Hide file tree
Showing 16 changed files with 571 additions and 29 deletions.
6 changes: 3 additions & 3 deletions docs/devguide/ajc.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ Limitations which apply to both LTW and CTW modes include:
<Directory> defaults to the current working dir.

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

Expand Down
3 changes: 0 additions & 3 deletions docs/release/README-1.9.21.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
:doctype: book
:leveloffset: +1

// 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
// document can be updated. After copying this document, remove the comment from the previous one.

The releases 1.9.21, 1.9.21.1 and 1.9.21.2 are described together in this document.

= AspectJ 1.9.21.2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
compiler.name = AspectJ Compiler
# AspectJ_JDK_Update: Update not only for new Java versions, but each time JDT Core is updated with an upstream merge.
# Always make sure to update to the latest merge commit ID and date of the latest upstream commit.
compiler.version = Eclipse Compiler 8398f6c1210ec3 (13Feb2024) - Java21
compiler.version = Eclipse Compiler b2705b00e91be7 (20Mar2024) - Java22
compiler.copyright =

misc.version = {0} {1} - {2} {3}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public String toString() {
// AspectJ_JDK_Update: Check minimum supported ECJ version, currently 1.3
public static final int JAVA_VERSION_MIN = 3;
// AspectJ_JDK_Update: Check maximum supported ECJ version
public static final int JAVA_VERSION_MAX = 21;
public static final int JAVA_VERSION_MAX = 22;

static final String[] SOURCE_INPUTS;
static final String[] TARGET_INPUTS;
Expand Down
2 changes: 1 addition & 1 deletion tests/features1921/java21/UnnamedPatternsPreview1Aspect.aj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import java.util.stream.Stream;
/**
* Examples taken from <a href="https://openjdk.org/jeps/443">JEP 443</a>
*/
public class UnnamedPatternsPreview1Aspect {
public aspect UnnamedPatternsPreview1Aspect {
public static void main(String[] args) {}

before() : execution(* main(String[])) {
Expand Down
4 changes: 3 additions & 1 deletion tests/src/test/java/org/aspectj/systemtest/AllTests19.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.aspectj.systemtest.ajc192.AllTestsAspectJ192;
import org.aspectj.systemtest.ajc1920.AllTestsAspectJ1920;
import org.aspectj.systemtest.ajc1921.AllTestsAspectJ1921;
import org.aspectj.systemtest.ajc1922.AllTestsAspectJ1922;
import org.aspectj.systemtest.ajc193.AllTestsAspectJ193;
import org.aspectj.systemtest.ajc195.AllTestsAspectJ195;
import org.aspectj.systemtest.ajc196.AllTestsAspectJ196;
Expand Down Expand Up @@ -43,8 +44,9 @@ public static Test suite() {
suite.addTest(AllTestsAspectJ199.suite());
suite.addTest(AllTestsAspectJ1919.suite());
suite.addTest(AllTestsAspectJ1920.suite());
// AspectJ_JDK_Update
suite.addTest(AllTestsAspectJ1921.suite());
// AspectJ_JDK_Update
suite.addTest(AllTestsAspectJ1922.suite());
suite.addTest(AllTests18.suite());
// $JUnit-END$
return suite;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,6 @@
import org.aspectj.tools.ant.taskdefs.AjcTask;
import org.aspectj.util.LangUtil;

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

/**
* @author Alexander Kriegisch
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ public void testStringPatternsAspect() {
/**
* Still not implemented with the Java 21 release Eclipse 2023-12 (4.30),
* see <a href="https://github.com/eclipse-jdt/eclipse.jdt.core/issues/893">GitHub issue 893</a>.
* <p>
* TODO: Activate after JDT Core implementation and merge.
*/
public void testUnnamedPatterns() {
//runTest("unnamed patterns");
Expand All @@ -43,8 +41,6 @@ public void testUnnamedPatterns() {
/**
* Still not implemented with the Java 21 release Eclipse 2023-12 (4.30),
* see <a href="https://github.com/eclipse-jdt/eclipse.jdt.core/issues/893">GitHub issue 893</a>.
* <p>
* TODO: Activate after JDT Core implementation and merge.
*/
public void testUnnamedPatternsAspect() {
//runTest("unnamed patterns aspect");
Expand Down Expand Up @@ -73,8 +69,6 @@ public void testNamedAspectWithSimpleMainMethod() {
/**
* Still not implemented with the Java 21 release Eclipse 2023-12 (4.30),
* see <a href="https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1106">GitHub issue 1106</a>.
* <p>
* TODO: Activate after JDT Core implementation and merge.
*/
public void testUnnamedClassWithSimpleMainMethod() {
//runTest("unnamed class with simple main method");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*******************************************************************************
* Copyright (c) 2024 Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
*******************************************************************************/
package org.aspectj.systemtest.ajc1922;

import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.systemtest.ajc10x.Ajc10xTests;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;

/**
* @author Alexander Kriegisch
*/
public class Ajc1922TestsJava extends JavaVersionSpecificXMLBasedAjcTestCase {

private static final Constants.ClassFileVersion classFileVersion = Constants.ClassFileVersion.of(22);

public Ajc1922TestsJava() {
super(22);
}

public void testUnnamedPatterns() {
runTest("unnamed patterns");
}

public void testUnnamedPatternsAspect() {
runTest("unnamed patterns aspect");
}

/**
* Same as {@link Ajc10xTests#test052()}, but compiled to target 22 instead of 1.4
*/
public void testUnderscoreInPointcutPattern1() {
runTest("underscore can still be used in pointcut patterns on Java 21+ - 1");
}

public void testUnderscoreInPointcutPattern2() {
runTest("underscore can still be used in pointcut patterns on Java 21+ - 2");
}

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

@Override
protected java.net.URL getSpecFile() {
return getClassResource("ajc1922.xml");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*******************************************************************************
* Copyright (c) 2024 Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
*******************************************************************************/
package org.aspectj.systemtest.ajc1922;

import junit.framework.Test;
import junit.framework.TestSuite;
import org.aspectj.tools.ant.taskdefs.AjcTask;
import org.aspectj.util.LangUtil;

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

/**
* @author Alexander Kriegisch
*/
public class AllTestsAspectJ1922 {

private static final int JAVA_VERSION = 22;

public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.22 tests");
suite.addTest(Bugs1922Tests.suite());
if (LangUtil.isVMGreaterOrEqual(JAVA_VERSION)) {
suite.addTest(SanityTestsJava22.suite());
suite.addTest(Ajc1922TestsJava.suite());
}

// Do not run tests using a previous compiler's preview features anymore. They would all fail.
if (AjcTask.JAVA_VERSION_MAX == JAVA_VERSION) {
if (LangUtil.isVMGreaterOrEqual(JAVA_VERSION) && LangUtil.isVMLessOrEqual(JAVA_VERSION)) {
suite.addTest(Java22PreviewFeaturesTests.suite());
}
}
return suite;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (c) 2024 Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
*******************************************************************************/
package org.aspectj.systemtest.ajc1922;

import junit.framework.Test;
import org.aspectj.testing.XMLBasedAjcTestCase;

/**
* @author Alexander Kriegisch
*/
public class Bugs1922Tests extends XMLBasedAjcTestCase {

public void testDummy() {
//runTest("dummy");
}

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

@Override
protected java.net.URL getSpecFile() {
return getClassResource("ajc1922.xml");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*******************************************************************************
* Copyright (c) 2024 Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
*******************************************************************************/
package org.aspectj.systemtest.ajc1922;

import junit.framework.Test;
import org.aspectj.systemtest.ajc10x.Ajc10xTests;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;

/**
* @author Alexander Kriegisch
*/
public class Java22PreviewFeaturesTests extends JavaVersionSpecificXMLBasedAjcTestCase {

public Java22PreviewFeaturesTests() {
super(22, 22);
}

public void testStringPatterns() {
runTest("string patterns");
}

public void testStringPatternsAspect() {
runTest("string patterns aspect");
}

public void testNamedClassWithSimpleMainMethod() {
runTest("named class with simple main method");
}

public void testNamedAspectWithSimpleMainMethod() {
runTest("named aspect with simple main method");
}

/**
* Still not implemented with the Java 21 release Eclipse 2023-12 (4.30),
* see <a href="https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1106">GitHub issue 1106</a>.
*/
public void testUnnamedClassWithSimpleMainMethod() {
runTest("unnamed class with simple main method");
}

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

@Override
protected java.net.URL getSpecFile() {
return getClassResource("ajc1922.xml");
}

}
Loading

0 comments on commit 9279adc

Please sign in to comment.