]> source.dussan.org Git - aspectj.git/commitdiff
Add test case + experimental fix for AJC option '--add-exports'
authorAlexander Kriegisch <Alexander@Kriegisch.name>
Sun, 27 Mar 2022 05:57:19 +0000 (12:57 +0700)
committerAlexander Kriegisch <Alexander@Kriegisch.name>
Sun, 27 Mar 2022 05:57:19 +0000 (12:57 +0700)
I am expecting the test case to pass, but other tests to fail. This
temporary commit is meant to create feedback from GitHub CI test runs.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/StatefulNameEnvironment.java
org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java
tests/bugs199/add_exports/Application.java [new file with mode: 0644]
tests/src/test/java/org/aspectj/systemtest/ajc199/Bugs199Tests.java
tests/src/test/resources/org/aspectj/systemtest/ajc199/ajc199.xml

index 08bf00d54961a8af90791146b2500fa32b3346af..c1bc570cc0e9723a30d8185308c99b1aa3dbdff2 100644 (file)
@@ -1044,7 +1044,9 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
                        for (int i = 0; i < cps.size(); i++) {
                                classpaths[i] = cps.get(i);
                        }
-                       FileSystem fileSystem = getLibraryAccess(classpaths, filenames);
+                       //FileSystem fileSystem = getLibraryAccess(classpaths, filenames);
+                       // TODO: This will probably fail other tests, it is just an experiment
+                       FileSystem fileSystem = buildConfig.getBuildArgParser().getLibraryAccess();
                        environment = new StatefulNameEnvironment(fileSystem, state.getClassNameToFileMap(), state);
                        state.setFileSystem(fileSystem);
                        state.setNameEnvironment(environment);
index 0af411be361fd15d3d08e66ae6f61bb971de7337..dad61e7b2316163f09dae3a184a10121a89b0959 100644 (file)
@@ -27,6 +27,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFormatExcepti
 import org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryType;
 import org.aspectj.org.eclipse.jdt.internal.compiler.env.IModule;
 import org.aspectj.org.eclipse.jdt.internal.compiler.env.IModuleAwareNameEnvironment;
+import org.aspectj.org.eclipse.jdt.internal.compiler.env.IUpdatableModule;
 import org.aspectj.org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
 import org.aspectj.util.FileUtil;
 
@@ -151,6 +152,16 @@ public class StatefulNameEnvironment implements IModuleAwareNameEnvironment {
                return baseEnvironment.getModule(moduleName);
        }
 
+       @Override
+       public void applyModuleUpdates(IUpdatableModule module, IUpdatableModule.UpdateKind kind) {
+               baseEnvironment.applyModuleUpdates(module, kind);
+       }
+
+       @Override
+       public char[][] getUniqueModulesDeclaringPackage(char[][] packageName, char[] moduleName) {
+               return baseEnvironment.getUniqueModulesDeclaringPackage(packageName, moduleName);
+       }
+
        @Override
        public char[][] getAllAutomaticModules() {
                return baseEnvironment.getAllAutomaticModules();
index 7a1ad855bfe28e6838dbee23233e3e132c0041d0..0aa9a81db19ebef3350d494c36847166c1e36688 100644 (file)
@@ -699,7 +699,15 @@ public abstract class AjcTestCase extends TestCase {
                                e.printStackTrace();
                        }
                        return lastRunResult;
-               } else if (vmargs!=null && (vmargs.contains("--enable-preview") || vmargs.contains("--add-modules") || vmargs.contains("--limit-modules") || vmargs.contains("--add-reads"))) {
+               } else if (
+                       vmargs != null && (
+                               vmargs.contains("--enable-preview") ||
+                               vmargs.contains("--add-modules") ||
+                               vmargs.contains("--limit-modules") ||
+                               vmargs.contains("--add-reads") ||
+                               vmargs.contains("--add-exports")
+                       )
+               ) {
                        // If --add-modules supplied, need to fork the test
                        try {
                                //                              if (mp.indexOf("$runtime") != -1) {
diff --git a/tests/bugs199/add_exports/Application.java b/tests/bugs199/add_exports/Application.java
new file mode 100644 (file)
index 0000000..88bd177
--- /dev/null
@@ -0,0 +1,17 @@
+import sun.security.x509.X509CertInfo;
+
+import java.security.cert.CertificateParsingException;
+
+/**
+ * https://github.com/mojohaus/aspectj-maven-plugin/issues/139
+ */
+public class Application {
+  public static void main(String[] args) {
+    try {
+      new X509CertInfo(new byte[0]);
+    }
+    catch (CertificateParsingException e) {
+      System.out.println(e);
+    }
+  }
+}
index b83448935c9f60dace017ba2a07bd4d1e2cd7b89..a9f7f302317cc9bd49c9f1ba81fedcd98d8eed77 100644 (file)
@@ -61,6 +61,10 @@ public class Bugs199Tests extends XMLBasedAjcTestCase {
     runTest("asynchronous proceed for nested around-advice (native, thread pool)");
   }
 
+  public void testAddExports() {
+    runTest("use --add-exports");
+  }
+
   public static Test suite() {
     return XMLBasedAjcTestCase.loadSuite(Bugs199Tests.class);
   }
index 7baeea086dff503b41e7277d987a28f2b57e3802..9a9ac2d47e2852e2083ca6e1aa1e327fc4442978 100644 (file)
                </run>
        </ajc-test>
 
+       <ajc-test dir="bugs199/add_exports" title="use --add-exports" vm="9">
+               <compile files="Application.java" options="-11 --add-exports java.base/sun.security.x509=ALL-UNNAMED" />
+               <run class="Application" vmargs="--add-exports java.base/sun.security.x509=ALL-UNNAMED">
+                       <stdout>
+                               <line text="java.security.cert.CertificateParsingException: java.io.IOException"/>
+                       </stdout>
+               </run>
+       </ajc-test>
+
 </suite>