From 0fb70c99cfc6432ceb8357f211722ca0be2dc9c4 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Wed, 23 Feb 2022 21:48:04 +0700 Subject: [PATCH] Regression test for #125: Bugs198Tests.testGitHub_125 This test fails when run against AspectJ 1.9.8 with JDT Core 1.9.8.RC3. It passes when using the latest JDT Core 1.9.9-SNAPSHOT. It sets system property 'org.aspectj.weaver.openarchives=20', provoking open classpath JAR file exhaustion when compiling a simple class with AJC, i.e. JARs are being forcibly closed and automatically re-opened, as soon as they are needed. Before the JDT Core bugfix, this test causes: java.lang.NullPointerException at ....compiler.batch.ClasspathJmod.getModulesDeclaringPackage With the bugfix incorporated into AspectJ Tools, the problem is gone. Note: New test dependency 'io.github.bmuskalla:scoped-system-properties' helps to test compilation with the temporarily changed global system property in isolation, saving the environment in a thread-local variable and later cleanly restoring the original values again. If we ever switch to parallel test execution, this would otherwise influence other tests and potentially cause weird side effects. Better safe than sorry. Signed-off-by: Alexander Kriegisch --- tests/bugs198/github_125/Application.java | 11 +++++++++++ tests/pom.xml | 11 +++++++++++ .../aspectj/systemtest/ajc198/Bugs198Tests.java | 15 ++++++++++++--- .../org/aspectj/systemtest/ajc198/ajc198.xml | 14 ++++++++++++++ 4 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 tests/bugs198/github_125/Application.java diff --git a/tests/bugs198/github_125/Application.java b/tests/bugs198/github_125/Application.java new file mode 100644 index 000000000..7e893fc1a --- /dev/null +++ b/tests/bugs198/github_125/Application.java @@ -0,0 +1,11 @@ +public class Application { + public static void main(String[] argv) { + System.out.println("Hello world!"); + } + + static aspect MyAspect { + before(): execution(* Application.main(..)) { + System.out.println("Before advice"); + } + } +} diff --git a/tests/pom.xml b/tests/pom.xml index 8ab3878bc..33801c2f5 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -90,6 +90,17 @@ ${project.version} test + + + io.github.bmuskalla + scoped-system-properties + 1.1.0 + test + + + + + + + + + + -- 2.39.5