import org.aspectj.testing.util.TestUtil;
import org.aspectj.util.FileUtil;
+import static java.io.File.pathSeparator;
+import static java.io.File.separator;
+
/**
* The Ajc class is intended for use as part of a unit-test suite, it drives the AspectJ compiler and lets you check the compilation
* results. Compilations run in a sandbox that is created in C:\temp\ajcSandbox or /tmp/ajcSandbox depending on your platform.
private static final String BUILD_OUTPUT_FOLDER = "target";
public static final String outputFolder(String module) {
- return File.pathSeparator + ".." +File.separator + module + File.separator + BUILD_OUTPUT_FOLDER + File.separator + "classes";
+ return pathSeparator + ".." + separator + module + separator + BUILD_OUTPUT_FOLDER + separator + "classes";
}
public static final String outputFolders(String... modules) {
StringBuilder s = new StringBuilder();
for (String module: modules) {
- s.append(File.pathSeparator + ".." +File.separator + module + File.separator + BUILD_OUTPUT_FOLDER + File.separator + "classes");
+ s.append(pathSeparator + ".." + separator + module + separator + BUILD_OUTPUT_FOLDER + separator + "classes");
}
return s.toString();
}
outputFolder("testing-client")
+ outputFolder("runtime")
+ outputFolder("bcel-builder")
- + File.pathSeparator + ".." + File.separator + "lib" + File.separator + "junit" + File.separator + "junit.jar"
+ + File.pathSeparator + ".." + separator + "lib" + separator + "junit" + separator + "junit.jar"
+ outputFolder("bridge")
+ outputFolder("loadtime")
+ outputFolder("weaver")
hasOutdir = true;
}
boolean isOutjar = args[i].equals("-outjar");
- StringTokenizer strTok = new StringTokenizer(args[++i], File.pathSeparator);
+ StringTokenizer strTok = new StringTokenizer(args[++i], pathSeparator);
while (strTok.hasMoreTokens()) {
File f = new File(strTok.nextToken());
buff.append(adjustFileOrDir(f, copyThisTime, isOutjar).getAbsolutePath());
if (strTok.hasMoreTokens())
- buff.append(File.pathSeparator);
+ buff.append(pathSeparator);
}
newArgs[i] = buff.toString();
if (args[i - 1].equals("-classpath")) {
hasClasspath = true;
- newArgs[i] = newArgs[i] + File.pathSeparator + TESTER_PATH + File.pathSeparator
+ newArgs[i] = newArgs[i] + pathSeparator + TESTER_PATH + pathSeparator
+ getSandboxDirectory().getAbsolutePath();
}
} else {
newArgs = new String[oldArgs.length + 2];
System.arraycopy(oldArgs, 0, newArgs, 0, oldArgs.length);
newArgs[oldArgs.length] = "-classpath";
- newArgs[oldArgs.length + 1] = TESTER_PATH + File.pathSeparator + getSandboxDirectory().getAbsolutePath();
+ newArgs[oldArgs.length + 1] = TESTER_PATH + pathSeparator + getSandboxDirectory().getAbsolutePath();
}
if (!hasOutdir) {
String[] oldArgs = newArgs;
if (!from.isAbsolute()) {
ret = new File(sandbox, from.getPath());
File fromParent = from.getParentFile();
- String relativeToPath = (fromParent != null) ? (fromParent.getPath() + File.separator) : "";
+ String relativeToPath = (fromParent != null) ? (fromParent.getPath() + separator) : "";
if (baseDir != null) {
from = new File(baseDir, from.getPath());
// if (ensureDirsExist) {
import junit.framework.TestCase;
+import static java.io.File.pathSeparator;
+import static java.io.File.separator;
+
/**
* A TestCase class that acts as the superclass for all test cases wishing to drive the ajc compiler.
* <p>
public static final String CLASSPATH_ASM =
Arrays.stream(System.getProperty("java.class.path")
- .split(File.pathSeparator))
+ .split(pathSeparator))
.filter(path -> path.replace('\\', '/').contains("org/ow2/asm/"))
.findFirst()
.orElseThrow(() -> new RuntimeException("ASM library not found on classpath"));
// see Ajc and AntSpec
public static final String DEFAULT_CLASSPATH_ENTRIES =
Ajc.outputFolders("bridge","util","loadtime","weaver","asm","testing-client","runtime","org.aspectj.matcher")
- + File.pathSeparator + ".." + File.separator + "lib" + File.separator + "junit" + File.separator + "junit.jar"
- + File.pathSeparator + ".." + File.separator + "lib" + File.separator + "bcel" + File.separator + "bcel.jar"
- + File.pathSeparator + ".." + File.separator + "lib" + File.separator + "bcel" + File.separator + "bcel-verifier.jar"
- + File.pathSeparator + CLASSPATH_ASM
- + File.pathSeparator + ".." + File.separator + "lib" + File.separator + "test" + File.separator + "testing-client.jar"
+ + pathSeparator + ".." + separator + "lib" + separator + "junit" + separator + "junit.jar"
+ + pathSeparator + ".." + separator + "lib" + separator + "bcel" + separator + "bcel.jar"
+ + pathSeparator + ".." + separator + "lib" + separator + "bcel" + separator + "bcel-verifier.jar"
+ + pathSeparator + CLASSPATH_ASM
+ + pathSeparator + ".." + separator + "lib" + separator + "test" + separator + "testing-client.jar"
// hmmm, this next one should perhaps point to an aj-build jar...
- + File.pathSeparator + ".." + File.separator + "lib" + File.separator + "test" + File.separator + "aspectjrt.jar"
+ + pathSeparator + ".." + separator + "lib" + separator + "test" + separator + "aspectjrt.jar"
;
/*
char[] chars = srcFile.toCharArray();
for (char c : chars) {
if ((c == '\\') || (c == '/')) {
- srcFileName.append(File.separator);
+ srcFileName.append(separator);
} else {
srcFileName.append(c);
}
if (classpath != null) {
// allow replacing this special variable, rather than copying all files to allow tests of jars that don't end in .jar
cp.append(substituteSandbox(classpath));
- cp.append(File.pathSeparator);
+ cp.append(pathSeparator);
}
if (moduleName == null) {
// When running modules, we want more control so don't try to be helpful by adding all jars
StringBuilder mp = new StringBuilder();
if (modulepath != null) {
mp.append(substituteSandbox(modulepath));
- mp.append(File.pathSeparator);
+ mp.append(pathSeparator);
}
URLClassLoader sandboxLoader;
File directory = new File (".");
String absPath = directory.getAbsolutePath();
- String javaagent= absPath+File.separator+".."+File.separator+"aj-build"+File.separator+"dist"+File.separator+"tools"+File.separator+"lib"+File.separator+"aspectjweaver.jar";
+ String javaagent= absPath+separator+".."+separator+"aj-build"+separator+"dist"+separator+"tools"+separator+"lib"+separator+"aspectjweaver.jar";
try {
String command ="java " +vmargs+ " -classpath " + cp +" -javaagent:"+javaagent + " " + className ;
mp = mp.replace(mp.indexOf("$runtime"),"$runtime".length(),TestUtil.aspectjrtPath().toString());
}
if (cp.indexOf("aspectjrt")==-1) {
- cp.append(TestUtil.aspectjrtPath().getPath()).append(File.pathSeparator);
+ cp.append(TestUtil.aspectjrtPath().getPath()).append(pathSeparator);
}
String command = LangUtil.getJavaExecutable().getAbsolutePath() + " " +vmargs+ (cp.length()==0?"":" -classpath " + cp) + " -p "+mp+" --module "+moduleName ;
if (Ajc.verbose) {
// mp = mp.replace(mp.indexOf("$runtime"),"$runtime".length(),TestUtil.aspectjrtPath().toString());
// }
if (cp.indexOf("aspectjrt")==-1) {
- cp.append(File.pathSeparator).append(TestUtil.aspectjrtPath().getPath());
+ cp.append(pathSeparator).append(TestUtil.aspectjrtPath().getPath());
}
String command = LangUtil.getJavaExecutable().getAbsolutePath() + " " +vmargs+ (cp.length()==0?"":" -classpath " + cp) + " " + className ;
if (Ajc.verbose) {
}
private URL[] getURLs(String classpath) {
- StringTokenizer strTok = new StringTokenizer(classpath, File.pathSeparator);
+ StringTokenizer strTok = new StringTokenizer(classpath, pathSeparator);
URL[] urls = new URL[strTok.countTokens()];
try {
for (int i = 0; i < urls.length; i++) {
cpIndex++;
String[] newargs = new String[args.length];
System.arraycopy(args, 0, newargs, 0, args.length);
- newargs[cpIndex] = args[cpIndex] + File.pathSeparator + TestUtil.aspectjrtPath().getPath();
+ newargs[cpIndex] = args[cpIndex] + pathSeparator + TestUtil.aspectjrtPath().getPath();
args = newargs;
}
}
if (needsJRTFS) {
if (!args[cpIndex].contains(LangUtil.JRT_FS)) {
String jrtfsPath = LangUtil.getJrtFsFilePath();
- args[cpIndex] = jrtfsPath + File.pathSeparator + args[cpIndex];
+ args[cpIndex] = jrtfsPath + pathSeparator + args[cpIndex];
}
}
return args;
File[] files = dir.listFiles();
for (File file : files) {
if (file.getName().endsWith(".jar")) {
- buff.append(File.pathSeparator);
+ buff.append(pathSeparator);
buff.append(file.getAbsolutePath());
} else if (file.isDirectory()) {
getAnyJars(file, buff);