Browse Source

New abstract class JavaVersionSpecificXMLBasedAjcTestCase

Replaces now obsolete base classes
  - XMLBasedAjcTestCaseForJava[n]OrLater,
  - XMLBasedAjcTestCaseForJava[n]Only.

The new class is parametrised with minimum and maximum Java version and
hence can replace all the other classes. This does not only apply the
DRY principle, but also makes adding tests for new Java versions less
tedious.

By chance, I also noticed missing sanity tests for Java 12, which I
added as a little drive-by benefit.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
tags/V1_9_21_2
Alexander Kriegisch 2 months ago
parent
commit
47db35bb48
72 changed files with 505 additions and 870 deletions
  1. 2
    2
      taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java
  2. 48
    0
      testing/src/test/java/org/aspectj/testing/JavaVersionSpecificXMLBasedAjcTestCase.java
  3. 0
    30
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava10OrLater.java
  4. 0
    30
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava11OrLater.java
  5. 0
    30
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava12OrLater.java
  6. 0
    30
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava13OrLater.java
  7. 0
    38
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava14Only.java
  8. 0
    27
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava14OrLater.java
  9. 0
    38
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava15Only.java
  10. 0
    27
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava15OrLater.java
  11. 0
    40
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava16Only.java
  12. 0
    27
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava16OrLater.java
  13. 0
    40
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava17Only.java
  14. 0
    27
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava17OrLater.java
  15. 0
    40
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18Only.java
  16. 0
    27
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18OrLater.java
  17. 0
    40
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava19Only.java
  18. 0
    27
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava19OrLater.java
  19. 0
    40
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava20Only.java
  20. 0
    27
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava20OrLater.java
  21. 0
    42
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava21Only.java
  22. 0
    27
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava21OrLater.java
  23. 0
    30
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava9OrLater.java
  24. 6
    4
      tests/src/test/java/org/aspectj/systemtest/ajc190/Ajc190Tests.java
  25. 0
    2
      tests/src/test/java/org/aspectj/systemtest/ajc190/AllTestsAspectJ190.java
  26. 6
    4
      tests/src/test/java/org/aspectj/systemtest/ajc190/ModuleTests.java
  27. 1
    1
      tests/src/test/java/org/aspectj/systemtest/ajc190/SanityTests19.java
  28. 6
    4
      tests/src/test/java/org/aspectj/systemtest/ajc191/Ajc191Tests.java
  29. 0
    2
      tests/src/test/java/org/aspectj/systemtest/ajc191/AllTestsAspectJ191.java
  30. 1
    2
      tests/src/test/java/org/aspectj/systemtest/ajc191/SanityTestsJava10.java
  31. 5
    2
      tests/src/test/java/org/aspectj/systemtest/ajc1919/Ajc1919TestsJava.java
  32. 9
    5
      tests/src/test/java/org/aspectj/systemtest/ajc1919/AllTestsAspectJ1919.java
  33. 6
    2
      tests/src/test/java/org/aspectj/systemtest/ajc1919/Java19PreviewFeaturesTests.java
  34. 6
    3
      tests/src/test/java/org/aspectj/systemtest/ajc1919/SanityTestsJava19.java
  35. 3
    6
      tests/src/test/java/org/aspectj/systemtest/ajc192/Ajc192Tests.java
  36. 0
    2
      tests/src/test/java/org/aspectj/systemtest/ajc192/AllTestsAspectJ192.java
  37. 7
    4
      tests/src/test/java/org/aspectj/systemtest/ajc192/SanityTestsJava11.java
  38. 6
    2
      tests/src/test/java/org/aspectj/systemtest/ajc1920/Ajc1920TestsJava.java
  39. 8
    5
      tests/src/test/java/org/aspectj/systemtest/ajc1920/AllTestsAspectJ1920.java
  40. 6
    2
      tests/src/test/java/org/aspectj/systemtest/ajc1920/Java20PreviewFeaturesTests.java
  41. 6
    2
      tests/src/test/java/org/aspectj/systemtest/ajc1920/SanityTestsJava20.java
  42. 15
    9
      tests/src/test/java/org/aspectj/systemtest/ajc1921/Ajc1921TestsJava.java
  43. 9
    5
      tests/src/test/java/org/aspectj/systemtest/ajc1921/AllTestsAspectJ1921.java
  44. 6
    2
      tests/src/test/java/org/aspectj/systemtest/ajc1921/Java21PreviewFeaturesTests.java
  45. 6
    2
      tests/src/test/java/org/aspectj/systemtest/ajc1921/SanityTestsJava21.java
  46. 7
    5
      tests/src/test/java/org/aspectj/systemtest/ajc193/Ajc193Tests.java
  47. 6
    1
      tests/src/test/java/org/aspectj/systemtest/ajc193/AllTestsAspectJ193.java
  48. 0
    31
      tests/src/test/java/org/aspectj/systemtest/ajc193/Java13Tests.java
  49. 93
    0
      tests/src/test/java/org/aspectj/systemtest/ajc193/SanityTestsJava12.java
  50. 2
    1
      tests/src/test/java/org/aspectj/systemtest/ajc195/AllTestsAspectJ195.java
  51. 6
    2
      tests/src/test/java/org/aspectj/systemtest/ajc195/SanityTestsJava13.java
  52. 7
    4
      tests/src/test/java/org/aspectj/systemtest/ajc196/Ajc196Tests.java
  53. 10
    6
      tests/src/test/java/org/aspectj/systemtest/ajc196/AllTestsAspectJ196.java
  54. 7
    4
      tests/src/test/java/org/aspectj/systemtest/ajc196/Java14PreviewFeaturesTests.java
  55. 7
    4
      tests/src/test/java/org/aspectj/systemtest/ajc196/SanityTestsJava14.java
  56. 15
    9
      tests/src/test/java/org/aspectj/systemtest/ajc197/Ajc197TestsJava.java
  57. 10
    5
      tests/src/test/java/org/aspectj/systemtest/ajc197/AllTestsAspectJ197.java
  58. 6
    2
      tests/src/test/java/org/aspectj/systemtest/ajc197/Java16PreviewFeaturesTests.java
  59. 6
    2
      tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava15.java
  60. 6
    2
      tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava16.java
  61. 12
    6
      tests/src/test/java/org/aspectj/systemtest/ajc198/Ajc198TestsJava.java
  62. 10
    6
      tests/src/test/java/org/aspectj/systemtest/ajc198/AllTestsAspectJ198.java
  63. 6
    3
      tests/src/test/java/org/aspectj/systemtest/ajc198/Bugs198Java11Tests.java
  64. 5
    2
      tests/src/test/java/org/aspectj/systemtest/ajc198/CompileWithReleaseTests.java
  65. 6
    2
      tests/src/test/java/org/aspectj/systemtest/ajc198/Java17PreviewFeaturesTests.java
  66. 6
    2
      tests/src/test/java/org/aspectj/systemtest/ajc198/SanityTestsJava17.java
  67. 5
    2
      tests/src/test/java/org/aspectj/systemtest/ajc199/Ajc199TestsJava.java
  68. 9
    6
      tests/src/test/java/org/aspectj/systemtest/ajc199/AllTestsAspectJ199.java
  69. 6
    2
      tests/src/test/java/org/aspectj/systemtest/ajc199/Java18PreviewFeaturesTests.java
  70. 6
    2
      tests/src/test/java/org/aspectj/systemtest/ajc199/SanityTestsJava18.java
  71. 69
    0
      tests/src/test/resources/org/aspectj/systemtest/ajc193/sanity-tests-12.xml
  72. 9
    1
      util/src/main/java/org/aspectj/util/LangUtil.java

+ 2
- 2
taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java View File

@@ -251,9 +251,9 @@ public class AjcTask extends MatchingTask {
public static final String COMMAND_EDITOR_NAME = AjcTask.class.getName() + ".COMMAND_EDITOR";

// AspectJ_JDK_Update: Check minimum supported ECJ version, currently 1.3
static final int JAVA_VERSION_MIN = 3;
public static final int JAVA_VERSION_MIN = 3;
// AspectJ_JDK_Update: Check maximum supported ECJ version
static final int JAVA_VERSION_MAX = 21;
public static final int JAVA_VERSION_MAX = 21;

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

+ 48
- 0
testing/src/test/java/org/aspectj/testing/JavaVersionSpecificXMLBasedAjcTestCase.java View File

@@ -0,0 +1,48 @@
/* *******************************************************************
* 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.testing;

import static org.aspectj.util.LangUtil.isVMGreaterOrEqual;
import static org.aspectj.util.LangUtil.isVMLessOrEqual;

/**
* A test case which only runs on specific Java versions
*
* @author Alexander Kriegisch
*/
public abstract class JavaVersionSpecificXMLBasedAjcTestCase extends XMLBasedAjcTestCase {
private final int minimumJavaVersion;
private final int maximumJavaVersion;

protected JavaVersionSpecificXMLBasedAjcTestCase(int minimumJavaVersion) {
this(minimumJavaVersion, Integer.MAX_VALUE);
}

protected JavaVersionSpecificXMLBasedAjcTestCase(int minimumJavaVersion, int maximumJavaVersion) {
this.minimumJavaVersion = minimumJavaVersion;
this.maximumJavaVersion = maximumJavaVersion;
}

@Override
public void setUp() throws Exception {
boolean withinBounds = isVMGreaterOrEqual(minimumJavaVersion) && isVMLessOrEqual(maximumJavaVersion);
if (!withinBounds) {
String errorMessage = "These tests must run on Java version ";
if (maximumJavaVersion == Integer.MAX_VALUE)
errorMessage += minimumJavaVersion + " or greater";
else if (maximumJavaVersion == minimumJavaVersion)
errorMessage += minimumJavaVersion + " only";
else
errorMessage += "range " + minimumJavaVersion + " to " + maximumJavaVersion;
throw new IllegalStateException(errorMessage);
}
super.setUp();
}

}

+ 0
- 30
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava10OrLater.java View File

@@ -1,30 +0,0 @@
/* *******************************************************************
* Copyright (c) 2018 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
*
* Contributors:
* Andy Clement
* ******************************************************************/
package org.aspectj.testing;

import org.aspectj.util.LangUtil;

/**
* Ensure sure tests are running on the right level of JDK.
*
* @author Andy Clement
*/
public abstract class XMLBasedAjcTestCaseForJava10OrLater extends XMLBasedAjcTestCase {

@Override
public void setUp() throws Exception {
if (!LangUtil.isVMGreaterOrEqual(10))
throw new IllegalStateException("These tests should be run on Java 10 or later");
super.setUp();
}

}

+ 0
- 30
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava11OrLater.java View File

@@ -1,30 +0,0 @@
/* *******************************************************************
* Copyright (c) 2018 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
*
* Contributors:
* Andy Clement
* ******************************************************************/
package org.aspectj.testing;

import org.aspectj.util.LangUtil;

/**
* Makes sure tests are running on the right level of JDK.
*
* @author Andy Clement
*/
public abstract class XMLBasedAjcTestCaseForJava11OrLater extends XMLBasedAjcTestCase {

@Override
public void setUp() throws Exception {
if (!LangUtil.isVMGreaterOrEqual(11))
throw new IllegalStateException("These tests should be run on Java 11 or later");
super.setUp();
}

}

+ 0
- 30
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava12OrLater.java View File

@@ -1,30 +0,0 @@
/* *******************************************************************
* Copyright (c) 2018 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
*
* Contributors:
* Andy Clement
* ******************************************************************/
package org.aspectj.testing;

import org.aspectj.util.LangUtil;

/**
* Ensure sure tests are running on the right level of JDK.
*
* @author Andy Clement
*/
public abstract class XMLBasedAjcTestCaseForJava12OrLater extends XMLBasedAjcTestCase {

@Override
public void setUp() throws Exception {
if (!LangUtil.isVMGreaterOrEqual(12))
throw new IllegalStateException("These tests should be run on Java 12 or later");
super.setUp();
}

}

+ 0
- 30
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava13OrLater.java View File

@@ -1,30 +0,0 @@
/* *******************************************************************
* Copyright (c) 2019 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
*
* Contributors:
* Andy Clement
* ******************************************************************/
package org.aspectj.testing;

import org.aspectj.util.LangUtil;

/**
* Makes sure tests are running on the right level of JDK.
*
* @author Andy Clement
*/
public abstract class XMLBasedAjcTestCaseForJava13OrLater extends XMLBasedAjcTestCase {

@Override
public void setUp() throws Exception {
if (!LangUtil.isVMGreaterOrEqual(13))
throw new IllegalStateException("These tests should be run on Java 13 or later");
super.setUp();
}

}

+ 0
- 38
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava14Only.java View File

@@ -1,38 +0,0 @@
/* *******************************************************************
* Copyright (c) 2021 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.testing;

/**
* Makes sure tests are running on the right level of JDK.
*
* @author Alexander Kriegisch
*/
public abstract class XMLBasedAjcTestCaseForJava14Only extends XMLBasedAjcTestCase {

@Override
public void setUp() throws Exception {
// Activate this block after upgrading to JDT Core Java 15
throw new IllegalStateException(
"These tests need a Java 14 level AspectJ compiler " +
"(e.g. because they use version-specific preview features). " +
"This compiler does not support preview features of a previous version anymore."
);
// Activate this block before upgrading to JDT Core Java 15
/*
if (!LangUtil.isVMGreaterOrEqual(14) || LangUtil.isVMGreaterOrEqual(15)) {
throw new IllegalStateException(
"These tests should be run on Java 14 only " +
"(e.g. because they use version-specific preview features)"
);
}
super.setUp();
*/
}

}

+ 0
- 27
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava14OrLater.java View File

@@ -1,27 +0,0 @@
/* *******************************************************************
* Copyright (c) 2020 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.testing;

import org.aspectj.util.LangUtil;

/**
* Makes sure tests are running on the right level of JDK.
*
* @author Andy Clement
*/
public abstract class XMLBasedAjcTestCaseForJava14OrLater extends XMLBasedAjcTestCase {

@Override
public void setUp() throws Exception {
if (!LangUtil.isVMGreaterOrEqual(14))
throw new IllegalStateException("These tests should be run on Java 14 or later");
super.setUp();
}

}

+ 0
- 38
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava15Only.java View File

@@ -1,38 +0,0 @@
/* *******************************************************************
* Copyright (c) 2021 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.testing;

/**
* Makes sure tests are running on the right level of JDK.
*
* @author Alexander Kriegisch
*/
public abstract class XMLBasedAjcTestCaseForJava15Only extends XMLBasedAjcTestCase {

@Override
public void setUp() throws Exception {
// Activate this block after upgrading to JDT Core Java 16
throw new IllegalStateException(
"These tests need a Java 15 level AspectJ compiler " +
"(e.g. because they use version-specific preview features). " +
"This compiler does not support preview features of a previous version anymore."
);
// Activate this block before upgrading to JDT Core Java 16
/*
if (!LangUtil.isVMGreaterOrEqual(15) || LangUtil.isVMGreaterOrEqual(16)) {
throw new IllegalStateException(
"These tests should be run on Java 15 only " +
"(e.g. because they use version-specific preview features)"
);
}
super.setUp();
*/
}

}

+ 0
- 27
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava15OrLater.java View File

@@ -1,27 +0,0 @@
/* *******************************************************************
* Copyright (c) 2021 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.testing;

import org.aspectj.util.LangUtil;

/**
* Makes sure tests are running on the right level of JDK.
*
* @author Alexander Kriegisch
*/
public abstract class XMLBasedAjcTestCaseForJava15OrLater extends XMLBasedAjcTestCase {

@Override
public void setUp() throws Exception {
if (!LangUtil.isVMGreaterOrEqual(15))
throw new IllegalStateException("These tests should be run on Java 15 or later");
super.setUp();
}

}

+ 0
- 40
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava16Only.java View File

@@ -1,40 +0,0 @@
/* *******************************************************************
* Copyright (c) 2021 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.testing;

import org.aspectj.util.LangUtil;

/**
* Makes sure tests are running on the right level of JDK.
*
* @author Alexander Kriegisch
*/
public abstract class XMLBasedAjcTestCaseForJava16Only extends XMLBasedAjcTestCase {

@Override
public void setUp() throws Exception {
// Activate this block after upgrading to JDT Core Java 17
throw new IllegalStateException(
"These tests need a Java 16 level AspectJ compiler " +
"(e.g. because they use version-specific preview features). " +
"This compiler does not support preview features of a previous version anymore."
);
// Activate this block before upgrading to JDT Core Java 17
/*
if (!LangUtil.isVMGreaterOrEqual(16) || LangUtil.isVMGreaterOrEqual(17)) {
throw new IllegalStateException(
"These tests should be run on Java 16 only " +
"(e.g. because they use version-specific preview features)"
);
}
super.setUp();
*/
}

}

+ 0
- 27
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava16OrLater.java View File

@@ -1,27 +0,0 @@
/* *******************************************************************
* Copyright (c) 2021 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.testing;

import org.aspectj.util.LangUtil;

/**
* Makes sure tests are running on the right level of JDK.
*
* @author Alexander Kriegisch
*/
public abstract class XMLBasedAjcTestCaseForJava16OrLater extends XMLBasedAjcTestCase {

@Override
public void setUp() throws Exception {
if (!LangUtil.isVMGreaterOrEqual(16))
throw new IllegalStateException("These tests should be run on Java 16 or later");
super.setUp();
}

}

+ 0
- 40
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava17Only.java View File

@@ -1,40 +0,0 @@
/* *******************************************************************
* Copyright (c) 2021 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.testing;

import org.aspectj.util.LangUtil;

/**
* Makes sure tests are running on the right level of JDK.
*
* @author Alexander Kriegisch
*/
public abstract class XMLBasedAjcTestCaseForJava17Only extends XMLBasedAjcTestCase {

@Override
public void setUp() throws Exception {
// Activate this block after upgrading to JDT Core Java 18
throw new IllegalStateException(
"These tests need a Java 17 level AspectJ compiler " +
"(e.g. because they use version-specific preview features). " +
"This compiler does not support preview features of a previous version anymore."
);
// Activate this block before upgrading to JDT Core Java 18
/*
if (!LangUtil.isVMGreaterOrEqual(17) || LangUtil.isVMGreaterOrEqual(18)) {
throw new IllegalStateException(
"These tests should be run on Java 17 only " +
"(e.g. because they use version-specific preview features)"
);
super.setUp();
}
*/
}

}

+ 0
- 27
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava17OrLater.java View File

@@ -1,27 +0,0 @@
/* *******************************************************************
* Copyright (c) 2021 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.testing;

import org.aspectj.util.LangUtil;

/**
* Makes sure tests are running on the right level of JDK.
*
* @author Alexander Kriegisch
*/
public abstract class XMLBasedAjcTestCaseForJava17OrLater extends XMLBasedAjcTestCase {

@Override
public void setUp() throws Exception {
if (!LangUtil.isVMGreaterOrEqual(17))
throw new IllegalStateException("These tests should be run on Java 17 or later");
super.setUp();
}

}

+ 0
- 40
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18Only.java View File

@@ -1,40 +0,0 @@
/* *******************************************************************
* Copyright (c) 2022 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.testing;

import org.aspectj.util.LangUtil;

/**
* Makes sure tests are running on the right level of JDK.
*
* @author Alexander Kriegisch
*/
public abstract class XMLBasedAjcTestCaseForJava18Only extends XMLBasedAjcTestCase {

@Override
public void setUp() throws Exception {
// Activate this block after upgrading to JDT Core Java 19
throw new IllegalStateException(
"These tests need a Java 18 level AspectJ compiler " +
"(e.g. because they use version-specific preview features). " +
"This compiler does not support preview features of a previous version anymore."
);
// Activate this block before upgrading to JDT Core Java 19
/*
if (!LangUtil.isVMGreaterOrEqual(18) || LangUtil.isVMGreaterOrEqual(19)) {
throw new IllegalStateException(
"These tests should be run on Java 18 only " +
"(e.g. because they use version-specific preview features)"
);
}
super.setUp();
*/
}

}

+ 0
- 27
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18OrLater.java View File

@@ -1,27 +0,0 @@
/* *******************************************************************
* Copyright (c) 2022 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.testing;

import org.aspectj.util.LangUtil;

/**
* Makes sure tests are running on the right level of JDK.
*
* @author Alexander Kriegisch
*/
public abstract class XMLBasedAjcTestCaseForJava18OrLater extends XMLBasedAjcTestCase {

@Override
public void setUp() throws Exception {
if (!LangUtil.isVMGreaterOrEqual(18))
throw new IllegalStateException("These tests should be run on Java 18 or later");
super.setUp();
}

}

+ 0
- 40
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava19Only.java View File

@@ -1,40 +0,0 @@
/* *******************************************************************
* Copyright (c) 2022 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.testing;

import org.aspectj.util.LangUtil;

/**
* Makes sure tests are running on the right level of JDK.
*
* @author Alexander Kriegisch
*/
public abstract class XMLBasedAjcTestCaseForJava19Only extends XMLBasedAjcTestCase {

@Override
public void setUp() throws Exception {
// Activate this block after upgrading to JDT Core Java 20
throw new IllegalStateException(
"These tests need a Java 19 level AspectJ compiler " +
"(e.g. because they use version-specific preview features). " +
"This compiler does not support preview features of a previous version anymore."
);
// Activate this block before upgrading to JDT Core Java 20
/*
if (!LangUtil.isVMGreaterOrEqual(19) || LangUtil.isVMGreaterOrEqual(20)) {
throw new IllegalStateException(
"These tests should be run on Java 19 only " +
"(e.g. because they use version-specific preview features)"
);
}
super.setUp();
*/
}

}

+ 0
- 27
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava19OrLater.java View File

@@ -1,27 +0,0 @@
/* *******************************************************************
* Copyright (c) 2022 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.testing;

import org.aspectj.util.LangUtil;

/**
* Makes sure tests are running on the right level of JDK.
*
* @author Alexander Kriegisch
*/
public abstract class XMLBasedAjcTestCaseForJava19OrLater extends XMLBasedAjcTestCase {

@Override
public void setUp() throws Exception {
if (!LangUtil.isVMGreaterOrEqual(19))
throw new IllegalStateException("These tests should be run on Java 19 or later");
super.setUp();
}

}

+ 0
- 40
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava20Only.java View File

@@ -1,40 +0,0 @@
/* *******************************************************************
* Copyright (c) 2022 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.testing;

import org.aspectj.util.LangUtil;

/**
* Makes sure tests are running on the right level of JDK.
*
* @author Alexander Kriegisch
*/
public abstract class XMLBasedAjcTestCaseForJava20Only extends XMLBasedAjcTestCase {

@Override
public void setUp() throws Exception {
// Activate this block after upgrading to JDT Core Java 21
throw new IllegalStateException(
"These tests need a Java 20 level AspectJ compiler " +
"(e.g. because they use version-specific preview features). " +
"This compiler does not support preview features of a previous version anymore."
);
// Activate this block before upgrading to JDT Core Java 21
/*
if (!LangUtil.isVMGreaterOrEqual(20) || LangUtil.isVMGreaterOrEqual(21)) {
throw new IllegalStateException(
"These tests should be run on Java 20 only " +
"(e.g. because they use version-specific preview features)"
);
}
super.setUp();
*/
}

}

+ 0
- 27
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava20OrLater.java View File

@@ -1,27 +0,0 @@
/* *******************************************************************
* Copyright (c) 2022 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.testing;

import org.aspectj.util.LangUtil;

/**
* Makes sure tests are running on the right level of JDK.
*
* @author Alexander Kriegisch
*/
public abstract class XMLBasedAjcTestCaseForJava20OrLater extends XMLBasedAjcTestCase {

@Override
public void setUp() throws Exception {
if (!LangUtil.isVMGreaterOrEqual(20))
throw new IllegalStateException("These tests should be run on Java 20 or later");
super.setUp();
}

}

+ 0
- 42
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava21Only.java View File

@@ -1,42 +0,0 @@
/* *******************************************************************
* Copyright (c) 2023 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.testing;

import org.aspectj.util.LangUtil;

/**
* Makes sure tests are running on the right level of JDK.
*
* @author Alexander Kriegisch
*/
public abstract class XMLBasedAjcTestCaseForJava21Only extends XMLBasedAjcTestCase {

@Override
public void setUp() throws Exception {
// AspectJ_JDK_Update
// Activate this block after upgrading to JDT Core Java 22
/*
throw new IllegalStateException(
"These tests need a Java 21 level AspectJ compiler " +
"(e.g. because they use version-specific preview features). " +
"This compiler does not support preview features of a previous version anymore."
);
*/
// AspectJ_JDK_Update
// Activate this block before upgrading to JDT Core Java 22
if (!LangUtil.isVMGreaterOrEqual(21) || LangUtil.isVMGreaterOrEqual(22)) {
throw new IllegalStateException(
"These tests should be run on Java 21 only " +
"(e.g. because they use version-specific preview features)"
);
}
super.setUp();
}

}

+ 0
- 27
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava21OrLater.java View File

@@ -1,27 +0,0 @@
/* *******************************************************************
* Copyright (c) 2023 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.testing;

import org.aspectj.util.LangUtil;

/**
* Makes sure tests are running on the right level of JDK.
*
* @author Alexander Kriegisch
*/
public abstract class XMLBasedAjcTestCaseForJava21OrLater extends XMLBasedAjcTestCase {

@Override
public void setUp() throws Exception {
if (!LangUtil.isVMGreaterOrEqual(21))
throw new IllegalStateException("These tests should be run on Java 21 or later");
super.setUp();
}

}

+ 0
- 30
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava9OrLater.java View File

@@ -1,30 +0,0 @@
/* *******************************************************************
* Copyright (c) 2018 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
*
* Contributors:
* Andy Clement
* ******************************************************************/
package org.aspectj.testing;

import org.aspectj.util.LangUtil;

/**
* Makes sure tests are running on the right level of JDK.
*
* @author Andy Clement
*/
public abstract class XMLBasedAjcTestCaseForJava9OrLater extends XMLBasedAjcTestCase {

@Override
public void setUp() throws Exception {
if (!LangUtil.isVMGreaterOrEqual(9))
throw new IllegalStateException("These tests should be run on Java 9 or later");
super.setUp();
}

}

+ 6
- 4
tests/src/test/java/org/aspectj/systemtest/ajc190/Ajc190Tests.java View File

@@ -10,15 +10,17 @@
*******************************************************************************/
package org.aspectj.systemtest.ajc190;

import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava9OrLater;

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

/**
* @author Andy Clement
*/
public class Ajc190Tests extends XMLBasedAjcTestCaseForJava9OrLater {
public class Ajc190Tests extends JavaVersionSpecificXMLBasedAjcTestCase {
public Ajc190Tests() {
super(9);
}

public void testParamAnnosNegative() {
runTest("param annos negative");

+ 0
- 2
tests/src/test/java/org/aspectj/systemtest/ajc190/AllTestsAspectJ190.java View File

@@ -17,13 +17,11 @@ public class AllTestsAspectJ190 {

public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.0 tests");
// $JUnit-BEGIN$
suite.addTest(Ajc190Tests.suite());
suite.addTest(SanityTests19.suite());
suite.addTest(EfficientTJPTests.suite());
suite.addTest(ModuleTests.suite());
suite.addTest(Annotations.suite());
// $JUnit-END$
return suite;
}
}

+ 6
- 4
tests/src/test/java/org/aspectj/systemtest/ajc190/ModuleTests.java View File

@@ -7,16 +7,15 @@
*******************************************************************************/
package org.aspectj.systemtest.ajc190;

import junit.framework.Test;
import org.aspectj.apache.bcel.classfile.Attribute;
import org.aspectj.apache.bcel.classfile.Code;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Method;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava9OrLater;
import org.aspectj.util.LangUtil;

import junit.framework.Test;

/**
* Building and weaving with modules in the picture.
*
@@ -25,7 +24,10 @@ import junit.framework.Test;
* @author Andy Clement
*
*/
public class ModuleTests extends XMLBasedAjcTestCaseForJava9OrLater {
public class ModuleTests extends JavaVersionSpecificXMLBasedAjcTestCase {
public ModuleTests() {
super(9);
}

public void testBuildAModule() {
runTest("build a module");

+ 1
- 1
tests/src/test/java/org/aspectj/systemtest/ajc190/SanityTests19.java View File

@@ -20,7 +20,7 @@ import junit.framework.Test;
* These are a copy of the earlier Sanity Tests created for 1.6 but these supply the -1.9 option
* to check code generation and modification with that version specified.
*/
public class SanityTests19 extends org.aspectj.testing.XMLBasedAjcTestCase {
public class SanityTests19 extends XMLBasedAjcTestCase {
public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(9).MAJOR;

// Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)

+ 6
- 4
tests/src/test/java/org/aspectj/systemtest/ajc191/Ajc191Tests.java View File

@@ -10,15 +10,17 @@
*******************************************************************************/
package org.aspectj.systemtest.ajc191;

import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava10OrLater;

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

/**
* @author Andy Clement
*/
public class Ajc191Tests extends XMLBasedAjcTestCaseForJava10OrLater {
public class Ajc191Tests extends JavaVersionSpecificXMLBasedAjcTestCase {
public Ajc191Tests() {
super(10);
}

public void testVar1() {
runTest("var 1");

+ 0
- 2
tests/src/test/java/org/aspectj/systemtest/ajc191/AllTestsAspectJ191.java View File

@@ -17,10 +17,8 @@ public class AllTestsAspectJ191 {

public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.1 tests");
// $JUnit-BEGIN$
suite.addTest(Ajc191Tests.suite());
suite.addTest(SanityTestsJava10.suite());
// $JUnit-END$
return suite;
}
}

+ 1
- 2
tests/src/test/java/org/aspectj/systemtest/ajc191/SanityTestsJava10.java View File

@@ -19,7 +19,7 @@ import junit.framework.Test;
*
* @author Andy Clement
*/
public class SanityTestsJava10 extends org.aspectj.testing.XMLBasedAjcTestCase {
public class SanityTestsJava10 extends XMLBasedAjcTestCase {
public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(10).MAJOR;

// Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
@@ -74,7 +74,6 @@ public class SanityTestsJava10 extends org.aspectj.testing.XMLBasedAjcTestCase {
checkVersion("A", Constants.ClassFileVersion.of(5).MAJOR, 0);
}

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

+ 5
- 2
tests/src/test/java/org/aspectj/systemtest/ajc1919/Ajc1919TestsJava.java View File

@@ -8,13 +8,16 @@
package org.aspectj.systemtest.ajc1919;

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

/**
* @author Alexander Kriegisch
*/
public class Ajc1919TestsJava extends XMLBasedAjcTestCaseForJava19OrLater {
public class Ajc1919TestsJava extends JavaVersionSpecificXMLBasedAjcTestCase {
public Ajc1919TestsJava() {
super(19);
}

public void testDummyJava19() {
//runTest("dummy Java 19");

+ 9
- 5
tests/src/test/java/org/aspectj/systemtest/ajc1919/AllTestsAspectJ1919.java View File

@@ -9,6 +9,7 @@ package org.aspectj.systemtest.ajc1919;

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

/**
@@ -16,19 +17,22 @@ import org.aspectj.util.LangUtil;
*/
public class AllTestsAspectJ1919 {

private static final int JAVA_VERSION = 19;

public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.19 tests");
suite.addTest(Bugs1919Tests.suite());
if (LangUtil.isVMGreaterOrEqual(19)) {
if (LangUtil.isVMGreaterOrEqual(JAVA_VERSION)) {
suite.addTest(SanityTestsJava19.suite());
suite.addTest(Ajc1919TestsJava.suite());
}

// Do not run tests using a previous compiler's preview features anymore. They would all fail.
/*
if (LangUtil.isVMGreaterOrEqual(19) && !LangUtil.isVMGreaterOrEqual(20)) {
suite.addTest(Java19PreviewFeaturesTests.suite());
if (AjcTask.JAVA_VERSION_MAX == JAVA_VERSION) {
if (LangUtil.isVMGreaterOrEqual(JAVA_VERSION) && LangUtil.isVMLessOrEqual(JAVA_VERSION)) {
suite.addTest(Java19PreviewFeaturesTests.suite());
}
}
*/
return suite;
}
}

+ 6
- 2
tests/src/test/java/org/aspectj/systemtest/ajc1919/Java19PreviewFeaturesTests.java View File

@@ -9,15 +9,19 @@ package org.aspectj.systemtest.ajc1919;

import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava19Only;

/**
* @author Alexander Kriegisch
*/
public class Java19PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava19Only {
public class Java19PreviewFeaturesTests extends JavaVersionSpecificXMLBasedAjcTestCase {
private static final Constants.ClassFileVersion classFileVersion = Constants.ClassFileVersion.of(19);

public Java19PreviewFeaturesTests() {
super(19, 19);
}

public void testSwitchPatternMatchingPreview3Java() {
runTest("switch pattern matching preview 3 java");
checkVersion("SwitchPatternPreview3OK", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);

+ 6
- 3
tests/src/test/java/org/aspectj/systemtest/ajc1919/SanityTestsJava19.java View File

@@ -9,8 +9,8 @@ package org.aspectj.systemtest.ajc1919;

import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava19OrLater;

/*
* Some very trivial tests that help verify things are OK.
@@ -19,10 +19,13 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava19OrLater;
*
* @author Alexander Kriegisch
*/
public class SanityTestsJava19 extends XMLBasedAjcTestCaseForJava19OrLater {

public class SanityTestsJava19 extends JavaVersionSpecificXMLBasedAjcTestCase {
public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(19).MAJOR;

public SanityTestsJava19() {
super(19);
}

// Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
public void testSimpleJava_A() {
runTest("simple - a");

+ 3
- 6
tests/src/test/java/org/aspectj/systemtest/ajc192/Ajc192Tests.java View File

@@ -10,23 +10,22 @@
*******************************************************************************/
package org.aspectj.systemtest.ajc192;

import junit.framework.Test;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.NestHost;
import org.aspectj.apache.bcel.classfile.NestMembers;
import org.aspectj.testing.XMLBasedAjcTestCase;

import junit.framework.Test;

/**
* @author Andy Clement
*/
public class Ajc192Tests extends XMLBasedAjcTestCase {

public void testITDLambdas() throws Exception {
public void testITDLambdas() {
runTest("itd lambdas");
}

public void test11Flags() throws Exception {
public void test11Flags() {
runTest("11flags");
}

@@ -82,8 +81,6 @@ public class Ajc192Tests extends XMLBasedAjcTestCase {
runTest("ptw - privileged same package");
}

// ---

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

+ 0
- 2
tests/src/test/java/org/aspectj/systemtest/ajc192/AllTestsAspectJ192.java View File

@@ -17,10 +17,8 @@ public class AllTestsAspectJ192 {

public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.2 tests");
// $JUnit-BEGIN$
suite.addTest(Ajc192Tests.suite());
suite.addTest(SanityTestsJava11.suite());
// $JUnit-END$
return suite;
}
}

+ 7
- 4
tests/src/test/java/org/aspectj/systemtest/ajc192/SanityTestsJava11.java View File

@@ -7,11 +7,10 @@
*******************************************************************************/
package org.aspectj.systemtest.ajc192;

import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava11OrLater;

import junit.framework.Test;

/*
* Some very trivial tests that help verify things are OK.
@@ -20,9 +19,13 @@ import junit.framework.Test;
*
* @author Andy Clement
*/
public class SanityTestsJava11 extends XMLBasedAjcTestCaseForJava11OrLater {
public class SanityTestsJava11 extends JavaVersionSpecificXMLBasedAjcTestCase {
public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(11).MAJOR;

public SanityTestsJava11() {
super(11);
}

// Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
public void testSimpleJava_A() {
runTest("simple - a");

+ 6
- 2
tests/src/test/java/org/aspectj/systemtest/ajc1920/Ajc1920TestsJava.java View File

@@ -8,13 +8,17 @@
package org.aspectj.systemtest.ajc1920;

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

/**
* @author Alexander Kriegisch
*/
public class Ajc1920TestsJava extends XMLBasedAjcTestCaseForJava20OrLater {
public class Ajc1920TestsJava extends JavaVersionSpecificXMLBasedAjcTestCase {

public Ajc1920TestsJava() {
super(20);
}

public void testDummyJava20() {
//runTest("dummy Java 20");

+ 8
- 5
tests/src/test/java/org/aspectj/systemtest/ajc1920/AllTestsAspectJ1920.java View File

@@ -9,26 +9,29 @@ package org.aspectj.systemtest.ajc1920;

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

/**
* @author Alexander Kriegisch
*/
public class AllTestsAspectJ1920 {
private static final int JAVA_VERSION = 20;

public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.20 tests");
suite.addTest(Bugs1920Tests.suite());
if (LangUtil.isVMGreaterOrEqual(20)) {
if (LangUtil.isVMGreaterOrEqual(JAVA_VERSION)) {
suite.addTest(SanityTestsJava20.suite());
suite.addTest(Ajc1920TestsJava.suite());
}

// Do not run tests using a previous compiler's preview features anymore. They would all fail.
/*
if (LangUtil.isVMGreaterOrEqual(20) && !LangUtil.isVMGreaterOrEqual(21)) {
suite.addTest(Java20PreviewFeaturesTests.suite());
if (AjcTask.JAVA_VERSION_MAX == JAVA_VERSION) {
if (LangUtil.isVMGreaterOrEqual(JAVA_VERSION) && LangUtil.isVMLessOrEqual(JAVA_VERSION)) {
suite.addTest(Java20PreviewFeaturesTests.suite());
}
}
*/
return suite;
}
}

+ 6
- 2
tests/src/test/java/org/aspectj/systemtest/ajc1920/Java20PreviewFeaturesTests.java View File

@@ -9,15 +9,19 @@ package org.aspectj.systemtest.ajc1920;

import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava20Only;

/**
* @author Alexander Kriegisch
*/
public class Java20PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava20Only {
public class Java20PreviewFeaturesTests extends JavaVersionSpecificXMLBasedAjcTestCase {
private static final Constants.ClassFileVersion classFileVersion = Constants.ClassFileVersion.of(20);

public Java20PreviewFeaturesTests() {
super(20, 20);
}

public void testSwitchPatternMatchingPreview4Java() {
runTest("switch pattern matching preview 4 java");
checkVersion("SwitchPatternPreview4OK", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);

+ 6
- 2
tests/src/test/java/org/aspectj/systemtest/ajc1920/SanityTestsJava20.java View File

@@ -9,8 +9,8 @@ package org.aspectj.systemtest.ajc1920;

import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava20OrLater;

/*
* Some very trivial tests that help verify things are OK.
@@ -19,10 +19,14 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava20OrLater;
*
* @author Alexander Kriegisch
*/
public class SanityTestsJava20 extends XMLBasedAjcTestCaseForJava20OrLater {
public class SanityTestsJava20 extends JavaVersionSpecificXMLBasedAjcTestCase {

public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(20).MAJOR;

public SanityTestsJava20() {
super(20);
}

// Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
public void testSimpleJava_A() {
runTest("simple - a");

+ 15
- 9
tests/src/test/java/org/aspectj/systemtest/ajc1921/Ajc1921TestsJava.java View File

@@ -9,17 +9,23 @@ package org.aspectj.systemtest.ajc1921;

import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava21OrLater;

/**
* @author Alexander Kriegisch
*/
public class Ajc1921TestsJava extends XMLBasedAjcTestCaseForJava21OrLater {
public class Ajc1921TestsJava extends JavaVersionSpecificXMLBasedAjcTestCase {

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

public Ajc1921TestsJava() {
super(21);
}

public void testSwitchPatternMatchingPreview4Java() {
runTest("switch pattern matching preview 4 java");
checkVersion("SwitchPatternPreview4OK", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
checkVersion("SwitchPatternPreview4OK", classFileVersion.MAJOR, classFileVersion.MINOR);
}

public void testSwitchPatternMatchingPreview4Error() {
@@ -28,10 +34,10 @@ public class Ajc1921TestsJava extends XMLBasedAjcTestCaseForJava21OrLater {

public void testSwitchPatternMatchingPreview3Aspect() {
runTest("switch pattern matching preview 3 aspect");
checkVersion("SwitchPatternPreview3Aspect", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
checkVersion("Application", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
checkVersion("Shape", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
checkVersion("S", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
checkVersion("SwitchPatternPreview3Aspect", classFileVersion.MAJOR, classFileVersion.MINOR);
checkVersion("Application", classFileVersion.MAJOR, classFileVersion.MINOR);
checkVersion("Shape", classFileVersion.MAJOR, classFileVersion.MINOR);
checkVersion("S", classFileVersion.MAJOR, classFileVersion.MINOR);
}

public void testSwitchPatternMatchingCaseLabelDominatedByPrecedingError() {
@@ -54,8 +60,8 @@ public class Ajc1921TestsJava extends XMLBasedAjcTestCaseForJava21OrLater {
public void testRecordPatternsPreview1Error() {
// https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450 (fixed for preview 2 in Eclipse 2023-03, 4.27)
runTest("record patterns error");
checkVersion("RecordPatternsPreview1Error", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
checkVersion("Box", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
checkVersion("RecordPatternsPreview1Error", classFileVersion.MAJOR, classFileVersion.MINOR);
checkVersion("Box", classFileVersion.MAJOR, classFileVersion.MINOR);
}

public void testRecordPatternsPreview1ExhaustivenessOK1() {

+ 9
- 5
tests/src/test/java/org/aspectj/systemtest/ajc1921/AllTestsAspectJ1921.java View File

@@ -9,6 +9,7 @@ package org.aspectj.systemtest.ajc1921;

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

// AspectJ_JDK_Update
@@ -28,18 +29,21 @@ import org.aspectj.util.LangUtil;
*/
public class AllTestsAspectJ1921 {

private static final int JAVA_VERSION = 21;

public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.21 tests");
suite.addTest(Bugs1921Tests.suite());
if (LangUtil.isVMGreaterOrEqual(21)) {
if (LangUtil.isVMGreaterOrEqual(JAVA_VERSION)) {
suite.addTest(SanityTestsJava21.suite());
suite.addTest(Ajc1921TestsJava.suite());
}
// AspectJ_JDK_Update
// Do not run tests using a previous compiler's preview features anymore. They would all fail.
// TODO: Comment out the following block when upgrading JDT Core to Java 22
if (LangUtil.isVMGreaterOrEqual(21) && !LangUtil.isVMGreaterOrEqual(22)) {
suite.addTest(Java21PreviewFeaturesTests.suite());
if (AjcTask.JAVA_VERSION_MAX == JAVA_VERSION) {
if (LangUtil.isVMGreaterOrEqual(JAVA_VERSION) && LangUtil.isVMLessOrEqual(JAVA_VERSION)) {
suite.addTest(Java21PreviewFeaturesTests.suite());
}
}
return suite;
}

+ 6
- 2
tests/src/test/java/org/aspectj/systemtest/ajc1921/Java21PreviewFeaturesTests.java View File

@@ -9,13 +9,17 @@ package org.aspectj.systemtest.ajc1921;

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

/**
* @author Alexander Kriegisch
*/
public class Java21PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava21Only {
public class Java21PreviewFeaturesTests extends JavaVersionSpecificXMLBasedAjcTestCase {

public Java21PreviewFeaturesTests() {
super(21, 21);
}

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

+ 6
- 2
tests/src/test/java/org/aspectj/systemtest/ajc1921/SanityTestsJava21.java View File

@@ -9,8 +9,8 @@ package org.aspectj.systemtest.ajc1921;

import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava21OrLater;

/*
* Some very trivial tests that help verify things are OK.
@@ -19,10 +19,14 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava21OrLater;
*
* @author Alexander Kriegisch
*/
public class SanityTestsJava21 extends XMLBasedAjcTestCaseForJava21OrLater {
public class SanityTestsJava21 extends JavaVersionSpecificXMLBasedAjcTestCase {

public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(21).MAJOR;

public SanityTestsJava21() {
super(21);
}

// Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
public void testSimpleJava_A() {
runTest("simple - a");

+ 7
- 5
tests/src/test/java/org/aspectj/systemtest/ajc193/Ajc193Tests.java View File

@@ -7,19 +7,21 @@
*******************************************************************************/
package org.aspectj.systemtest.ajc193;

import java.io.File;

import junit.framework.Test;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava10OrLater;
import org.aspectj.weaver.WeaverStateInfo;

import junit.framework.Test;
import java.io.File;

/**
* @author Andy Clement
*/
public class Ajc193Tests extends XMLBasedAjcTestCaseForJava10OrLater {
public class Ajc193Tests extends JavaVersionSpecificXMLBasedAjcTestCase {
public Ajc193Tests() {
super(10);
}

public void testNestedAroundProceed() {
runTest("nested around proceed");

+ 6
- 1
tests/src/test/java/org/aspectj/systemtest/ajc193/AllTestsAspectJ193.java View File

@@ -12,13 +12,18 @@ package org.aspectj.systemtest.ajc193;

import junit.framework.Test;
import junit.framework.TestSuite;
import org.aspectj.util.LangUtil;

public class AllTestsAspectJ193 {
private static final int JAVA_VERSION = 12;

public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.3 tests");
suite.addTest(Ajc193Tests.suite());
// suite.addTest(Java13Tests.suite());
// suite.addTest(Java12Tests.suite());
if (LangUtil.isVMGreaterOrEqual(JAVA_VERSION)) {
suite.addTest(SanityTestsJava12.suite());
}
return suite;
}
}

+ 0
- 31
tests/src/test/java/org/aspectj/systemtest/ajc193/Java13Tests.java View File

@@ -1,31 +0,0 @@
/*******************************************************************************
* Copyright (c) 2019 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.ajc193;

import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava13OrLater;

import junit.framework.Test;

/**
* @author Andy Clement
*/
public class Java13Tests extends XMLBasedAjcTestCaseForJava13OrLater {

// ---

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

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

}

+ 93
- 0
tests/src/test/java/org/aspectj/systemtest/ajc193/SanityTestsJava12.java View File

@@ -0,0 +1,93 @@
/*******************************************************************************
* 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.ajc193;

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

/*
* Some very trivial tests that help verify things are OK.
* These are a copy of the earlier Sanity Tests created for 1.6 but these supply the -12 option
* to check code generation and modification with that version specified.
*
* @author Alexander Kriegisch
*/
public class SanityTestsJava12 extends JavaVersionSpecificXMLBasedAjcTestCase {

public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(12).MAJOR;

public SanityTestsJava12() {
super(12);
}

// Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
public void testSimpleJava_A() {
runTest("simple - a");
}

public void testSimpleJava_B() {
runTest("simple - b");
}

public void testSimpleCode_C() {
runTest("simple - c");
}

public void testSimpleCode_D() {
runTest("simple - d");
}

public void testSimpleCode_E() {
runTest("simple - e");
}

public void testSimpleCode_F() {
runTest("simple - f");
}

public void testSimpleCode_G() {
runTest("simple - g");
}

public void testSimpleCode_H() {
runTest("simple - h", true);
}

public void testSimpleCode_I() {
runTest("simple - i");
}

public void testVersionCorrect1() throws ClassNotFoundException {
runTest("simple - j");
checkVersion("A", bytecode_version_for_JDK_level, 0);
}

public void testVersionCorrect2() throws ClassNotFoundException {
runTest("simple - k");
checkVersion("A", bytecode_version_for_JDK_level, 0);
}

public void testVersionCorrect4() throws ClassNotFoundException { // check it is 49.0 when -1.5 is specified
runTest("simple - m");
checkVersion("A", Constants.ClassFileVersion.of(5).MAJOR, 0);
}


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

@Override
protected java.net.URL getSpecFile() {
return getClassResource("sanity-tests-12.xml");
}

}

+ 2
- 1
tests/src/test/java/org/aspectj/systemtest/ajc195/AllTestsAspectJ195.java View File

@@ -16,11 +16,12 @@ import junit.framework.Test;
import junit.framework.TestSuite;

public class AllTestsAspectJ195 {
private static final int JAVA_VERSION = 13;

public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.5 tests");
suite.addTest(Ajc195Tests.suite());
if (LangUtil.isVMGreaterOrEqual(13)) {
if (LangUtil.isVMGreaterOrEqual(JAVA_VERSION)) {
suite.addTest(SanityTestsJava13.suite());
}
return suite;

+ 6
- 2
tests/src/test/java/org/aspectj/systemtest/ajc195/SanityTestsJava13.java View File

@@ -8,8 +8,8 @@
package org.aspectj.systemtest.ajc195;

import org.aspectj.apache.bcel.Constants;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava13OrLater;

import junit.framework.Test;

@@ -20,10 +20,14 @@ import junit.framework.Test;
*
* @author Andy Clement
*/
public class SanityTestsJava13 extends XMLBasedAjcTestCaseForJava13OrLater {
public class SanityTestsJava13 extends JavaVersionSpecificXMLBasedAjcTestCase {

public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(13).MAJOR;

public SanityTestsJava13() {
super(13);
}

// Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
public void testSimpleJava_A() {
runTest("simple - a");

+ 7
- 4
tests/src/test/java/org/aspectj/systemtest/ajc196/Ajc196Tests.java View File

@@ -7,16 +7,19 @@
*******************************************************************************/
package org.aspectj.systemtest.ajc196;

import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava14OrLater;

import junit.framework.Test;

/**
* @author Andy Clement
*/
public class Ajc196Tests extends XMLBasedAjcTestCaseForJava14OrLater {
public class Ajc196Tests extends JavaVersionSpecificXMLBasedAjcTestCase {

public Ajc196Tests() {
super(14);
}

public void testNPE_558995() {
runTest("early resolution of supporting interfaces");

+ 10
- 6
tests/src/test/java/org/aspectj/systemtest/ajc196/AllTestsAspectJ196.java View File

@@ -7,6 +7,7 @@
*******************************************************************************/
package org.aspectj.systemtest.ajc196;

import org.aspectj.tools.ant.taskdefs.AjcTask;
import org.aspectj.util.LangUtil;

import junit.framework.Test;
@@ -16,19 +17,22 @@ import junit.framework.TestSuite;
* @author Andy Clement
*/
public class AllTestsAspectJ196 {
private static final int JAVA_VERSION = 14;

public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.6 tests");
if (LangUtil.isVMGreaterOrEqual(14)) {
suite.addTest(Ajc196Tests.suite());
//suite.addTest(Bugs196Tests.suite());
if (LangUtil.isVMGreaterOrEqual(JAVA_VERSION)) {
suite.addTest(SanityTestsJava14.suite());
suite.addTest(Ajc196Tests.suite());
}

// Do not run tests using a previous compiler's preview features anymore. They would all fail.
/*
if (LangUtil.isVMGreaterOrEqual(14) && !LangUtil.isVMGreaterOrEqual(15)) {
suite.addTest(Java14PreviewFeaturesTests.suite());
if (AjcTask.JAVA_VERSION_MAX == JAVA_VERSION) {
if (LangUtil.isVMGreaterOrEqual(JAVA_VERSION) && LangUtil.isVMLessOrEqual(JAVA_VERSION)) {
suite.addTest(Java14PreviewFeaturesTests.suite());
}
}
*/
return suite;
}
}

+ 7
- 4
tests/src/test/java/org/aspectj/systemtest/ajc196/Java14PreviewFeaturesTests.java View File

@@ -7,18 +7,21 @@
*******************************************************************************/
package org.aspectj.systemtest.ajc196;

import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava14Only;

import junit.framework.Test;

/**
* @author Alexander Kriegisch
*/
public class Java14PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava14Only {
public class Java14PreviewFeaturesTests extends JavaVersionSpecificXMLBasedAjcTestCase {
private static final Constants.ClassFileVersion classFileVersion = Constants.ClassFileVersion.of(14);

public Java14PreviewFeaturesTests() {
super(14, 14);
}

public void testRecords() {
runTest("simple record");
checkVersion("Person", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);

+ 7
- 4
tests/src/test/java/org/aspectj/systemtest/ajc196/SanityTestsJava14.java View File

@@ -7,11 +7,10 @@
*******************************************************************************/
package org.aspectj.systemtest.ajc196;

import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava14OrLater;

import junit.framework.Test;

/*
* Some very trivial tests that help verify things are OK.
@@ -20,10 +19,14 @@ import junit.framework.Test;
*
* @author Andy Clement
*/
public class SanityTestsJava14 extends XMLBasedAjcTestCaseForJava14OrLater {
public class SanityTestsJava14 extends JavaVersionSpecificXMLBasedAjcTestCase {

public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(14).MAJOR;

public SanityTestsJava14() {
super(14);
}

// Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
public void testSimpleJava_A() {
runTest("simple - a");

+ 15
- 9
tests/src/test/java/org/aspectj/systemtest/ajc197/Ajc197TestsJava.java View File

@@ -9,47 +9,53 @@ package org.aspectj.systemtest.ajc197;

import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava16OrLater;

/**
* @author Alexander Kriegisch
*/
public class Ajc197TestsJava extends XMLBasedAjcTestCaseForJava16OrLater {
public class Ajc197TestsJava extends JavaVersionSpecificXMLBasedAjcTestCase {

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

public Ajc197TestsJava() {
super(16);
}

public void testHiddenClass() {
runTest("hidden class");
checkVersion("HiddenClassDemo", Constants.ClassFileVersion.of(16).MAJOR, Constants.ClassFileVersion.of(16).MINOR);
checkVersion("HiddenClassDemo", classFileVersion.MAJOR, classFileVersion.MINOR);
}

public void testTextBlock1() {
runTest("textblock 1");
checkVersion("Code", Constants.ClassFileVersion.of(16).MAJOR, Constants.ClassFileVersion.of(16).MINOR);
checkVersion("Code", classFileVersion.MAJOR, classFileVersion.MINOR);
}

public void testTextBlock2() {
runTest("textblock 2");
checkVersion("Code2", Constants.ClassFileVersion.of(16).MAJOR, Constants.ClassFileVersion.of(16).MINOR);
checkVersion("Code2", classFileVersion.MAJOR, classFileVersion.MINOR);
}

public void testRecords() {
runTest("simple record");
checkVersion("Person", Constants.ClassFileVersion.of(16).MAJOR, Constants.ClassFileVersion.of(16).MINOR);
checkVersion("Person", classFileVersion.MAJOR, classFileVersion.MINOR);
}

public void testRecords2() {
runTest("using a record");
checkVersion("UsingPersonRecord", Constants.ClassFileVersion.of(16).MAJOR, Constants.ClassFileVersion.of(16).MINOR);
checkVersion("UsingPersonRecord", classFileVersion.MAJOR, classFileVersion.MINOR);
}

public void testAdvisingRecords() {
runTest("advising records");
checkVersion("TraceRecordComponents", Constants.ClassFileVersion.of(16).MAJOR, Constants.ClassFileVersion.of(16).MINOR);
checkVersion("TraceRecordComponents", classFileVersion.MAJOR, classFileVersion.MINOR);
}

public void testInstanceofPatterns() {
runTest("instanceof patterns");
checkVersion("Jep305", Constants.ClassFileVersion.of(16).MAJOR, Constants.ClassFileVersion.of(16).MINOR);
checkVersion("Jep305", classFileVersion.MAJOR, classFileVersion.MINOR);
}

public static Test suite() {

+ 10
- 5
tests/src/test/java/org/aspectj/systemtest/ajc197/AllTestsAspectJ197.java View File

@@ -9,6 +9,7 @@ package org.aspectj.systemtest.ajc197;

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

/**
@@ -16,21 +17,25 @@ import org.aspectj.util.LangUtil;
*/
public class AllTestsAspectJ197 {

private static final int JAVA_VERSION = 16;

public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.7 tests");
//suite.addTest(Bugs197Tests.suite());
if (LangUtil.isVMGreaterOrEqual(15)) {
suite.addTest(SanityTestsJava15.suite());
}
if (LangUtil.isVMGreaterOrEqual(16)) {
if (LangUtil.isVMGreaterOrEqual(JAVA_VERSION)) {
suite.addTest(SanityTestsJava16.suite());
suite.addTest(Ajc197TestsJava.suite());
}

// Do not run tests using a previous compiler's preview features anymore. They would all fail.
/*
if (LangUtil.isVMGreaterOrEqual(16) && !LangUtil.isVMGreaterOrEqual(17)) {
suite.addTest(Java16PreviewFeaturesTests.suite());
if (AjcTask.JAVA_VERSION_MAX == JAVA_VERSION) {
if (LangUtil.isVMGreaterOrEqual(JAVA_VERSION) && LangUtil.isVMLessOrEqual(JAVA_VERSION)) {
suite.addTest(Java16PreviewFeaturesTests.suite());
}
}
*/
return suite;
}
}

+ 6
- 2
tests/src/test/java/org/aspectj/systemtest/ajc197/Java16PreviewFeaturesTests.java View File

@@ -9,15 +9,19 @@ package org.aspectj.systemtest.ajc197;

import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava16Only;

/**
* @author Alexander Kriegisch
*/
public class Java16PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava16Only {
public class Java16PreviewFeaturesTests extends JavaVersionSpecificXMLBasedAjcTestCase {
private static final Constants.ClassFileVersion classFileVersion = Constants.ClassFileVersion.of(16);

public Java16PreviewFeaturesTests() {
super(16, 16);
}

public void testSealedClassWithLegalSubclasses() {
runTest("sealed class with legal subclasses");
checkVersion("Employee", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);

+ 6
- 2
tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava15.java View File

@@ -9,8 +9,8 @@ package org.aspectj.systemtest.ajc197;

import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava15OrLater;

/*
* Some very trivial tests that help verify things are OK.
@@ -19,10 +19,14 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava15OrLater;
*
* @author Alexander Kriegisch
*/
public class SanityTestsJava15 extends XMLBasedAjcTestCaseForJava15OrLater {
public class SanityTestsJava15 extends JavaVersionSpecificXMLBasedAjcTestCase {

public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(15).MAJOR;

public SanityTestsJava15() {
super(15);
}

// Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
public void testSimpleJava_A() {
runTest("simple - a");

+ 6
- 2
tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava16.java View File

@@ -9,8 +9,8 @@ package org.aspectj.systemtest.ajc197;

import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava16OrLater;

/*
* Some very trivial tests that help verify things are OK.
@@ -19,10 +19,14 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava16OrLater;
*
* @author Alexander Kriegisch
*/
public class SanityTestsJava16 extends XMLBasedAjcTestCaseForJava16OrLater {
public class SanityTestsJava16 extends JavaVersionSpecificXMLBasedAjcTestCase {

public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(16).MAJOR;

public SanityTestsJava16() {
super(16);
}

// Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
public void testSimpleJava_A() {
runTest("simple - a");

+ 12
- 6
tests/src/test/java/org/aspectj/systemtest/ajc198/Ajc198TestsJava.java View File

@@ -9,28 +9,34 @@ package org.aspectj.systemtest.ajc198;

import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava17OrLater;

/**
* @author Alexander Kriegisch
*/
public class Ajc198TestsJava extends XMLBasedAjcTestCaseForJava17OrLater {
public class Ajc198TestsJava extends JavaVersionSpecificXMLBasedAjcTestCase {

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

public Ajc198TestsJava() {
super(17);
}

public void testSealedClassWithLegalSubclasses() {
runTest("sealed class with legal subclasses");
checkVersion("Employee", Constants.ClassFileVersion.of(17).MAJOR, Constants.ClassFileVersion.of(17).MINOR);
checkVersion("Manager", Constants.ClassFileVersion.of(17).MAJOR, Constants.ClassFileVersion.of(17).MINOR);
checkVersion("Employee", classFileVersion.MAJOR, classFileVersion.MINOR);
checkVersion("Manager", classFileVersion.MAJOR, classFileVersion.MINOR);
}

public void testSealedClassWithIllegalSubclass() {
runTest("sealed class with illegal subclass");
checkVersion("Person", Constants.ClassFileVersion.of(17).MAJOR, Constants.ClassFileVersion.of(17).MINOR);
checkVersion("Person", classFileVersion.MAJOR, classFileVersion.MINOR);
}

public void testWeaveSealedClass() {
runTest("weave sealed class");
checkVersion("PersonAspect", Constants.ClassFileVersion.of(17).MAJOR, Constants.ClassFileVersion.of(17).MINOR);
checkVersion("PersonAspect", classFileVersion.MAJOR, classFileVersion.MINOR);
}

public static Test suite() {

+ 10
- 6
tests/src/test/java/org/aspectj/systemtest/ajc198/AllTestsAspectJ198.java View File

@@ -9,6 +9,7 @@ package org.aspectj.systemtest.ajc198;

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

/**
@@ -16,25 +17,28 @@ import org.aspectj.util.LangUtil;
*/
public class AllTestsAspectJ198 {

private static final int JAVA_VERSION = 17;

public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.8 tests");
suite.addTest(Bugs198Tests.suite());
suite.addTest(Bugs198Tests.suite());
if (LangUtil.isVMGreaterOrEqual(9)) {
suite.addTest(CompileWithReleaseTests.suite());
}
if (LangUtil.isVMGreaterOrEqual(11)) {
suite.addTest(Bugs198Java11Tests.suite());
}
if (LangUtil.isVMGreaterOrEqual(17)) {
if (LangUtil.isVMGreaterOrEqual(JAVA_VERSION)) {
suite.addTest(SanityTestsJava17.suite());
suite.addTest(Ajc198TestsJava.suite());
}

// Do not run tests using a previous compiler's preview features anymore. They would all fail.
/*
if (LangUtil.isVMGreaterOrEqual(17) && !LangUtil.isVMGreaterOrEqual(18)) {
suite.addTest(Java17PreviewFeaturesTests.suite());
if (AjcTask.JAVA_VERSION_MAX == JAVA_VERSION) {
if (LangUtil.isVMGreaterOrEqual(JAVA_VERSION) && LangUtil.isVMLessOrEqual(JAVA_VERSION)) {
suite.addTest(Java17PreviewFeaturesTests.suite());
}
}
*/
return suite;
}
}

+ 6
- 3
tests/src/test/java/org/aspectj/systemtest/ajc198/Bugs198Java11Tests.java View File

@@ -8,15 +8,18 @@
package org.aspectj.systemtest.ajc198;

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

/**
* @author Alexander Kriegisch
*/
public class Bugs198Java11Tests extends XMLBasedAjcTestCaseForJava11OrLater {
public class Bugs198Java11Tests extends JavaVersionSpecificXMLBasedAjcTestCase {
public Bugs198Java11Tests() {
super(11);
}

public void testGitHub_68() {
public void testGitHub_68() {
runTest("correctly weave code using constant-dynamic");
}


+ 5
- 2
tests/src/test/java/org/aspectj/systemtest/ajc198/CompileWithReleaseTests.java View File

@@ -11,15 +11,18 @@ import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Method;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava9OrLater;

import java.util.Objects;

/**
* @author Alexander Kriegisch
*/
public class CompileWithReleaseTests extends XMLBasedAjcTestCaseForJava9OrLater {
public class CompileWithReleaseTests extends JavaVersionSpecificXMLBasedAjcTestCase {
public CompileWithReleaseTests() {
super(9);
}

/**
* In order to avoid a complicated test involving two different JDKs (9+ for compilation, 8 for runtime), we inspect

+ 6
- 2
tests/src/test/java/org/aspectj/systemtest/ajc198/Java17PreviewFeaturesTests.java View File

@@ -9,15 +9,19 @@ package org.aspectj.systemtest.ajc198;

import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava17Only;

/**
* @author Alexander Kriegisch
*/
public class Java17PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava17Only {
public class Java17PreviewFeaturesTests extends JavaVersionSpecificXMLBasedAjcTestCase {
private static final Constants.ClassFileVersion classFileVersion = Constants.ClassFileVersion.of(17);

public Java17PreviewFeaturesTests() {
super(17, 17);
}

public void testSwitchPatternMatchingCaseLabelDominatedByPrecedingError() {
runTest("switch pattern matching error");
}

+ 6
- 2
tests/src/test/java/org/aspectj/systemtest/ajc198/SanityTestsJava17.java View File

@@ -9,8 +9,8 @@ package org.aspectj.systemtest.ajc198;

import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava17OrLater;

/*
* Some very trivial tests that help verify things are OK.
@@ -19,10 +19,14 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava17OrLater;
*
* @author Alexander Kriegisch
*/
public class SanityTestsJava17 extends XMLBasedAjcTestCaseForJava17OrLater {
public class SanityTestsJava17 extends JavaVersionSpecificXMLBasedAjcTestCase {

public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(17).MAJOR;

public SanityTestsJava17() {
super(17);
}

// Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
public void testSimpleJava_A() {
runTest("simple - a");

+ 5
- 2
tests/src/test/java/org/aspectj/systemtest/ajc199/Ajc199TestsJava.java View File

@@ -8,13 +8,16 @@
package org.aspectj.systemtest.ajc199;

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

/**
* @author Alexander Kriegisch
*/
public class Ajc199TestsJava extends XMLBasedAjcTestCaseForJava18OrLater {
public class Ajc199TestsJava extends JavaVersionSpecificXMLBasedAjcTestCase {
public Ajc199TestsJava() {
super(18);
}

public void testDummyJava18() {
//runTest("dummy Java 18");

+ 9
- 6
tests/src/test/java/org/aspectj/systemtest/ajc199/AllTestsAspectJ199.java View File

@@ -9,26 +9,29 @@ package org.aspectj.systemtest.ajc199;

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

/**
* @author Alexander Kriegisch
*/
public class AllTestsAspectJ199 {
private static final int JAVA_VERSION = 18;

public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.9 tests");
suite.addTest(Bugs199Tests.suite());
if (LangUtil.isVMGreaterOrEqual(18)) {
suite.addTest(Bugs199Tests.suite());
if (LangUtil.isVMGreaterOrEqual(JAVA_VERSION)) {
suite.addTest(SanityTestsJava18.suite());
suite.addTest(Ajc199TestsJava.suite());
}

// Do not run tests using a previous compiler's preview features anymore. They would all fail.
/*
if (LangUtil.isVMGreaterOrEqual(18) && !LangUtil.isVMGreaterOrEqual(19)) {
suite.addTest(Java18PreviewFeaturesTests.suite());
if (AjcTask.JAVA_VERSION_MAX == JAVA_VERSION) {
if (LangUtil.isVMGreaterOrEqual(JAVA_VERSION) && LangUtil.isVMLessOrEqual(JAVA_VERSION)) {
suite.addTest(Java18PreviewFeaturesTests.suite());
}
}
*/
return suite;
}
}

+ 6
- 2
tests/src/test/java/org/aspectj/systemtest/ajc199/Java18PreviewFeaturesTests.java View File

@@ -9,15 +9,19 @@ package org.aspectj.systemtest.ajc199;

import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava18Only;

/**
* @author Alexander Kriegisch
*/
public class Java18PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava18Only {
public class Java18PreviewFeaturesTests extends JavaVersionSpecificXMLBasedAjcTestCase {
private static final Constants.ClassFileVersion classFileVersion = Constants.ClassFileVersion.of(18);

public Java18PreviewFeaturesTests() {
super(18, 18);
}

public void testSwitchPatternMatchingCaseLabelDominatedByPrecedingError() {
runTest("switch pattern matching error");
}

+ 6
- 2
tests/src/test/java/org/aspectj/systemtest/ajc199/SanityTestsJava18.java View File

@@ -9,8 +9,8 @@ package org.aspectj.systemtest.ajc199;

import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava18OrLater;

/*
* Some very trivial tests that help verify things are OK.
@@ -19,10 +19,14 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava18OrLater;
*
* @author Alexander Kriegisch
*/
public class SanityTestsJava18 extends XMLBasedAjcTestCaseForJava18OrLater {
public class SanityTestsJava18 extends JavaVersionSpecificXMLBasedAjcTestCase {

public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(18).MAJOR;

public SanityTestsJava18() {
super(18);
}

// Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
public void testSimpleJava_A() {
runTest("simple - a");

+ 69
- 0
tests/src/test/resources/org/aspectj/systemtest/ajc193/sanity-tests-12.xml View File

@@ -0,0 +1,69 @@
<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>

<suite>

<!-- empty class -->
<ajc-test dir="bugs160/simplejava" title="simple - a">
<compile files="SimpleA.java" options="-12"/>
</ajc-test>

<!-- class with one method -->
<ajc-test dir="bugs160/simplejava" title="simple - b">
<compile files="SimpleB.java" options="-12"/>
<run class="SimpleB"/>
</ajc-test>

<!-- empty aspect -->
<ajc-test dir="bugs160/simplejava" title="simple - c">
<compile files="SimpleC.java" options="-12"/>
</ajc-test>

<!-- simple before -->
<ajc-test dir="bugs160/simplejava" title="simple - d">
<compile files="SimpleD.java" options="-12"/>
</ajc-test>

<!-- simple itd field -->
<ajc-test dir="bugs160/simplejava" title="simple - e">
<compile files="SimpleE.java" options="-12"/>
</ajc-test>

<!-- aspect with main calling a static method -->
<ajc-test dir="bugs160/simplejava" title="simple - f">
<compile files="SimpleF.java" options="-12"/>
</ajc-test>

<!-- pertarget -->
<ajc-test dir="bugs160/simplejava" title="simple - g">
<compile files="SimpleG.java" options="-12"/>
</ajc-test>

<!-- generic ctor itds -->
<ajc-test dir="bugs160/simplejava" title="simple - h">
<compile files="SimpleH.java" options="-12"/>
</ajc-test>

<!-- overriding generic itd methods -->
<ajc-test dir="bugs160/simplejava" title="simple - i">
<compile files="SimpleI.java" options="-12"/>
</ajc-test>

<!-- check class file version is 57.0 -->
<ajc-test dir="bugs160/simplejava" title="simple - j">
<compile files="SimpleJ.java" options="-12"/>
</ajc-test>

<!-- check class file version is 57.0 -->
<ajc-test dir="bugs160/simplejava" title="simple - k">
<compile files="SimpleJ.java" options="-source 12"/>
</ajc-test>

<!-- check class file version is 49.0 -->
<ajc-test dir="bugs160/simplejava" title="simple - m">
<compile files="SimpleJ.java" options="-1.5"/>
</ajc-test>

<ajc-test dir="bugs160/simplejava" title="simple - n">
<compile files="SimpleN.java" options="-12"/>
</ajc-test>
</suite>

+ 9
- 1
util/src/main/java/org/aspectj/util/LangUtil.java View File

@@ -115,7 +115,15 @@ public class LangUtil {
}

public static boolean isVMGreaterOrEqual(double javaVersion) {
return javaVersion <= vmVersion;
return vmVersion >= javaVersion;
}

public static boolean isVMLessOrEqual(int javaVersion) {
return isVMLessOrEqual((double) javaVersion);
}

public static boolean isVMLessOrEqual(double javaVersion) {
return vmVersion <= javaVersion;
}

/**

Loading…
Cancel
Save