]> source.dussan.org Git - aspectj.git/commitdiff
Fix classpath for tests on Java9
authorAndy Clement <aclement@pivotal.io>
Mon, 27 Jun 2016 22:49:09 +0000 (15:49 -0700)
committerAndy Clement <aclement@pivotal.io>
Mon, 27 Jun 2016 22:49:09 +0000 (15:49 -0700)
ajde.core/testsrc/org/aspectj/ajde/core/TestCompilerConfiguration.java
ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTestCase.java
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/CommandTestCase.java
org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjcTestCase.java
testing-drivers/testsrc/org/aspectj/testing/drivers/HarnessSelectionTest.java
testing/testsrc/org/aspectj/testing/taskdefs/AjcTaskCompileCommandTest.java

index c3a46c0479e55a1b3c4711351b6d8282c9b86f5e..2265014f962f6a197fea9963747ba2234e4150f2 100644 (file)
@@ -22,6 +22,7 @@ import java.util.Set;
 
 import org.aspectj.tools.ajc.AjcTests;
 import org.aspectj.util.FileUtil;
+import org.aspectj.util.LangUtil;
 
 /**
  * Test implementation of ICompilerConfiguration. Allows users to configure the settings via setter methods. By default returns null
@@ -58,8 +59,15 @@ public class TestCompilerConfiguration implements ICompilerConfiguration {
        }
 
        public String getClasspath() {
-               return projectPath + File.pathSeparator + System.getProperty("sun.boot.class.path") + File.pathSeparator
-                               + AjcTests.aspectjrtClasspath();
+               StringBuilder classpath = new StringBuilder();
+               classpath.append(projectPath);
+        if (LangUtil.is19VMOrGreater()) {
+               classpath.append(File.pathSeparator).append(LangUtil.getJrtFsFilePath());
+        } else {
+               classpath.append(File.pathSeparator).append(System.getProperty("sun.boot.class.path"));
+        }
+               classpath.append(File.pathSeparator).append(AjcTests.aspectjrtClasspath());
+               return classpath.toString();
        }
 
        public Set<File> getInpath() {
index 2db299f37377f7ede3e9ed150622ec1c7a2af916..d75f8cb64be6a66ef818cc1e69fe44db91e77ad5 100644 (file)
@@ -19,6 +19,7 @@ import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
 
 import org.aspectj.tools.ajc.Ajc;
+import org.aspectj.util.LangUtil;
 
 /**
  * This class is the super class of all Ajdoc tests. It creates a sandbox directory and provides utility methods for copying over
@@ -202,7 +203,12 @@ public class AjdocTestCase extends TestCase {
                args[1] = "-source";
                args[2] = sourceLevel;
                args[3] = "-classpath";
-               args[4] = AjdocTests.ASPECTJRT_PATH.getPath();
+               StringBuilder classpath = new StringBuilder();
+               if (LangUtil.is19VMOrGreater()) {
+                       classpath.append(LangUtil.getJrtFsFilePath()).append(File.pathSeparator);
+               }
+               classpath.append(AjdocTests.ASPECTJRT_PATH.getPath());
+               args[4] = classpath.toString();
                args[5] = "-d";
                args[6] = getAbsolutePathOutdir();
                // args[7] = "-Xset:minimalModel=false";
index 08a5252a63fa6bc97b909dc284feb900c8ae888a..62b1ef67e92439af16caeba43e85dc3f393fc9ad 100644 (file)
@@ -22,6 +22,7 @@ import org.aspectj.ajdt.ajc.AjdtCommand;
 import org.aspectj.bridge.ICommand;
 //import org.aspectj.bridge.IMessage;
 import org.aspectj.bridge.MessageHandler;
+import org.aspectj.util.LangUtil;
 
 /**
  * @author hugunin
@@ -71,6 +72,7 @@ public class BasicCommandTestCase extends CommandTestCase {
        public void testThisAndModifiers() {
                checkCompile("src1/ThisAndModifiers.java", NO_ERRORS);
        }
+       
        public void testDeclares() {
                checkCompile("src1/Declares.java", new int[] {2});
        }       
@@ -98,7 +100,10 @@ public class BasicCommandTestCase extends CommandTestCase {
                args.add(getSandboxName());
                
                args.add("-classpath");
-               args.add(getRuntimeClasspath() + File.pathSeparator +\r                  "../lib/junit/junit.jar;../testing-client/bin");
+               StringBuilder classpath = new StringBuilder();
+               classpath.append(getRuntimeClasspath());
+               classpath.append(File.pathSeparator).append("../lib/junit/junit.jar;../testing-client/bin");
+               args.add(classpath.toString());
                args.add("-Xlint:error");
                args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/Xlint.java");
                
index a586f8c7d1117af5ebb5481af6adda824dda87a9..23e5890804735cd9d4c3f637e8882bd29fc6ab7c 100644 (file)
@@ -31,6 +31,7 @@ import org.aspectj.bridge.MessageHandler;
 import org.aspectj.testing.util.TestUtil;
 import org.aspectj.tools.ajc.Ajc;
 import org.aspectj.tools.ajc.AjcTests;
+import org.aspectj.util.LangUtil;
 import org.aspectj.weaver.bcel.LazyClassGen;
 
 public abstract class CommandTestCase extends TestCase {
@@ -175,7 +176,12 @@ public abstract class CommandTestCase extends TestCase {
 
        /** get the location of the org.aspectj.lang & runtime classes */
        protected static String getRuntimeClasspath() {
-               return AjcTests.aspectjrtClasspath();
+               StringBuilder classpath = new StringBuilder();
+               if (LangUtil.is19VMOrGreater()) {
+                       classpath.append(LangUtil.getJrtFsFilePath()).append(File.pathSeparator);
+               }
+               classpath.append(AjcTests.aspectjrtClasspath());
+               return classpath.toString();
        }
 
        protected String getSandboxName() {
index f0af8da50096e8b7c4d6318cbf027fbc99009226..5c4ee012bca3a3c9274a72d68a21521f476bae7d 100644 (file)
@@ -35,6 +35,7 @@ import junit.framework.TestCase;
 import org.aspectj.bridge.IMessage;
 import org.aspectj.bridge.ISourceLocation;
 import org.aspectj.testing.util.TestUtil;
+import org.aspectj.util.LangUtil;
 
 /**
  * A TestCase class that acts as the superclass for all test cases wishing to drive the ajc compiler.
@@ -610,13 +611,11 @@ public class AjcTestCase extends TestCase {
                getAnyJars(ajc.getSandboxDirectory(), cp);
 
                URLClassLoader sandboxLoader;
-               URLClassLoader testLoader = (URLClassLoader) getClass().getClassLoader();
-               ClassLoader parentLoader = testLoader.getParent();
-
-       
+               ClassLoader parentLoader = getClass().getClassLoader().getParent();
                
                /* Sandbox -> AspectJ -> Extension -> Bootstrap */
                if ( !useFullLTW && useLTW) {
+                       URLClassLoader testLoader = (URLClassLoader) getClass().getClassLoader();
                        /*
                         * Create a new AspectJ class loader using the existing test CLASSPATH and any missing Java 5 projects
                         */
@@ -851,38 +850,46 @@ public class AjcTestCase extends TestCase {
         * @param args the String[] args to fix up
         * @return the String[] args to use
         */
-       protected String[] fixupArgs(String[] args) {
-               if (null == args) {
-                       return null;
-               }
-               int cpIndex = -1;
-               boolean hasruntime = false;
-               for (int i = 0; i < args.length - 1; i++) {
-                       args[i] = adaptToPlatform(args[i]);
-                       if ("-classpath".equals(args[i])) {
-                               cpIndex = i;
-                               args[i + 1] = substituteSandbox(args[i + 1]);
-                               String next = args[i + 1];
-                               hasruntime = ((null != next) && (-1 != next.indexOf("aspectjrt.jar")));
-                       }
-               }
-               if (-1 == cpIndex) {
-                       String[] newargs = new String[args.length + 2];
-                       newargs[0] = "-classpath";
-                       newargs[1] = TestUtil.aspectjrtPath().getPath();
-                       System.arraycopy(args, 0, newargs, 2, args.length);
-                       args = newargs;
-               } else {
-                       if (!hasruntime) {
-                               cpIndex++;
-                               String[] newargs = new String[args.length];
-                               System.arraycopy(args, 0, newargs, 0, args.length);
-                               newargs[cpIndex] = args[cpIndex] + File.pathSeparator + TestUtil.aspectjrtPath().getPath();
-                               args = newargs;
-                       }
-               }
-               return args;
-       }
+    protected String[] fixupArgs(String[] args) {
+        if (null == args) {
+                return null;
+        }
+        int cpIndex = -1;
+        boolean hasruntime = false;
+        for (int i = 0; i < args.length - 1; i++) {
+                args[i] = adaptToPlatform(args[i]);
+                if ("-classpath".equals(args[i])) {
+                        cpIndex = i;
+                        args[i + 1] = substituteSandbox(args[i + 1]);
+                        String next = args[i + 1];
+                        hasruntime = ((null != next) && (-1 != next.indexOf("aspectjrt.jar")));
+                }
+        }
+        if (-1 == cpIndex) {
+                String[] newargs = new String[args.length + 2];
+                newargs[0] = "-classpath";
+                newargs[1] = TestUtil.aspectjrtPath().getPath();
+                System.arraycopy(args, 0, newargs, 2, args.length);
+                args = newargs;
+                cpIndex = 1;
+        } else {
+                if (!hasruntime) {
+                        cpIndex++;
+                        String[] newargs = new String[args.length];
+                        System.arraycopy(args, 0, newargs, 0, args.length);
+                        newargs[cpIndex] = args[cpIndex] + File.pathSeparator + TestUtil.aspectjrtPath().getPath();
+                        args = newargs;
+                }
+        }
+        boolean needsJRTFS = LangUtil.is19VMOrGreater();
+        if (needsJRTFS) {
+                if (args[cpIndex].indexOf(LangUtil.JRT_FS) == -1) {
+                        String jrtfsPath = LangUtil.getJrtFsFilePath();
+                        args[cpIndex] = jrtfsPath + File.pathSeparator + args[cpIndex];
+                }
+        }
+        return args;
+}
 
        private String adaptToPlatform(String s) {
                String ret = s.replace(';', File.pathSeparatorChar);
index 9f50d0ff19e4d9fdcf57be8b264018a9204a1bcc..ac937ac4428046cf60a7b57d85568bb4849554c8 100644 (file)
@@ -18,6 +18,7 @@ import org.aspectj.bridge.MessageHandler;
 import org.aspectj.bridge.MessageUtil;
 import org.aspectj.testing.harness.bridge.AbstractRunSpec;
 import org.aspectj.testing.harness.bridge.AjcTest;
+import org.aspectj.testing.harness.bridge.IRunSpec;
 import org.aspectj.testing.run.IRunStatus;
 import org.aspectj.testing.run.RunValidator;
 import org.aspectj.testing.util.BridgeUtil;
@@ -298,7 +299,7 @@ public class HarnessSelectionTest extends TestCase {
         runtime.setOptions(options);
         AjcTest.Suite.Spec spec = getSpec(suiteFile);
         assertNotNull(spec);
-        ArrayList kids = spec.getChildren();
+        ArrayList<IRunSpec> kids = spec.getChildren();
         assertNotNull(kids);
         if ((suiteFile == SELECT) && (17 != kids.size())) {
             assertTrue("expected 17 kids, got " + kids.size(), false);
index 6ab5a386b6e86eb737f8372b4ca707fcb7807008..42a2063a485b2738281e243f6a35aeee4300f1b2 100644 (file)
@@ -44,7 +44,12 @@ public class AjcTaskCompileCommandTest extends TestCase {
         list.add("-d");
         list.add(getClassesDir().getAbsolutePath());
         list.add("-classpath");
-        list.add(Globals.F_aspectjrt_jar.getAbsolutePath());
+        StringBuilder classpath = new StringBuilder();
+        classpath.append(Globals.F_aspectjrt_jar.getAbsolutePath());
+        if (LangUtil.is19VMOrGreater()) {
+               classpath.append(File.pathSeparator).append(LangUtil.getJrtFsFilePath());
+        }
+        list.add(classpath.toString());
     }
 
     static boolean doWait(IMessageHolder holder, int seconds, int timeout) {