aboutsummaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
Diffstat (limited to 'testing')
-rw-r--r--testing/src/test/java/org/aspectj/testing/RunSpec.java8
-rw-r--r--testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava17Only.java6
-rw-r--r--testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18Only.java40
-rw-r--r--testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18OrLater.java27
-rw-r--r--testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java3
5 files changed, 79 insertions, 5 deletions
diff --git a/testing/src/test/java/org/aspectj/testing/RunSpec.java b/testing/src/test/java/org/aspectj/testing/RunSpec.java
index 9e07f8a44..181eb9062 100644
--- a/testing/src/test/java/org/aspectj/testing/RunSpec.java
+++ b/testing/src/test/java/org/aspectj/testing/RunSpec.java
@@ -22,7 +22,7 @@ import java.util.StringTokenizer;
import org.aspectj.tools.ajc.AjcTestCase;
import org.aspectj.util.FileUtil;
-import static org.aspectj.util.LangUtil.is16VMOrGreater;
+import static org.aspectj.util.LangUtil.is9VMOrGreater;
/**
* @author Adrian Colyer
@@ -71,7 +71,11 @@ public class RunSpec implements ITestStep {
// On Java 16+, LTW no longer works without this parameter. Add the argument here and not in AjcTestCase::run,
// because even if 'useLTW' and 'useFullLTW' are not set, we might in the future have tests for weaver attachment
// during runtime. See also docs/dist/doc/README-187.html.
- vmargs += is16VMOrGreater() ? " --add-opens java.base/java.lang=ALL-UNNAMED" : "";
+ //
+ // The reason for setting this parameter for Java 9+ instead of 16+ is that it helps to avoid the JVM printing
+ // unwanted illegal access warnings during weaving in 'useFullLTW' mode, either making existing tests fail or
+ // having to assert on the warning messages.
+ vmargs += is9VMOrGreater() ? " --add-opens java.base/java.lang=ALL-UNNAMED" : "";
AjcTestCase.RunResult rr = inTestCase.run(getClassToRun(), getModuleToRun(), args, vmargs, getClasspath(), getModulepath(), useLtw, "true".equalsIgnoreCase(usefullltw));
diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava17Only.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava17Only.java
index 0c351c69a..78941fcab 100644
--- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava17Only.java
+++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava17Only.java
@@ -20,21 +20,21 @@ public abstract class XMLBasedAjcTestCaseForJava17Only extends XMLBasedAjcTestCa
@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.is17VMOrGreater() || LangUtil.is18VMOrGreater()) {
throw new IllegalStateException(
"These tests should be run on Java 17 only " +
"(e.g. because they use version-specific preview features)"
);
- }
super.setUp();
+ }
+ */
}
}
diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18Only.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18Only.java
new file mode 100644
index 000000000..ba4d00605
--- /dev/null
+++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18Only.java
@@ -0,0 +1,40 @@
+/* *******************************************************************
+ * 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 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.is18VMOrGreater() || LangUtil.is19VMOrGreater()) {
+ throw new IllegalStateException(
+ "These tests should be run on Java 18 only " +
+ "(e.g. because they use version-specific preview features)"
+ );
+ }
+ super.setUp();
+ }
+
+}
diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18OrLater.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18OrLater.java
new file mode 100644
index 000000000..9b9efdd34
--- /dev/null
+++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18OrLater.java
@@ -0,0 +1,27 @@
+/* *******************************************************************
+ * 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 XMLBasedAjcTestCaseForJava18OrLater extends XMLBasedAjcTestCase {
+
+ @Override
+ public void setUp() throws Exception {
+ if (!LangUtil.is18VMOrGreater())
+ throw new IllegalStateException("These tests should be run on Java 18 or later");
+ super.setUp();
+ }
+
+}
diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java
index 93ca14e70..fa3315396 100644
--- a/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java
+++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java
@@ -600,6 +600,9 @@ public class JavaRun implements IAjcRun {
public static class Spec extends AbstractRunSpec {
static {
try {
+ // TODO: Deprecate the Security Manager for Removal, see https://openjdk.java.net/jeps/411.
+ // As of Java 18, the new API for blocking System.exit is not available yet, see
+ // https://bugs.openjdk.java.net/browse/JDK-8199704.
System.setSecurityManager(RunSecurityManager.ME);
} catch (Throwable t) {
System.err.println("JavaRun: Security manager set - no System.exit() protection");