aboutsummaryrefslogtreecommitdiffstats
path: root/taskdefs
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2020-08-12 15:20:45 -0700
committerGitHub <noreply@github.com>2020-08-12 15:20:45 -0700
commitb6eee2e1052116aa22ebbd3c2baf05c2b709bee5 (patch)
tree01fb5493dc348d42e4fb9fb6ce1cd41e361d666b /taskdefs
parentcacc9d5602b7bbe6192d5ff1351605dc180cc108 (diff)
parent29f947156e58f3f0c60e721d42e7f3e98de7180a (diff)
downloadaspectj-b6eee2e1052116aa22ebbd3c2baf05c2b709bee5.tar.gz
aspectj-b6eee2e1052116aa22ebbd3c2baf05c2b709bee5.zip
Merge pull request #1 from larsgrefer/feature/java5
Update the code to Java 5 features
Diffstat (limited to 'taskdefs')
-rw-r--r--taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc10.java50
-rw-r--r--taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc11CompilerAdapter.java2
-rw-r--r--taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java34
-rw-r--r--taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcCompilerAdapter.java6
-rw-r--r--taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java29
-rw-r--r--taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajdoc.java83
-rw-r--r--taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/compilers/Ajc.java40
-rw-r--r--taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/Ajc11CompilerAdapterTest.java10
-rw-r--r--taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java94
9 files changed, 172 insertions, 176 deletions
diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc10.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc10.java
index 065f44e71..354702f5a 100644
--- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc10.java
+++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc10.java
@@ -439,32 +439,32 @@ public class Ajc10 extends MatchingTask {
int numargfiles = 0;
if (argfiles != null) {
- for (Iterator i = argfiles.iterator(); i.hasNext();) {
- String name = i.next()+"";
- File argfile = project.resolveFile(name);
- if (check(argfile, name, false, location)) {
- cmd.createArgument().setValue("-argfile");
- cmd.createArgument().setFile(argfile);
- numargfiles++;
- }
- }
+ for (Object o : argfiles) {
+ String name = o + "";
+ File argfile = project.resolveFile(name);
+ if (check(argfile, name, false, location)) {
+ cmd.createArgument().setValue("-argfile");
+ cmd.createArgument().setFile(argfile);
+ numargfiles++;
+ }
+ }
}
int numfiles = 0;
if (srcdir != null) {
// todo: ignore any srcdir if any argfiles and no explicit includes
String[] dirs = srcdir.list();
- for (int i = 0; i < dirs.length; i++) {
- File dir = project.resolveFile(dirs[i]);
- check(dir, dirs[i], true, location);
- String[] files = getDirectoryScanner(dir).getIncludedFiles();
- for (int j = 0; j < files.length; j++) {
- File file = new File(dir, files[j]);
- if (FileUtil.hasSourceSuffix(file)) {
- cmd.createArgument().setFile(file);
- numfiles++;
- }
- }
- }
+ for (String value : dirs) {
+ File dir = project.resolveFile(value);
+ check(dir, value, true, location);
+ String[] files = getDirectoryScanner(dir).getIncludedFiles();
+ for (String s : files) {
+ File file = new File(dir, s);
+ if (FileUtil.hasSourceSuffix(file)) {
+ cmd.createArgument().setFile(file);
+ numfiles++;
+ }
+ }
+ }
}
if ((null != ignoredOptions) && (ignoredOptions.size() > 0)) {
log("The following attributes were ignored " + ignoredOptions,
@@ -568,10 +568,10 @@ public class Ajc10 extends MatchingTask {
public static String render(String[] args) {
if (null == args) return "";
StringBuffer sb = new StringBuffer();
- for (int i = 0; i < args.length; i++) {
- sb.append(args[i]);
- sb.append(" ");
- }
+ for (String arg : args) {
+ sb.append(arg);
+ sb.append(" ");
+ }
return sb.toString();
}
diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc11CompilerAdapter.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc11CompilerAdapter.java
index a64c5131e..d74fa5134 100644
--- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc11CompilerAdapter.java
+++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc11CompilerAdapter.java
@@ -79,7 +79,7 @@ public class Ajc11CompilerAdapter implements CompilerAdapter {
if (null == javac) {
throw new IllegalStateException("null javac");
}
- if (!((Boolean) inSelfCall.get()).booleanValue()
+ if (!(Boolean) inSelfCall.get()
&& afterCleaningDirs()) {
// if we are not re-calling ourself and we cleaned dirs,
// then re-call javac to get the list of all source files.
diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java
index f31c7558f..84f661cd5 100644
--- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java
+++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java
@@ -416,11 +416,10 @@ public class Ajc2 extends Javac {
List newIncludes = new ArrayList();
List newArguments = new ArrayList();
if (argfiles != null) {
- Iterator iter = argfiles.iterator();
- while (iter.hasNext()) {
- File argfile = ((Argfile)iter.next()).getFile();
- expandArgfile(argfile, newIncludes, newArguments);
- }
+ for (Object o : argfiles) {
+ File argfile = ((Argfile) o).getFile();
+ expandArgfile(argfile, newIncludes, newArguments);
+ }
}
// If there aren't any includes, but we've used an argfile then we should
@@ -434,21 +433,20 @@ public class Ajc2 extends Javac {
// Otherwise we want to add all .java files to the compileList
else {
- for (int i = 0; i < files.length; i++) {
- File newFile = new File(srcDir, files[i]);
- if (newFile != null &&
- newFile.exists() &&
- newFile.getName().endsWith(".java")) {
- newFiles.add(newFile);
- }
- }
+ for (String file : files) {
+ File newFile = new File(srcDir, file);
+ if (newFile != null &&
+ newFile.exists() &&
+ newFile.getName().endsWith(".java")) {
+ newFiles.add(newFile);
+ }
+ }
}
// Add the new included files
- Iterator iter = newIncludes.iterator();
- while (iter.hasNext()) {
- newFiles.add((File)iter.next());
- }
+ for (Object newInclude : newIncludes) {
+ newFiles.add((File) newInclude);
+ }
// This is the same behavior found in Javac
int newFileSize = newFiles.size();
@@ -500,7 +498,7 @@ public class Ajc2 extends Javac {
}
// If there are stars we'll try to resolve the file here
- else if (line.indexOf("*") != -1) {
+ else if (line.contains("*")) {
log("The argfile line '" + line + "' is invalid",
Project.MSG_WARN);
}
diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcCompilerAdapter.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcCompilerAdapter.java
index 1542f6cb4..a0c84d2db 100644
--- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcCompilerAdapter.java
+++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcCompilerAdapter.java
@@ -94,9 +94,9 @@ public class AjcCompilerAdapter implements CompilerAdapter {
tempAjc.setIncludeantruntime(javac.getIncludeantruntime()); // XXX unsupported
File[] files = javac.getFileList();
if (null != files) {
- for (int i = 0; i < files.length; i++) {
- tempAjc.backdoorSetFile(files[i]);
- }
+ for (File file : files) {
+ tempAjc.backdoorSetFile(file);
+ }
}
ajc = tempAjc;
}
diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java
index 4f40526c7..8a7c8a511 100644
--- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java
+++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java
@@ -207,7 +207,7 @@ public class AjcTask extends MatchingTask {
int loc = path.lastIndexOf(prefix);
if ((-1 != loc) && ((loc + minLength) <= path.length())) {
String rest = path.substring(loc + prefixLength);
- if (-1 != rest.indexOf(File.pathSeparator)) {
+ if (rest.contains(File.pathSeparator)) {
return null;
}
if (rest.startsWith(infix) || rest.startsWith(altInfix)) {
@@ -827,7 +827,7 @@ public class AjcTask extends MatchingTask {
*/
public void setInpathDirCopyFilter(String filter) {
if (null != filter) {
- if (-1 == filter.indexOf("**/*.class")) {
+ if (!filter.contains("**/*.class")) {
filter = "**/*.class," + filter;
}
}
@@ -1161,9 +1161,9 @@ public class AjcTask extends MatchingTask {
String[] makeCommand() {
ArrayList result = new ArrayList();
if (0 < ignored.size()) {
- for (Iterator iter = ignored.iterator(); iter.hasNext();) {
- logVerbose("ignored: " + iter.next());
- }
+ for (Object o : ignored) {
+ logVerbose("ignored: " + o);
+ }
}
// when copying resources, use temp jar for class output
// then copy temp jar contents and resources to output jar
@@ -1344,7 +1344,7 @@ public class AjcTask extends MatchingTask {
String message = fail.getMessage();
if (LangUtil.isEmpty(message)) {
message = "<no message>";
- } else if (-1 != message.indexOf(USAGE_SUBSTRING)) {
+ } else if (message.contains(USAGE_SUBSTRING)) {
continue;
}
Throwable t = fail.getThrown();
@@ -1576,14 +1576,15 @@ public class AjcTask extends MatchingTask {
}
}
if (0 < adapterFiles.size()) {
- for (Iterator iter = adapterFiles.iterator(); iter.hasNext();) {
- File file = (File) iter.next();
- if (file.canRead() && FileUtil.hasSourceSuffix(file)) {
- list.add(file.getAbsolutePath());
- } else {
- this.logger.warning("skipping file: " + file);
- }
- }
+ for (Object adapterFile : adapterFiles) {
+ File file = (File) adapterFile;
+ if (file.canRead() && FileUtil.hasSourceSuffix(file)) {
+ list.add(file.getAbsolutePath());
+ }
+ else {
+ this.logger.warning("skipping file: " + file);
+ }
+ }
}
}
diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajdoc.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajdoc.java
index b787a2f89..194efaf22 100644
--- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajdoc.java
+++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajdoc.java
@@ -178,9 +178,9 @@ public class Ajdoc extends MatchingTask {
File baseDir = fs.getDir(getProject());
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
String[] files = ds.getIncludedFiles();
- for (int i = 0; i < files.length; i++) {
- sourcefiles.add((new File(baseDir, files[i])).getAbsolutePath());
- }
+ for (String file : files) {
+ sourcefiles.add((new File(baseDir, file)).getAbsolutePath());
+ }
}
}
@@ -606,17 +606,16 @@ public class Ajdoc extends MatchingTask {
cmd.createArgument().setValue("-docletpath");
cmd.createArgument().setPath(doclet.path);
}
- for (Iterator i = doclet.params.iterator(); i.hasNext();) {
- Param param = (Param)i.next();
- if (param.name == null) {
- throw new BuildException("Doclet params cannot be null!",
- getLocation());
- }
- cmd.createArgument().setValue(param.name);
- if (param.value == null) {
- cmd.createArgument().setValue(param.value);
- }
- }
+ for (Param param : doclet.params) {
+ if (param.name == null) {
+ throw new BuildException("Doclet params cannot be null!",
+ getLocation());
+ }
+ cmd.createArgument().setValue(param.name);
+ if (param.value == null) {
+ cmd.createArgument().setValue(param.value);
+ }
+ }
}
Map<String,List<String>> groupMap = new HashMap<String,List<String>>();
for (Group group: groups) {
@@ -647,48 +646,48 @@ public class Ajdoc extends MatchingTask {
cmd.createArgument().setValue(pkgstr);
}
if (argfiles != null) {
- for (Iterator i = argfiles.iterator(); i.hasNext();) {
- String name = i.next()+"";
- File argfile = getProject().resolveFile(name);
- if (check(argfile, name, false, getLocation())) {
- cmd.createArgument().setValue("-argfile");
- cmd.createArgument().setFile(argfile);
- }
- }
+ for (File file : argfiles) {
+ String name = file + "";
+ File argfile = getProject().resolveFile(name);
+ if (check(argfile, name, false, getLocation())) {
+ cmd.createArgument().setValue("-argfile");
+ cmd.createArgument().setFile(argfile);
+ }
+ }
}
if (packageList != null) {
cmd.createArgument().setValue("@" + packageList);
}
if (null != packagenames) {
- for (Iterator<String> i = packagenames.iterator(); i.hasNext();) {
- cmd.createArgument().setValue((String)i.next());
- }
+ for (String packagename : packagenames) {
+ cmd.createArgument().setValue(packagename);
+ }
}
// support for include parameter as a MatchingTask
int numfiles = 0;
if (sourcepath != null) {
String[] dirs = sourcepath.list();
- for (int i = 0; i < dirs.length; i++) {
- File dir = getProject().resolveFile(dirs[i]);
- check(dir, dirs[i], true, getLocation());
- String[] files = getDirectoryScanner(dir).getIncludedFiles();
- for (int j = 0; j < files.length; j++) {
- File file = new File(dir, files[j]);
- if (file.getName().endsWith(".java")
- || file.getName().endsWith(".aj")) {
- cmd.createArgument().setFile(file);
- numfiles++;
- }
- }
- }
+ for (String value : dirs) {
+ File dir = getProject().resolveFile(value);
+ check(dir, value, true, getLocation());
+ String[] files = getDirectoryScanner(dir).getIncludedFiles();
+ for (String s : files) {
+ File file = new File(dir, s);
+ if (file.getName().endsWith(".java")
+ || file.getName().endsWith(".aj")) {
+ cmd.createArgument().setFile(file);
+ numfiles++;
+ }
+ }
+ }
}
addFileSets();
if (sourcefiles != null) {
- for (Iterator<String> i = sourcefiles.iterator(); i.hasNext();) {
- // let ajdoc resolve sourcefiles relative to sourcepath,
- cmd.createArgument().setValue(i.next());
- }
+ for (String sourcefile : sourcefiles) {
+ // let ajdoc resolve sourcefiles relative to sourcepath,
+ cmd.createArgument().setValue(sourcefile);
+ }
}
// XXX PR682 weak way to report errors - need to refactor
int result = compile();
diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/compilers/Ajc.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/compilers/Ajc.java
index 690cccf22..2516a2ac5 100644
--- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/compilers/Ajc.java
+++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/compilers/Ajc.java
@@ -91,11 +91,11 @@ public class Ajc extends DefaultCompilerAdapter {
Project.MSG_WARN));
System.setOut(logstr);
System.setErr(logstr);
- return ((Integer)main.getMethod
- ("compile", new Class[]{String[].class}).invoke
- (main.newInstance(), new Object[]{
- removeUnsupported(cline, logstr)
- })).intValue() == AJC_COMPILER_SUCCESS;
+ return (Integer) main.getMethod
+ ("compile", new Class[]{String[].class}).invoke
+ (main.newInstance(), new Object[]{
+ removeUnsupported(cline, logstr)
+ }) == AJC_COMPILER_SUCCESS;
} catch (Exception e) {
if (e instanceof BuildException) {
throw (BuildException)e;
@@ -198,25 +198,23 @@ public class Ajc extends DefaultCompilerAdapter {
niceSourceList.append(" to be compiled:");
niceSourceList.append(lSep);
- for (int i=0; i < compileList.length; i++) {
+ for (File file : compileList) {
- // DefaultCompilerAdapter only expects .java files but we must deal
- // with .lst files also
- File file = compileList[i];
+ // DefaultCompilerAdapter only expects .java files but we must deal
+ // with .lst files also
+ if (file == null) continue;
- if (file == null) continue;
+ String arg = file.getAbsolutePath();
+ String rest = "";
+ String name = file.getName();
- String arg = file.getAbsolutePath();
- String rest = "";
- String name = file.getName();
-
- // For .java files take the default behavior and add that
- // file to the command line
- if (name.endsWith(".java")) {
- cmd.createArgument().setValue(arg);
- }
- niceSourceList.append(" " + arg + rest + lSep);
- }
+ // For .java files take the default behavior and add that
+ // file to the command line
+ if (name.endsWith(".java")) {
+ cmd.createArgument().setValue(arg);
+ }
+ niceSourceList.append(" " + arg + rest + lSep);
+ }
attributes.log(niceSourceList.toString(), Project.MSG_VERBOSE);
}
}
diff --git a/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/Ajc11CompilerAdapterTest.java b/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/Ajc11CompilerAdapterTest.java
index 3b95693e2..80e9ed4a0 100644
--- a/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/Ajc11CompilerAdapterTest.java
+++ b/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/Ajc11CompilerAdapterTest.java
@@ -35,11 +35,11 @@ public class Ajc11CompilerAdapterTest extends TestCase {
}
public void tearDown() {
- for (Iterator iter = tempFiles.iterator(); iter.hasNext();) {
- File file = (File) iter.next();
- FileUtil.deleteContents(file);
- file.delete();
- }
+ for (Object tempFile : tempFiles) {
+ File file = (File) tempFile;
+ FileUtil.deleteContents(file);
+ file.delete();
+ }
}
// public void testCompilerAdapterWithJavac() { // XXX requires tools.jar
diff --git a/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java b/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java
index c149ad79b..4b387c21b 100644
--- a/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java
+++ b/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java
@@ -178,7 +178,7 @@ public class AjcTaskTest extends TestCase {
String m = e.getMessage();
if (null == m) {
assertTrue("not " + exceptionString, false);
- } else if (-1 == m.indexOf(exceptionString)) {
+ } else if (!m.contains(exceptionString)) {
assertEquals(exceptionString, e.getMessage());
}
}
@@ -187,17 +187,17 @@ public class AjcTaskTest extends TestCase {
}
private void checkContains(String[] cmd, String option, boolean contains) {
- for (int i = 0; i < cmd.length; i++) {
- if (option.equals(cmd[i])) {
- if (contains) {
- return;
- } else {
- assertTrue(
- "not expecting " + option + " in " + Arrays.asList(cmd),
- false);
- }
- }
- }
+ for (String s : cmd) {
+ if (option.equals(s)) {
+ if (contains) {
+ return;
+ } else {
+ assertTrue(
+ "not expecting " + option + " in " + Arrays.asList(cmd),
+ false);
+ }
+ }
+ }
if (contains) {
assertTrue(
"expecting " + option + " in " + Arrays.asList(cmd),
@@ -218,7 +218,7 @@ public class AjcTaskTest extends TestCase {
if (NOFILE.equals(input)) {
// add nothing
} else if (input.endsWith(".lst")) {
- if (-1 != input.indexOf(",")) {
+ if (input.contains(",")) {
throw new IllegalArgumentException(
"lists not supported: " + input);
} else if (null == testdataDir) {
@@ -279,8 +279,8 @@ public class AjcTaskTest extends TestCase {
AjcTask task = getTask(NOFILE, null);
String[] cmd = task.makeCommand();
- for (int i = 0; i < cmd.length; i++) {
- assertTrue(!"-d".equals(cmd[i]));
+ for (String s : cmd) {
+ assertTrue(!"-d".equals(s));
}
}
@@ -398,14 +398,14 @@ public class AjcTaskTest extends TestCase {
String[] expected = {"copyMe.htm", "pack/includeme",
"pack/Pack.class", "Default.class"};
String[] unexpected = {"doNotCopy", "skipTxtFiles.txt", "pack/something.txt"};
- for (int i = 0; i < expected.length; i++) {
- JarEntry entry = jarFile.getJarEntry(expected[i]);
- assertTrue(expected[i] + " not found", null != entry);
- }
- for (int i = 0; i < unexpected.length; i++) {
- JarEntry entry = jarFile.getJarEntry(unexpected[i]);
- assertTrue(unexpected[i] + " found", null == entry);
- }
+ for (String value : expected) {
+ JarEntry entry = jarFile.getJarEntry(value);
+ assertTrue(value + " not found", null != entry);
+ }
+ for (String s : unexpected) {
+ JarEntry entry = jarFile.getJarEntry(s);
+ assertTrue(s + " found", null == entry);
+ }
}
public void testInpathDirCopyFilterError() {
@@ -656,30 +656,30 @@ public class AjcTaskTest extends TestCase {
public void testVersions() {
String[] inputs = AjcTask.TARGET_INPUTS;
- for (int i = 0; i < inputs.length; i++) {
+ for (String value : inputs) {
AjcTask task = getTask(NOFILE);
- task.setTarget(inputs[i]);
+ task.setTarget(value);
String[] cmd = task.makeCommand();
- checkContains(cmd, "-target", true);
- checkContains(cmd, inputs[i], true);
+ checkContains(cmd, "-target", true);
+ checkContains(cmd, value, true);
}
inputs = AjcTask.SOURCE_INPUTS;
- for (int i = 0; i < inputs.length; i++) {
- AjcTask task = getTask(NOFILE);
- task.setSource(inputs[i]);
- String[] cmd = task.makeCommand();
- checkContains(cmd, "-source", true);
- checkContains(cmd, inputs[i], true);
- }
+ for (String s : inputs) {
+ AjcTask task = getTask(NOFILE);
+ task.setSource(s);
+ String[] cmd = task.makeCommand();
+ checkContains(cmd, "-source", true);
+ checkContains(cmd, s, true);
+ }
inputs = AjcTask.COMPLIANCE_INPUTS;
- for (int i = 0; i < inputs.length; i++) {
- AjcTask task = getTask(NOFILE);
- task.setCompliance(inputs[i]);
- String[] cmd = task.makeCommand();
- checkContains(cmd, inputs[i], true);
- }
+ for (String input : inputs) {
+ AjcTask task = getTask(NOFILE);
+ task.setCompliance(input);
+ String[] cmd = task.makeCommand();
+ checkContains(cmd, input, true);
+ }
}
public void testClasspath() {
@@ -695,7 +695,7 @@ public class AjcTaskTest extends TestCase {
}
assertTrue(
"expecting aspectj in classpath",
- (-1 != classpath.indexOf("aspectjrt.jar")));
+ (classpath.contains("aspectjrt.jar")));
}
CompilerArg createCompilerArg(String value) {
@@ -792,7 +792,7 @@ public class AjcTaskTest extends TestCase {
boolean matched = false;
for (int i = 0; !matched && (i < results.length); i++) {
String s = results[i];
- matched = (null != s) && (-1 != s.indexOf(DEFAULT));
+ matched = (null != s) && (s.contains(DEFAULT));
}
if (!matched) {
fail(DEFAULT + " not found in " + Arrays.asList(results));
@@ -807,11 +807,11 @@ public class AjcTaskTest extends TestCase {
"reweavable:compress",
"noInline"
};
- for (int i = 0; i < xopts.length; i++) {
+ for (String xopt : xopts) {
AjcTask task = getTask(NOFILE);
- task.setX(xopts[i]);
+ task.setX(xopt);
String[] cmd = task.makeCommand();
- checkContains(cmd,"-X" + xopts[i],true);
+ checkContains(cmd, "-X" + xopt, true);
}
}
@@ -1080,8 +1080,8 @@ class VerboseCommandEditor implements ICommandEditor {
public static final String VERBOSE = "-verbose";
@Override
public String[] editCommand(String[] command) {
- for (int i = 0; i < command.length; i++) {
- if (VERBOSE.equals(command[i])) {
+ for (String s : command) {
+ if (VERBOSE.equals(s)) {
return command;
}
}