diff options
author | Lars Grefer <eclipse@larsgrefer.de> | 2020-08-08 03:11:12 +0200 |
---|---|---|
committer | Lars Grefer <eclipse@larsgrefer.de> | 2020-08-08 03:11:12 +0200 |
commit | c1c373f4278426308689db61f7758185e8f0401b (patch) | |
tree | 9e03af2feb69782c50464fc1e1e2ce0d6b6bb8c5 | |
parent | a508fd5315c6330f2057c219aebc35b15d0ea497 (diff) | |
download | aspectj-c1c373f4278426308689db61f7758185e8f0401b.tar.gz aspectj-c1c373f4278426308689db61f7758185e8f0401b.zip |
'String.indexOf()' expression is replaceable with 'contains()'
Reports any String.indexOf() expressions which can be replaced with a call to the String.contains() method available in Java 5 and newer.
Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>
105 files changed, 235 insertions, 238 deletions
diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/AjdeCoreTestCase.java b/ajde.core/src/test/java/org/aspectj/ajde/core/AjdeCoreTestCase.java index eafa22f04..c692d6d50 100644 --- a/ajde.core/src/test/java/org/aspectj/ajde/core/AjdeCoreTestCase.java +++ b/ajde.core/src/test/java/org/aspectj/ajde/core/AjdeCoreTestCase.java @@ -125,7 +125,7 @@ public abstract class AjdeCoreTestCase extends TestCase { public boolean checkFor(String what) { List<TestMessage> ll = ((TestMessageHandler) compiler.getMessageHandler()).getMessages(); for (TestMessage element: ll) { - if (element.toString().indexOf(what) != -1) + if (element.toString().contains(what)) return true; } return false; diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/TestBuildProgressMonitor.java b/ajde.core/src/test/java/org/aspectj/ajde/core/TestBuildProgressMonitor.java index 2a293b626..e214faeae 100644 --- a/ajde.core/src/test/java/org/aspectj/ajde/core/TestBuildProgressMonitor.java +++ b/ajde.core/src/test/java/org/aspectj/ajde/core/TestBuildProgressMonitor.java @@ -52,7 +52,7 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor { if (text.startsWith("woven class ")) numWovenClassMessages++; if (text.startsWith("compiled:")) numCompiledMessages++; if (programmableString != null - && text.indexOf(programmableString) != -1) { + && text.contains(programmableString)) { count--; if (count==0) { if (debugTests) System.out.println("Just got message '"+newText+"' - asking build to cancel"); @@ -76,7 +76,7 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor { public boolean containsMessage(String prefix,String distinguishingMarks) { for (String element: messagesReceived) { if (element.startsWith(prefix) && - element.indexOf(distinguishingMarks)!=-1) return true; + element.contains(distinguishingMarks)) return true; } return false; } diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/InpathTest.java b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/InpathTest.java index 0696aa908..2d1b3fd7c 100644 --- a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/InpathTest.java +++ b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/InpathTest.java @@ -242,7 +242,7 @@ public class InpathTest extends AjdeCoreTestCase { while (null != (entry = outjar.getNextEntry())) { String fileName = entry.getName(); fileName = fileName.replace('\\', '/'); - if (fileName.indexOf("CVS") == -1) { + if (!fileName.contains("CVS")) { boolean b = expectedOutputJarContents.remove(fileName); assertTrue("Unexpectedly found : " + fileName + " in outjar", b); } @@ -295,7 +295,7 @@ public class InpathTest extends AjdeCoreTestCase { File binBase = openFile(outdirName); String[] toResources = FileUtil.listFiles(binBase); for (String fileName : toResources) { - if (fileName.indexOf("CVS") == -1) { + if (!fileName.contains("CVS")) { boolean b = expectedOutdirContents.remove(fileName); assertTrue("Extraneous resources: " + fileName, b); } @@ -310,7 +310,7 @@ public class InpathTest extends AjdeCoreTestCase { for (File fromResource : fromResources) { String name = FileUtil.normalizedPath(fromResource, srcBase); // System.err.println("Checking "+name); - if (!name.startsWith("CVS/") && (-1 == name.indexOf("/CVS/")) && !name.endsWith("/CVS")) { + if (!name.startsWith("CVS/") && (!name.contains("/CVS/")) && !name.endsWith("/CVS")) { resources.add(name); } } diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ResourceCopyTest.java b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ResourceCopyTest.java index b6f44ae7d..889e2e5ce 100644 --- a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ResourceCopyTest.java +++ b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ResourceCopyTest.java @@ -169,7 +169,7 @@ public class ResourceCopyTest extends AjdeCoreTestCase { File[] fromResources = FileUtil.listFiles(srcBase, aspectjResourceFileFilter); for (File fromResource : fromResources) { String name = FileUtil.normalizedPath(fromResource, srcBase); - if (!name.startsWith("CVS/") && (-1 == name.indexOf("/CVS/")) && !name.endsWith("/CVS")) { + if (!name.startsWith("CVS/") && (!name.contains("/CVS/")) && !name.endsWith("/CVS")) { resources.add(name); } } @@ -179,7 +179,7 @@ public class ResourceCopyTest extends AjdeCoreTestCase { @Override public boolean accept(File pathname) { String name = pathname.getName().toLowerCase(); - boolean isCVSRelated = name.indexOf("/cvs/") != -1; + boolean isCVSRelated = name.contains("/cvs/"); return (!isCVSRelated && !name.endsWith(".class") && !name.endsWith(".java") && !name.endsWith(".aj")); } }; diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/StructureSearchManager.java b/ajde/src/main/java/org/aspectj/ajde/ui/StructureSearchManager.java index d9e9a0f52..8839b00da 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/StructureSearchManager.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/StructureSearchManager.java @@ -45,7 +45,7 @@ public class StructureSearchManager { private List<IProgramElement> findMatchesHelper(IProgramElement node, String pattern, IProgramElement.Kind kind, List<IProgramElement> matches) { - if (node != null && node.getName().indexOf(pattern) != -1) { + if (node != null && node.getName().contains(pattern)) { if (kind == null || node.getKind().equals(kind)) { matches.add(node); } diff --git a/ajde/src/test/java/org/aspectj/ajde/ExtensionTest.java b/ajde/src/test/java/org/aspectj/ajde/ExtensionTest.java index a8ce3d922..ce0269930 100644 --- a/ajde/src/test/java/org/aspectj/ajde/ExtensionTest.java +++ b/ajde/src/test/java/org/aspectj/ajde/ExtensionTest.java @@ -79,7 +79,7 @@ public class ExtensionTest extends AjcTestCase { private IProgramElement getChild(IProgramElement parent, String s) { List<IProgramElement> kids = parent.getChildren(); for (IProgramElement element : kids) { - if (element.getName().indexOf(s) != -1) + if (element.getName().contains(s)) return element; } return null; @@ -90,7 +90,7 @@ public class ExtensionTest extends AjcTestCase { private void findChild(String s, IProgramElement ipe) { if (ipe == null) return; - if (ipe.getName().indexOf(s) != -1) { + if (ipe.getName().contains(s)) { foundNode = ipe; return; } diff --git a/ajde/src/test/java/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java b/ajde/src/test/java/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java index c80f33bb6..fe642ff95 100644 --- a/ajde/src/test/java/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java +++ b/ajde/src/test/java/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java @@ -53,7 +53,7 @@ public class LstBuildConfigManagerTest extends AjdeTestCase { doBuild("bad-injar.lst"); messages = getMessages("bad-injar.lst"); message = (TestMessage)messages.get(0); - assertTrue(message.getContainedMessage().getMessage().indexOf("skipping missing, empty or corrupt inpath entry") != -1); + assertTrue(message.getContainedMessage().getMessage().contains("skipping missing, empty or corrupt inpath entry")); } public void testErrorMessages() throws IOException { @@ -63,7 +63,7 @@ public class LstBuildConfigManagerTest extends AjdeTestCase { List messages = getMessages("invalid-entry.lst"); TestMessage message = (TestMessage)messages.get(0); - assertTrue(message.getContainedMessage().getMessage(), message.getContainedMessage().getMessage().indexOf("aaa.bbb") != -1); + assertTrue(message.getContainedMessage().getMessage(), message.getContainedMessage().getMessage().contains("aaa.bbb")); } diff --git a/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestBuildProgressMonitor.java b/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestBuildProgressMonitor.java index 6ccddefc0..09d794191 100644 --- a/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestBuildProgressMonitor.java +++ b/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestBuildProgressMonitor.java @@ -55,7 +55,7 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor { if (text.startsWith("woven class ")) numWovenClassMessages++; if (text.startsWith("compiled:")) numCompiledMessages++; if (programmableString != null - && text.indexOf(programmableString) != -1) { + && text.contains(programmableString)) { count--; if (count==0) { if (debugTests) System.out.println("Just got message '"+newText+"' - asking build to cancel"); @@ -80,7 +80,7 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor { for (Object o : messagesReceived) { String element = (String) o; if (element.startsWith(prefix) && - element.indexOf(distinguishingMarks) != -1) return true; + element.contains(distinguishingMarks)) return true; } return false; } diff --git a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java index 35e84ca5a..44708bb01 100644 --- a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java +++ b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java @@ -192,7 +192,7 @@ class HtmlDecorator { } // only add aspect documentation if we're in the correct // file for the given IProgramElement - if (file.getName().indexOf(fullname + ".html") != -1) { + if (file.getName().contains(fullname + ".html")) { addAspectDocumentation(decl, fileContents, index); } } else { @@ -202,7 +202,7 @@ class HtmlDecorator { // moved this here because then can use the IProgramElement.Kind // rather than checking to see if there's advice - this fixes // the case with an inner aspect not having the title "Aspect" - if (decl.getKind().equals(IProgramElement.Kind.ASPECT) && file.getName().indexOf(decl.toSignatureString()) != -1) { + if (decl.getKind().equals(IProgramElement.Kind.ASPECT) && file.getName().contains(decl.toSignatureString())) { // only want to change "Class" to "Aspect" if we're in the // file corresponding to the IProgramElement String fullname = ""; @@ -212,7 +212,7 @@ class HtmlDecorator { } else { fullname += decl.toSignatureString(); } - if (file.getName().indexOf(fullname + ".html") == -1) { + if (!file.getName().contains(fullname + ".html")) { // we're still in the file for a parent IPE continue; } @@ -746,7 +746,7 @@ class HtmlDecorator { */ private static String getRelativePathFromHere(String packagePath) { StringBuffer result = new StringBuffer(""); - if (packagePath != null && (packagePath.indexOf("/") != -1)) { + if (packagePath != null && (packagePath.contains("/"))) { StringTokenizer sTok = new StringTokenizer(packagePath, "/", false); while (sTok.hasMoreTokens()) { sTok.nextToken(); // don't care about the token value diff --git a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/StubFileGenerator.java b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/StubFileGenerator.java index cd8a01e26..4b9301ce8 100644 --- a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/StubFileGenerator.java +++ b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/StubFileGenerator.java @@ -153,7 +153,7 @@ class StubFileGenerator { if (member.getKind().equals(IProgramElement.Kind.METHOD) || member.getKind().equals(IProgramElement.Kind.CONSTRUCTOR)) { - if (member.getParent().getKind().equals(IProgramElement.Kind.INTERFACE) || signature.indexOf("abstract ") != -1) { + if (member.getParent().getKind().equals(IProgramElement.Kind.INTERFACE) || signature.contains("abstract ")) { writer.println(";"); } else { writer.println(" { }"); diff --git a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocOutputChecker.java b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocOutputChecker.java index b22d1250d..797c76660 100644 --- a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocOutputChecker.java +++ b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocOutputChecker.java @@ -41,7 +41,7 @@ public class AjdocOutputChecker { BufferedReader reader = new BufferedReader(new FileReader(htmlFile)); String line = reader.readLine(); while (line != null) { - if (line.indexOf(requiredString) != -1) { + if (line.contains(requiredString)) { reader.close(); return true; } @@ -89,11 +89,11 @@ public class AjdocOutputChecker { BufferedReader reader = new BufferedReader(new FileReader(htmlFile)); String line = reader.readLine(); while (line != null) { - if (line.indexOf(sectionHeader) != -1) { + if (line.contains(sectionHeader)) { String nextLine = reader.readLine(); while (nextLine != null && - (nextLine.indexOf("========") == -1)) { - if (nextLine.indexOf(requiredString) != -1) { + (!nextLine.contains("========"))) { + if (nextLine.contains(requiredString)) { reader.close(); return true; } @@ -151,11 +151,11 @@ public class AjdocOutputChecker { BufferedReader reader = new BufferedReader(new FileReader(htmlFile)); String line = reader.readLine(); while (line != null) { - if (line.indexOf("START OF CLASS DATA") != -1) { + if (line.contains("START OF CLASS DATA")) { // found the required class data section String subLine = reader.readLine(); while(subLine != null - && (subLine.indexOf("========") == -1)){ + && (!subLine.contains("========"))){ int relIndex = subLine.indexOf(relationship.toString()); int targetIndex = subLine.indexOf(target); if ((relIndex != -1) && (targetIndex != -1)) { @@ -195,24 +195,24 @@ public class AjdocOutputChecker { if (((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html"))) { return false; } - if (sectionHeader.indexOf("DETAIL") == -1) { + if (!sectionHeader.contains("DETAIL")) { return false; } BufferedReader reader = new BufferedReader(new FileReader(htmlFile)); String line = reader.readLine(); while (line != null) { - if (line.indexOf(sectionHeader) != -1) { + if (line.contains(sectionHeader)) { // found the required main section String nextLine = reader.readLine(); - while (nextLine != null && (nextLine.indexOf("========") == -1)) { + while (nextLine != null && (!nextLine.contains("========"))) { // On JDK11 it looks like <a id="doIt()"> on earlier JDKs it can look like <a name="doit"> - if ((LangUtil.is11VMOrGreater() && nextLine.indexOf("ID=\""+source+"\"") != -1 || nextLine.indexOf("id=\""+source+"\"") != -1) || - nextLine.indexOf("NAME=\""+source+"\"") != -1 || nextLine.indexOf("name=\""+source+"\"") != -1) { + if ((LangUtil.is11VMOrGreater() && nextLine.contains("ID=\"" + source + "\"") || nextLine.contains("id=\"" + source + "\"")) || + nextLine.contains("NAME=\"" + source + "\"") || nextLine.contains("name=\"" + source + "\"")) { // found the required subsection String subLine = reader.readLine(); while(subLine != null - && (subLine.indexOf("========") == -1) - && (subLine.indexOf("NAME") == -1 && subLine.indexOf("name") == -1)) { + && (!subLine.contains("========")) + && (!subLine.contains("NAME") && !subLine.contains("name"))) { int relIndex = subLine.indexOf(relationship.toString()); int targetIndex = subLine.indexOf(target); if ((relIndex != -1) && (targetIndex != -1)) { @@ -259,22 +259,22 @@ public class AjdocOutputChecker { if (((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html"))) { return false; } - if (sectionHeader.indexOf("SUMMARY") == -1) { + if (!sectionHeader.contains("SUMMARY")) { return false; } BufferedReader reader = new BufferedReader(new FileReader(htmlFile)); String line = reader.readLine(); while (line != null) { - if (line.indexOf(sectionHeader) != -1) { + if (line.contains(sectionHeader)) { // found the required main section String nextLine = reader.readLine(); - while (nextLine != null && (nextLine.indexOf("========") == -1)) { - if (nextLine.indexOf(source) != -1) { + while (nextLine != null && (!nextLine.contains("========"))) { + if (nextLine.contains(source)) { // found the required subsection String subLine = nextLine; while(subLine != null - && (subLine.indexOf("========") == -1) - && (subLine.indexOf("<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">") == -1)) { + && (!subLine.contains("========")) + && (!subLine.contains("<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">"))) { int relIndex = subLine.indexOf(relationship.toString()); int targetIndex = subLine.indexOf(target); if ((relIndex != -1) && (targetIndex != -1)) { diff --git a/asm/src/main/java/org/aspectj/asm/internal/JDTLikeHandleProvider.java b/asm/src/main/java/org/aspectj/asm/internal/JDTLikeHandleProvider.java index 15eb990ee..5e518c51f 100644 --- a/asm/src/main/java/org/aspectj/asm/internal/JDTLikeHandleProvider.java +++ b/asm/src/main/java/org/aspectj/asm/internal/JDTLikeHandleProvider.java @@ -73,7 +73,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { if (folder.endsWith("/")) { folder = folder.substring(0, folder.length() - 1); } - if (folder.indexOf("/") != -1) { + if (folder.contains("/")) { folder = folder.replace("/", "\\/"); } sb.append(folder); @@ -211,7 +211,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { // this code needs a speed overhaul... and some proper tests // Two static parts because one may be enclosing jpsp (269522) if (sig1 != null) { - if (sig1.indexOf("Lorg/aspectj/lang") != -1) { + if (sig1.contains("Lorg/aspectj/lang")) { if (sig1.endsWith("Lorg/aspectj/lang/JoinPoint$StaticPart;")) { sig1 = sig1.substring(0, sig1.lastIndexOf("Lorg/aspectj/lang/JoinPoint$StaticPart;")); } @@ -263,7 +263,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { // this code needs a speed overhaul... and some proper tests // Two static parts because one may be enclosing jpsp (269522) if (sig1 != null) { - if (sig1.indexOf("Lorg/aspectj/lang") != -1) { + if (sig1.contains("Lorg/aspectj/lang")) { if (sig1.endsWith("Lorg/aspectj/lang/JoinPoint$StaticPart;")) { sig1 = sig1.substring(0, sig1.lastIndexOf("Lorg/aspectj/lang/JoinPoint$StaticPart;")); } @@ -358,7 +358,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { ipeSig = ipeSig.substring(0, idx); } if (ipeSig != null) { - if (ipeSig.indexOf("Lorg/aspectj/lang") != -1) { + if (ipeSig.contains("Lorg/aspectj/lang")) { if (ipeSig.endsWith("Lorg/aspectj/lang/JoinPoint$StaticPart;")) { ipeSig = ipeSig.substring(0, ipeSig.lastIndexOf("Lorg/aspectj/lang/JoinPoint$StaticPart;")); } diff --git a/asm/src/main/java/org/aspectj/asm/internal/ProgramElement.java b/asm/src/main/java/org/aspectj/asm/internal/ProgramElement.java index c1479f70f..77fe7a66b 100644 --- a/asm/src/main/java/org/aspectj/asm/internal/ProgramElement.java +++ b/asm/src/main/java/org/aspectj/asm/internal/ProgramElement.java @@ -432,7 +432,7 @@ public class ProgramElement implements IProgramElement { // check if someone is calling us with something that is a signature already assert name.charAt(0) != '['; - if (name.indexOf("<") == -1) { + if (!name.contains("<")) { // not parameterized return new StringBuilder("L").append(name.replace('.', '/')).append(';').toString(); } else { diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Utility.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Utility.java index 2d4b2a81f..9168847b0 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Utility.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Utility.java @@ -243,7 +243,7 @@ public abstract class Utility { StringBuffer buf = new StringBuffer("("); String type; int index; - int var_index = (access.indexOf("static") >= 0) ? 0 : 1; + int var_index = (access.contains("static")) ? 0 : 1; try { // Read all declarations between for `(' and `)' if (signature.charAt(0) != '(') { diff --git a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java index 426ebbea9..d9a4ce780 100644 --- a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java +++ b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java @@ -60,7 +60,7 @@ public class AnnotationGenTest extends BcelTestCase { NameValuePair nvGen = new NameValuePair("id", evg, cp); // Check it looks right - assertTrue("Should include string 'id=4' but says: " + nvGen.toString(), nvGen.toString().indexOf("id=4") != -1); + assertTrue("Should include string 'id=4' but says: " + nvGen.toString(), nvGen.toString().contains("id=4")); ObjectType t = new ObjectType("SimpleAnnotation"); @@ -87,7 +87,7 @@ public class AnnotationGenTest extends BcelTestCase { NameValuePair nvGen = new NameValuePair("id", evg, cp); // Check it looks right - assertTrue("Should include string 'id=4' but says: " + nvGen.toString(), nvGen.toString().indexOf("id=4") != -1); + assertTrue("Should include string 'id=4' but says: " + nvGen.toString(), nvGen.toString().contains("id=4")); ObjectType t = new ObjectType("SimpleAnnotation"); diff --git a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/ElementValueGenTest.java b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/ElementValueGenTest.java index 7d91bd7d3..ec7645aeb 100644 --- a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/ElementValueGenTest.java +++ b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/ElementValueGenTest.java @@ -187,7 +187,7 @@ public class ElementValueGenTest extends BcelTestCase { ClassElementValue evg = new ClassElementValue(classType, cp); assertTrue("Unexpected value for contained class: '" + evg.getClassString() + "'", - evg.getClassString().indexOf("Integer") != -1); + evg.getClassString().contains("Integer")); checkSerialize(evg, cp); } diff --git a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java index f49b4fb46..351caa002 100644 --- a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java +++ b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java @@ -75,9 +75,9 @@ public class ParameterAnnotationsTest extends BcelTestCase { AnnotationGen[] annos = mainMethod.getAnnotationsOnParameter(0); assertTrue("Should be two annotation on the 'argv' parameter to main() but there are "+annos.length,annos.length==2); assertTrue("This annotation should contain the string 'fruit=Apples' but it is "+annos[0].toString(), - annos[0].toString().indexOf("fruit=Apples")!=-1); + annos[0].toString().contains("fruit=Apples")); assertTrue("This annotation should contain the string 'fruit=Oranges' but it is "+annos[1].toString(), - annos[1].toString().indexOf("fruit=Oranges")!=-1); + annos[1].toString().contains("fruit=Oranges")); } @@ -105,9 +105,9 @@ public class ParameterAnnotationsTest extends BcelTestCase { AnnotationGen[] annos = mainMethod.getAnnotationsOnParameter(0); assertTrue("Should be two annotation on the 'argv' parameter to main() but there are "+annos.length,annos.length==2); assertTrue("This annotation should contain the string 'fruit=Apples' but it is "+annos[0].toString(), - annos[0].toString().indexOf("fruit=Apples")!=-1); + annos[0].toString().contains("fruit=Apples")); assertTrue("This annotation should contain the string 'fruit=Oranges' but it is "+annos[1].toString(), - annos[1].toString().indexOf("fruit=Oranges")!=-1); + annos[1].toString().contains("fruit=Oranges")); assertTrue(wipe("temp5","HelloWorld.class")); } diff --git a/bcel-builder/src/test/java/org/aspectj/apache/bcel/util/ClassPathTests.java b/bcel-builder/src/test/java/org/aspectj/apache/bcel/util/ClassPathTests.java index 711011213..53488df0e 100644 --- a/bcel-builder/src/test/java/org/aspectj/apache/bcel/util/ClassPathTests.java +++ b/bcel-builder/src/test/java/org/aspectj/apache/bcel/util/ClassPathTests.java @@ -9,7 +9,7 @@ public class ClassPathTests extends BcelTestCase { public void testJava9ImageFile() throws IOException { String sunbootClasspath = System.getProperty("sun.boot.class.path"); - if (sunbootClasspath==null || sunbootClasspath.indexOf(".jimage")==-1) { + if (sunbootClasspath==null || !sunbootClasspath.contains(".jimage")) { // Not java9 return; } diff --git a/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java b/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java index 0393a5a58..77f9c90a8 100644 --- a/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java +++ b/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java @@ -587,7 +587,7 @@ public class MessageUtil { return true; } String text = message.getMessage(); - return (text.indexOf(infix) != -1); + return (text.contains(infix)); } public void ignore(Kind kind) { diff --git a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java index bef3fb0aa..12286748e 100644 --- a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java +++ b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java @@ -61,10 +61,10 @@ public class AntBuilder extends Builder { boolean useEclipseCompiles = false; boolean verbose = false; if (null != config) { - if (-1 != config.indexOf("useEclipseCompiles")) { + if (config.contains("useEclipseCompiles")) { useEclipseCompiles = true; } - if (-1 != config.indexOf("verbose")) { + if (config.contains("verbose")) { verbose = true; } } diff --git a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java index afa3c71d3..aa0c35e35 100644 --- a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java +++ b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java @@ -422,7 +422,7 @@ public class Checklics extends MatchingTask { if ((null == line) || (0 == line.length())) { return; } - if (!gotLicense && (null != license) && (-1 != line.indexOf(license))) { + if (!gotLicense && (null != license) && (line.contains(license))) { gotLicense = true; } if (!gotCopyright && (null != copyright)) { @@ -670,7 +670,7 @@ class Header { start = loc + 4; } - return (-1 != line.indexOf("*/")); + return (line.contains("*/")); } } // class Header diff --git a/build/src/main/java/org/aspectj/internal/tools/build/Builder.java b/build/src/main/java/org/aspectj/internal/tools/build/Builder.java index 1d7bfa7d8..fe80190ad 100644 --- a/build/src/main/java/org/aspectj/internal/tools/build/Builder.java +++ b/build/src/main/java/org/aspectj/internal/tools/build/Builder.java @@ -251,7 +251,7 @@ public abstract class Builder { */ protected Result specifyResultFor(BuildSpec buildSpec) { if (buildSpec.trimTesting - && (-1 != buildSpec.module.indexOf("testing"))) { // XXXNameLiteral + && (buildSpec.module.contains("testing"))) { // XXXNameLiteral String warning = "Warning - cannot trimTesting for testing modules: "; handler.log(warning + buildSpec.module); } diff --git a/build/src/main/java/org/aspectj/internal/tools/build/Module.java b/build/src/main/java/org/aspectj/internal/tools/build/Module.java index acc8fd90b..65d929707 100644 --- a/build/src/main/java/org/aspectj/internal/tools/build/Module.java +++ b/build/src/main/java/org/aspectj/internal/tools/build/Module.java @@ -444,7 +444,7 @@ public class Module { if (path.equals("org.eclipse.ajdt.core.ASPECTJRT_CONTAINER")) { classpathVariables.add("ASPECTJRT_LIB"); } else { - if (-1 == path.indexOf("JRE")) { // warn non-JRE containers + if (!path.contains("JRE")) { // warn non-JRE containers messager.log("cannot handle con yet: " + toString); } } @@ -614,7 +614,7 @@ public class Module { boolean inQuote = false; while (st.hasMoreTokens()) { String s = st.nextToken(); - if ((1 == s.length()) && (-1 != DELIM.indexOf(s))) { + if ((1 == s.length()) && (DELIM.contains(s))) { if ("\"".equals(s)) { // end quote (or escaped) if (inQuote) { inQuote = false; diff --git a/loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java b/loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java index 173310591..5827f2e64 100644 --- a/loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java +++ b/loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java @@ -662,7 +662,7 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor { * Checks if the pattern looks like "com.foo.Bar" - an exact name */ private String looksLikeExactName(String typePattern) { - if (hasSpaceAnnotationPlus(typePattern, 0) || typePattern.indexOf("*") != -1) { + if (hasSpaceAnnotationPlus(typePattern, 0) || typePattern.contains("*")) { return null; } return typePattern.replace('$', '.'); diff --git a/loadtime/src/main/java/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java b/loadtime/src/main/java/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java index 6f5b58702..7f87e40c9 100644 --- a/loadtime/src/main/java/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java +++ b/loadtime/src/main/java/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java @@ -164,7 +164,7 @@ public class ConcreteAspectCodeGen { String parentAspectName = concreteAspect.extend; - if (parentAspectName.indexOf("<") != -1) { + if (parentAspectName.contains("<")) { // yikes, generic parent parent = world.resolve(UnresolvedType.forName(parentAspectName), true); if (parent.isMissing()) { @@ -741,7 +741,7 @@ public class ConcreteAspectCodeGen { return null; } String clazz = value.substring(0, value.length() - 6); - boolean qualified = clazz.indexOf(".") != -1; + boolean qualified = clazz.contains("."); if (!qualified) { // if not qualified, have to assume java.lang clazz = "java.lang." + clazz; diff --git a/loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingURLClassLoaderTest.java b/loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingURLClassLoaderTest.java index 406847eb2..5ae1d50e3 100644 --- a/loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingURLClassLoaderTest.java +++ b/loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingURLClassLoaderTest.java @@ -359,7 +359,7 @@ public class WeavingURLClassLoaderTest extends TestCase { } catch (Exception ex) { // Expecting: java.lang.NoClassDefFoundError: LTWAspect String m = ex.getMessage(); - if (-1 == m.indexOf("java.lang.NoClassDefFoundError")) { + if (!m.contains("java.lang.NoClassDefFoundError")) { fail("Expecting java.lang.NoClassDefFoundError but caught " + ex); } } @@ -426,7 +426,7 @@ public class WeavingURLClassLoaderTest extends TestCase { // expecting error String message = ex.getMessage(); // expecting error - seems to be wrapped wrong - if (-1 == message.indexOf("around advice")) { + if (!message.contains("around advice")) { failWithException(ex); } } catch (Error ex) { @@ -461,7 +461,7 @@ public class WeavingURLClassLoaderTest extends TestCase { invokeMain(clazz, new String[] {}); fail("Should reject bad aspect MissingFile"); } catch (AbortException ae) { - assertTrue("Unexpected cause: " + ae.getMessage(), ae.getMessage().indexOf("bad aspect library") != -1); + assertTrue("Unexpected cause: " + ae.getMessage(), ae.getMessage().contains("bad aspect library")); } } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/AjdtCommand.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/AjdtCommand.java index 25de41c2d..7fa4e9c36 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/AjdtCommand.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/AjdtCommand.java @@ -168,9 +168,9 @@ public class AjdtCommand implements ICommand { /** @return IMessage.WARNING unless message contains error or info */ protected static IMessage.Kind inferKind(String message) { // XXX dubious - if (-1 != message.indexOf("error")) { + if (message.contains("error")) { return IMessage.ERROR; - } else if (-1 != message.indexOf("info")) { + } else if (message.contains("info")) { return IMessage.INFO; } else { return IMessage.WARNING; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java index 70a610950..365f56940 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java @@ -139,7 +139,7 @@ public class PointcutDeclaration extends AjMethodDeclaration { public String getPointcutText() { String text = getPointcut().toString(); - if (text.indexOf("BindingTypePattern") == -1) + if (!text.contains("BindingTypePattern")) return text; // has been wrecked by resolution, try to reconstruct from tokens if (pointcutDesignator != null) { diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java index ec5a2a545..c42a503c6 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java @@ -325,25 +325,25 @@ public class AjProblemReporter extends ProblemReporter { String name = new String(binding.selector); if (name.startsWith("ajc$")) { long metaTagBits = annotation.resolvedType.getAnnotationTagBits(); // could be forward reference - if (name.indexOf("interField") != -1) { + if (name.contains("interField")) { if ((metaTagBits & TagBits.AnnotationForField) != 0) return; - } else if (name.indexOf("interConstructor") != -1) { + } else if (name.contains("interConstructor")) { if ((metaTagBits & TagBits.AnnotationForConstructor) != 0) return; - } else if (name.indexOf("interMethod") != -1) { + } else if (name.contains("interMethod")) { if ((metaTagBits & TagBits.AnnotationForMethod) != 0) return; - } else if (name.indexOf("declare_" + DeclareAnnotation.AT_TYPE + "_") != -1) { + } else if (name.contains("declare_" + DeclareAnnotation.AT_TYPE + "_")) { if ((metaTagBits & TagBits.AnnotationForAnnotationType) != 0 || (metaTagBits & TagBits.AnnotationForType) != 0) return; - } else if (name.indexOf("declare_" + DeclareAnnotation.AT_FIELD + "_") != -1) { + } else if (name.contains("declare_" + DeclareAnnotation.AT_FIELD + "_")) { if ((metaTagBits & TagBits.AnnotationForField) != 0) return; - } else if (name.indexOf("declare_" + DeclareAnnotation.AT_CONSTRUCTOR + "_") != -1) { + } else if (name.contains("declare_" + DeclareAnnotation.AT_CONSTRUCTOR + "_")) { if ((metaTagBits & TagBits.AnnotationForConstructor) != 0) return; - } else if (name.indexOf("declare_eow") != -1) { + } else if (name.contains("declare_eow")) { if ((metaTagBits & TagBits.AnnotationForField) != 0) return; } @@ -685,7 +685,7 @@ public class AjProblemReporter extends ProblemReporter { this.delegate = aProblem; // if this was a problem that came via the weaver, it will already have // pinpoint info, don't do it twice... - if (delegate.getMessage().indexOf("message issued...") == -1) { + if (!delegate.getMessage().contains("message issued...")) { this.message = delegate.getMessage() + "\n" + pinpoint; } else { this.message = delegate.getMessage(); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java index 219f2fd48..4cd844590 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java @@ -579,7 +579,7 @@ public class AjBuildConfig implements CompilerConfigurationChangeFlags { lintValue = AjCompilerOptions.ERROR; } else { // Possibly a name=value comma separated list of configurations - if (lintMode.indexOf("=")!=-1) { + if (lintMode.contains("=")) { this.lintMode = AJLINT_DEFAULT; lintOptionsMap = new HashMap<String,String>(); StringTokenizer tokenizer = new StringTokenizer(lintMode,","); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java index 98c115190..dfdcba12c 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java @@ -640,9 +640,9 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour } private boolean acceptResource(String resourceName, boolean fromFile) { - if ((resourceName.startsWith("CVS/")) || (resourceName.indexOf("/CVS/") != -1) || (resourceName.endsWith("/CVS")) + if ((resourceName.startsWith("CVS/")) || (resourceName.contains("/CVS/")) || (resourceName.endsWith("/CVS")) || (resourceName.endsWith(".class")) || (resourceName.startsWith(".svn/")) - || (resourceName.indexOf("/.svn/") != -1) || (resourceName.endsWith("/.svn")) || + || (resourceName.contains("/.svn/")) || (resourceName.endsWith("/.svn")) || // Do not copy manifests if either they are coming from a jar or we are writing to a jar (resourceName.toUpperCase().equals(MANIFEST_NAME) && (!fromFile || zos != null))) { return false; @@ -1382,7 +1382,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour } return null; // this is the "OK" return value! } - else if (p.isFile() && p.getName().indexOf("org.aspectj.runtime") != -1) { + else if (p.isFile() && p.getName().contains("org.aspectj.runtime")) { // likely to be a variant from the springsource bundle repo b272591 return null; } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java index 833ce2382..7e08c02a7 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java @@ -1429,7 +1429,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe if (compiledTypes != null) { for (char[] className : (Iterable<char[]>) compiledTypes.keySet()) { String typeName = new String(className).replace('/', '.'); - if (typeName.indexOf(BcelWeaver.SYNTHETIC_CLASS_POSTFIX) == -1) { + if (!typeName.contains(BcelWeaver.SYNTHETIC_CLASS_POSTFIX)) { ResolvedType rt = world.resolve(typeName); if (rt.isMissing()) { // This can happen in a case where another problem has occurred that prevented it being diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java index 77862dddf..776696aff 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java @@ -174,7 +174,7 @@ public class AsmElementFormatter { } else if (methodDeclaration instanceof InterTypeDeclaration) { InterTypeDeclaration itd = (InterTypeDeclaration) methodDeclaration; String fqname = itd.getOnType().toString(); - if (fqname.indexOf(".") != -1) { + if (fqname.contains(".")) { // TODO the string handling round here is embarrassing node.addFullyQualifiedName(fqname + "." + new String(itd.getDeclaredSelector())); fqname = fqname.substring(fqname.lastIndexOf(".") + 1); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java index 8a3acaec8..795176c61 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java @@ -161,7 +161,7 @@ public class EclipseAdapterUtils { declared = true; extraDetails = extraDetails.substring(0, extraDetails.length() - "[deow=true]".length()); } - if (extraDetails != null && extraDetails.indexOf("[Xlint:") != -1) { + if (extraDetails != null && extraDetails.contains("[Xlint:")) { isLintMessage = true; lintkey = extraDetails.substring(extraDetails.indexOf("[Xlint:")); lintkey = lintkey.substring("[Xlint:".length()); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java index 6f7a1dd7c..88558fed0 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java @@ -570,7 +570,7 @@ public class Main { File file = loc.getSourceFile(); if (null != file) { String name = file.getName(); - if (!toString || (-1 == text.indexOf(name))) { + if (!toString || (!text.contains(name))) { sb.append(FileUtil.getBestPath(file)); if (loc.getLine() > 0) { sb.append(":" + loc.getLine()); diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/AjdtCommandTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/AjdtCommandTestCase.java index 9c504a300..57c2f8e4c 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/AjdtCommandTestCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/AjdtCommandTestCase.java @@ -122,7 +122,7 @@ public class AjdtCommandTestCase extends TestCase { public void testIncrementalOption() throws InvalidInputException { AjdtCommand.genBuildConfig(new String[] { "-incremental" }, counter); - assertTrue("didn't specify source root", outputWriter.getContents().indexOf("specify a source root") != -1); + assertTrue("didn't specify source root", outputWriter.getContents().contains("specify a source root")); outputWriter.flushBuffer(); AjdtCommand.genBuildConfig(new String[] { "-incremental", "-sourceroots", Constants.TESTDATA_PATH + "/src1" }, counter); @@ -132,8 +132,7 @@ public class AjdtCommandTestCase extends TestCase { outputWriter.flushBuffer(); AjdtCommand.genBuildConfig(new String[] { "-incremental", "testdata/src1/Hello.java" }, counter); - assertTrue("specified a file", outputWriter.getContents().indexOf( - "incremental mode only handles source files using -sourceroots") != -1); + assertTrue("specified a file", outputWriter.getContents().contains("incremental mode only handles source files using -sourceroots")); } public void testBadOptionAndUsagePrinting() throws InvalidInputException { @@ -143,7 +142,7 @@ public class AjdtCommandTestCase extends TestCase { } // usage printed by caller to genBuildConfig now... assertTrue(outputWriter.getContents() + " contains? " + "Usage", - outputWriter.getContents().indexOf("-mubleBadOption") != -1); + outputWriter.getContents().contains("-mubleBadOption")); } @@ -166,7 +165,7 @@ public class AjdtCommandTestCase extends TestCase { } String text = byteArrayOut.toString(); - assertTrue(text + " contains? " + "Usage", text.indexOf("Usage") != -1); + assertTrue(text + " contains? " + "Usage", text.contains("Usage")); } public void q() throws InvalidInputException { @@ -194,14 +193,13 @@ public class AjdtCommandTestCase extends TestCase { String text = byteArrayOut.toString(); // String text2 = byteArrayErr.toString(); - assertTrue("version output does not include 'AspectJ Compiler', output was:\n'" + text + "'", text - .indexOf("AspectJ Compiler") != -1); + assertTrue("version output does not include 'AspectJ Compiler', output was:\n'" + text + "'", text.contains("AspectJ Compiler")); } public void testNonExistingLstFile() { AjdtCommand.genBuildConfig(new String[] { "@mumbleDoesNotExist" }, counter); - assertTrue(outputWriter.getContents(), outputWriter.getContents().indexOf("file does not exist") != -1); + assertTrue(outputWriter.getContents(), outputWriter.getContents().contains("file does not exist")); } protected void setUp() throws Exception { diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java index 1f936661e..c4439c9f7 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java @@ -99,8 +99,8 @@ public class BuildArgParserTestCase extends TestCase { boolean jar2Found = false; for (Object o : cp) { String element = (String) o; - if (element.indexOf("1.jar") != -1) jar1Found = true; - if (element.indexOf("2.jar") != -1) jar2Found = true; + if (element.contains("1.jar")) jar1Found = true; + if (element.contains("2.jar")) jar2Found = true; } assertTrue( config.getClasspath().toString(), @@ -312,7 +312,7 @@ public class BuildArgParserTestCase extends TestCase { "-bootclasspath", PATH }, messageWriter); assertTrue("Should find '" + PATH + "' contained in the first entry of '" + config.getBootclasspath().toString(), - config.getBootclasspath().get(0).indexOf(PATH) != -1); + config.getBootclasspath().get(0).contains(PATH)); config = genBuildConfig(new String[] { }, @@ -375,8 +375,8 @@ public class BuildArgParserTestCase extends TestCase { boolean jar2Found = false; for (Object o : cp) { String element = (String) o; - if (element.indexOf("1.jar") != -1) jar1Found = true; - if (element.indexOf("2.jar") != -1) jar2Found = true; + if (element.contains("1.jar")) jar1Found = true; + if (element.contains("2.jar")) jar2Found = true; } assertTrue( config.getClasspath().toString(), diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/DumpTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/DumpTestCase.java index dad021a7c..4f40922d6 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/DumpTestCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/DumpTestCase.java @@ -123,7 +123,7 @@ public class DumpTestCase extends TestCase { String record; while ((null != (record = reader.readLine())) && (result == false)) { if (record.startsWith("----")) currentHeading = record; - else if ((record.indexOf(contents) != -1) && currentHeading.indexOf(heading) != -1) result = true; + else if ((record.contains(contents)) && currentHeading.contains(heading)) result = true; } reader.close(); } diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java index 6887d79fe..1dc118283 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java @@ -43,7 +43,7 @@ public class AjBuildManagerTest extends TestCase { final int numMessages = handler.numMessages(IMessage.WARNING, true); if (1 == numMessages) { // permit aspectjrt.jar warning IMessage m = handler.getMessages(IMessage.WARNING, true)[0]; - if (!(m.isWarning() && (-1 != m.getMessage().indexOf("aspectjrt.jar")))) { + if (!(m.isWarning() && (m.getMessage().contains("aspectjrt.jar")))) { assertTrue(handler.toString(), false); } } else if (0 != numMessages) { diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java index a9442de73..7aa97ad1e 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java @@ -224,7 +224,7 @@ public abstract class AjcTestCase extends TestCase { } } if (text != null) { - if (message.getMessage().indexOf(text) == -1) { + if (!message.getMessage().contains(text)) { return false; } } @@ -891,7 +891,7 @@ public abstract class AjcTestCase extends TestCase { private String substituteSandbox(String path) { // the longhand form of the non 1.3 API: path.replace("$sandbox", ajc.getSandboxDirectory().getAbsolutePath()); - while (path.indexOf("$sandbox") != -1) { + while (path.contains("$sandbox")) { int pos = path.indexOf("$sandbox"); String firstbit = path.substring(0, pos); String endbit = path.substring(pos + 8); @@ -918,7 +918,7 @@ public abstract class AjcTestCase extends TestCase { cpIndex = i; args[i + 1] = substituteSandbox(args[i + 1]); String next = args[i + 1]; - hasruntime = ((null != next) && (-1 != next.indexOf("aspectjrt.jar"))); + hasruntime = ((null != next) && (next.contains("aspectjrt.jar"))); } else if ("-p".equals(args[i]) || "--module-path".equals(args[i])) { args[i + 1] = substituteSandbox(args[i + 1]); } @@ -941,7 +941,7 @@ public abstract class AjcTestCase extends TestCase { } boolean needsJRTFS = LangUtil.is19VMOrGreater(); if (needsJRTFS) { - if (args[cpIndex].indexOf(LangUtil.JRT_FS) == -1) { + if (!args[cpIndex].contains(LangUtil.JRT_FS)) { String jrtfsPath = LangUtil.getJrtFsFilePath(); args[cpIndex] = jrtfsPath + File.pathSeparator + args[cpIndex]; } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/NameMangler.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/NameMangler.java index f9162684a..a2b2f5d1c 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/NameMangler.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/NameMangler.java @@ -72,7 +72,7 @@ public class NameMangler { return false; // body of an itd-m } return true; - } else if (methodName.indexOf("_aroundBody") != -1) { + } else if (methodName.contains("_aroundBody")) { return true; } // these aren't the droids you're looking for...move along...... pr148727 diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedMemberImpl.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedMemberImpl.java index 90fd3ece3..bb609f104 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedMemberImpl.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedMemberImpl.java @@ -755,7 +755,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Reso // check going bang in this case we check for $ (crap...) - we can't check the outer because the declaring type // is considered unresolved... if (// isParameterized && <-- might need this bit... - !getDeclaringType().isGenericType() && getDeclaringType().getName().indexOf("$") == -1) { + !getDeclaringType().isGenericType() && !getDeclaringType().getName().contains("$")) { throw new IllegalStateException("Can't ask to parameterize a member of non-generic type: " + getDeclaringType() + " kind(" + getDeclaringType().typeKind + ")"); } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedType.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedType.java index a5a5eea5d..8e48b02d4 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedType.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedType.java @@ -975,7 +975,7 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl } public boolean isSynthetic() { - return signature.indexOf("$ajc") != -1; + return signature.contains("$ajc"); } public final boolean isFinal() { diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ShadowMunger.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ShadowMunger.java index a0e49becc..809cc58de 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ShadowMunger.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ShadowMunger.java @@ -213,7 +213,7 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH // grab javaclass... but it doesnt know the originating file // } } - if (binaryPath.indexOf("!") == -1) { + if (!binaryPath.contains("!")) { File f = getDeclaringType().getSourceLocation().getSourceFile(); // Replace the source file suffix with .class int i = f.getPath().lastIndexOf('.'); diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/UnresolvedType.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/UnresolvedType.java index 155bc0955..19f1ca5ce 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/UnresolvedType.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/UnresolvedType.java @@ -380,7 +380,7 @@ public class UnresolvedType implements Traceable, TypeVariableDeclaringElement { * @return a type object represnting that JVM bytecode signature. */ public static UnresolvedType forSignature(String signature) { - assert !(signature.startsWith("L") && signature.indexOf("<") != -1); + assert !(signature.startsWith("L") && signature.contains("<")); switch (signature.charAt(0)) { case 'B': return UnresolvedType.BYTE; @@ -753,7 +753,7 @@ public class UnresolvedType implements Traceable, TypeVariableDeclaringElement { return name.replace('.','/'); } - if (name.indexOf("<") == -1) { + if (!name.contains("<")) { // not parameterized return new StringBuilder("L").append(name.replace('.', '/')).append(';').toString(); } else { @@ -903,7 +903,7 @@ public class UnresolvedType implements Traceable, TypeVariableDeclaringElement { public String getClassName() { if (className == null) { String name = getName(); - if (name.indexOf("<") != -1) { + if (name.contains("<")) { name = name.substring(0, name.indexOf("<")); } int index = name.lastIndexOf('.'); diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Utils.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Utils.java index 501ffa418..2ca0173be 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Utils.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Utils.java @@ -32,7 +32,7 @@ public class Utils { // 2. there are values specified (i.e. @SuppressAjWarnings("A") or @SuppressAjWarnings({"A","B"}) String value = ann.getStringFormOfValue("value"); // Slightly lazy, just doing a string indexof - if (value == null || value.indexOf(lintkey) != -1) { + if (value == null || value.contains(lintkey)) { return true; } } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/World.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/World.java index 4e625d841..3b69a5d73 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/World.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/World.java @@ -991,10 +991,10 @@ public abstract class World implements Dump.INode { if (jps == null) { return; } - if (jps.indexOf("arrayconstruction") != -1) { + if (jps.contains("arrayconstruction")) { optionalJoinpoint_ArrayConstruction = true; } - if (jps.indexOf("synchronization") != -1) { + if (jps.contains("synchronization")) { optionalJoinpoint_Synchronization = true; } } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java index 35f2dc674..531b3d09f 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java @@ -212,7 +212,7 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern { break; } else { if (t.isAnnotation()) { - if (v.indexOf("(") != -1) { + if (v.contains("(")) { throw new RuntimeException( "Compiler limitation: annotation values can only currently be marker annotations (no values): " + v); @@ -297,7 +297,7 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern { if (typePattern instanceof WildTypePattern && (annotationValues == null || annotationValues.isEmpty())) { WildTypePattern wildTypePattern = (WildTypePattern) typePattern; String fullyQualifiedName = wildTypePattern.maybeGetCleanName(); - if (fullyQualifiedName != null && fullyQualifiedName.indexOf(".") != -1) { + if (fullyQualifiedName != null && fullyQualifiedName.contains(".")) { ResolvedType resolvedType = world.resolve(UnresolvedType.forName(fullyQualifiedName)); if (resolvedType != null && !resolvedType.isMissing()) { typePattern = new ExactTypePattern(resolvedType, false, false); diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildTypePattern.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildTypePattern.java index 3dad2ce6b..39d4a387b 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildTypePattern.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildTypePattern.java @@ -1164,7 +1164,7 @@ public class WildTypePattern extends TypePattern { ret.add(possibleMatch); continue; } - if (possibleMatch.indexOf("$") != -1) { + if (possibleMatch.contains("$")) { names = splitNames(possibleMatch, false); // ??? not most efficient if (namePatterns[0].matches(names[names.length - 1])) { ret.add(possibleMatch); diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/BindingTestCase.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/BindingTestCase.java index 7303191dd..132512e5a 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/BindingTestCase.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/BindingTestCase.java @@ -102,7 +102,7 @@ public class BindingTestCase extends PatternsTestCase { // System.out.println("expected exception: " + re); return; } catch (Throwable t) { - assertTrue(prefix, t.getMessage().indexOf(prefix) != -1); + assertTrue(prefix, t.getMessage().contains(prefix)); return; } assertTrue("should have failed", false); diff --git a/runtime/src/main/java/org/aspectj/internal/lang/reflect/StringToType.java b/runtime/src/main/java/org/aspectj/internal/lang/reflect/StringToType.java index c658bbbd0..b953fa1ce 100644 --- a/runtime/src/main/java/org/aspectj/internal/lang/reflect/StringToType.java +++ b/runtime/src/main/java/org/aspectj/internal/lang/reflect/StringToType.java @@ -40,7 +40,7 @@ public class StringToType { public static Type stringToType(String typeName, Class classScope) throws ClassNotFoundException { try { - if (typeName.indexOf("<") == -1) { + if (!typeName.contains("<")) { return AjTypeSystem.getAjType(Class.forName(typeName,false,classScope.getClassLoader())); } else { return makeParameterizedType(typeName,classScope); diff --git a/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeTest.java b/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeTest.java index 542de36d5..9ddb5c0dc 100644 --- a/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeTest.java +++ b/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeTest.java @@ -139,8 +139,8 @@ public class AjTypeTest extends TestCase { assertEquals(2,fooTypes.length); // Alex -> Adrian: looks like you can not make assumption on the ordering String s = " " + fooTypes[0].getName() + " " + fooTypes[1].getName(); - assertTrue(s.indexOf(" org.aspectj.internal.lang.reflect.Foo$Z") >= 0); - assertTrue(s.indexOf(" org.aspectj.internal.lang.reflect.Foo$XX") >= 0); + assertTrue(s.contains(" org.aspectj.internal.lang.reflect.Foo$Z")); + assertTrue(s.contains(" org.aspectj.internal.lang.reflect.Foo$XX")); } public void testGetConstructor() throws Exception { diff --git a/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeWithAspectsTest.java b/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeWithAspectsTest.java index a2f33f91b..5431a7457 100644 --- a/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeWithAspectsTest.java +++ b/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeWithAspectsTest.java @@ -149,7 +149,7 @@ public class AjTypeWithAspectsTest extends TestCase { for (Method m : ms) { match = match + "--" + m.getName(); } - assertTrue(match.indexOf("aMethod") >=0); + assertTrue(match.contains("aMethod")); } public void testGetDeclaredPointcut() throws Exception { @@ -200,8 +200,8 @@ public class AjTypeWithAspectsTest extends TestCase { assertEquals(2,pcs.length); // AV was corrupted, cannot rely on ordering String match = "simpleAspectMethodExecution--simpleAspectCall"; - assertTrue(match.indexOf(pcs[0].getName()) >= 0); - assertTrue(match.indexOf(pcs[1].getName()) >= 0); + assertTrue(match.contains(pcs[0].getName())); + assertTrue(match.contains(pcs[1].getName())); } public void testGetPointcuts() { diff --git a/runtime/src/test/java/org/aspectj/runtime/RuntimeTest.java b/runtime/src/test/java/org/aspectj/runtime/RuntimeTest.java index a908a8ae0..2eb92e97b 100644 --- a/runtime/src/test/java/org/aspectj/runtime/RuntimeTest.java +++ b/runtime/src/test/java/org/aspectj/runtime/RuntimeTest.java @@ -69,9 +69,9 @@ public class RuntimeTest extends TestCase { static void checkSoftExceptionString(String s) { - assertTrue(-1 != s.indexOf("SoftException")); - assertTrue(-1 != s.indexOf("Caused by: java.lang.Error")); - assertTrue(-1 != s.indexOf("xyz")); - assertTrue(-1 != s.indexOf("testSoftExceptionPrintStackTrace")); + assertTrue(s.contains("SoftException")); + assertTrue(s.contains("Caused by: java.lang.Error")); + assertTrue(s.contains("xyz")); + assertTrue(s.contains("testSoftExceptionPrintStackTrace")); } } 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 9aea9ae6d..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 @@ -498,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/AjcTask.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java index c68a1eb59..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; } } @@ -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(); 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 b1f7c7b4f..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()); } } @@ -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) { @@ -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)); diff --git a/testing-client/src/test/java/org/aspectj/testing/TesterTest.java b/testing-client/src/test/java/org/aspectj/testing/TesterTest.java index 544e46e2f..5533739a3 100644 --- a/testing-client/src/test/java/org/aspectj/testing/TesterTest.java +++ b/testing-client/src/test/java/org/aspectj/testing/TesterTest.java @@ -190,7 +190,7 @@ public class TesterTest extends TestCase { boolean gotItem(List<IMessage> list, String substring) { for (IMessage element: list) { String s = element.getMessage(); - if ((null != s) && (-1 != s.indexOf(substring))) { + if ((null != s) && (s.contains(substring))) { return true; } } diff --git a/testing-drivers/src/test/java/org/aspectj/testing/drivers/Harness.java b/testing-drivers/src/test/java/org/aspectj/testing/drivers/Harness.java index e932a027d..6c0a84fe9 100644 --- a/testing-drivers/src/test/java/org/aspectj/testing/drivers/Harness.java +++ b/testing-drivers/src/test/java/org/aspectj/testing/drivers/Harness.java @@ -1056,7 +1056,7 @@ class SubstringRunner implements StringRunner { input = input.toLowerCase(); } for (String substring : substrings) { - if (-1 != input.indexOf(substring)) { + if (input.contains(substring)) { return true; } } @@ -1150,7 +1150,7 @@ class MessageRunValidator implements IRunValidator { continue; // hmm } String text = message.getMessage(); - if ((null != text) && (-1 != text.indexOf(sought))) { + if ((null != text) && (text.contains(sought))) { return true; } } diff --git a/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java b/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java index 6be6cc61e..76b7a181a 100644 --- a/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java +++ b/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java @@ -477,7 +477,7 @@ public final class TestUtil { String[] paths = FileUtil.listFiles(expectedBaseDir); boolean result = true; for (String path : paths) { - if (-1 != path.indexOf("CVS")) { + if (path.contains("CVS")) { continue; } if (!sameFiles(handler, expectedBaseDir, actualBaseDir, path) && result) { diff --git a/testing-util/src/test/java/org/aspectj/testingutil/TestUtilTest.java b/testing-util/src/test/java/org/aspectj/testingutil/TestUtilTest.java index 0807bd2a3..1427ccc8a 100644 --- a/testing-util/src/test/java/org/aspectj/testingutil/TestUtilTest.java +++ b/testing-util/src/test/java/org/aspectj/testingutil/TestUtilTest.java @@ -116,7 +116,7 @@ public class TestUtilTest extends TestCase { } catch (IllegalArgumentException e) { assertTrue("exception: " + errors[i], fail); String m = e.getMessage(); - if (-1 == m.indexOf(errors[i])) { + if (!m.contains(errors[i])) { fail(errors[i] + " not in " + m); } } diff --git a/testing/src/test/java/org/aspectj/testing/AntSpec.java b/testing/src/test/java/org/aspectj/testing/AntSpec.java index 64ff4f364..b5f23ca74 100644 --- a/testing/src/test/java/org/aspectj/testing/AntSpec.java +++ b/testing/src/test/java/org/aspectj/testing/AntSpec.java @@ -208,11 +208,11 @@ public class AntSpec implements ITestStep { if (m_stdErrSpec != null) { String stderr2 = stderr.toString(); // Working around this ridiculous message that still comes out of Java7 builds: - if (stderr2.indexOf("Class JavaLaunchHelper is implemented in both")!=-1 && stderr2.indexOf('\n')!=-1) { + if (stderr2.contains("Class JavaLaunchHelper is implemented in both") && stderr2.indexOf('\n')!=-1) { stderr2 = stderr2.replaceAll("objc\\[[0-9]*\\]: Class JavaLaunchHelper is implemented in both [^\n]*\n",""); } // JDK 11 is complaining about illegal reflective calls - temporary measure ignore these - does that get all tests passing and this is the last problem? - if (stderr2.indexOf("WARNING: Illegal reflective access using Lookup on org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor") != -1) { + if (stderr2.contains("WARNING: Illegal reflective access using Lookup on org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor")) { // WARNING: An illegal reflective access operation has occurred // WARNING: Illegal reflective access using Lookup on org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor (file:/Users/aclement/gits/org.aspectj/loadtime/bin/) to class java.lang.ClassLoader // WARNING: Please consider reporting this to the maintainers of org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor diff --git a/testing/src/test/java/org/aspectj/testing/CompileSpec.java b/testing/src/test/java/org/aspectj/testing/CompileSpec.java index 97cba2bc5..e950ee1ba 100644 --- a/testing/src/test/java/org/aspectj/testing/CompileSpec.java +++ b/testing/src/test/java/org/aspectj/testing/CompileSpec.java @@ -68,7 +68,7 @@ public class CompileSpec implements ITestStep { public void setTest(AjcTest t) { this.myTest = t; - if (options != null && (options.indexOf("-1.5") != -1)) { + if (options != null && (options.contains("-1.5"))) { myTest.setVm("1.5"); } } diff --git a/testing/src/test/java/org/aspectj/testing/OutputSpec.java b/testing/src/test/java/org/aspectj/testing/OutputSpec.java index 80e928bc9..d3b064907 100644 --- a/testing/src/test/java/org/aspectj/testing/OutputSpec.java +++ b/testing/src/test/java/org/aspectj/testing/OutputSpec.java @@ -65,7 +65,7 @@ public class OutputSpec { lineNo++; String outputLine = strTok.nextToken().trim(); /* Avoid trying to match on ajSandbox source names that appear in messages */ - if (outputLine.indexOf(line) == -1) { + if (!outputLine.contains(line)) { matches = false; break; } @@ -88,7 +88,7 @@ public class OutputSpec { found.addAll(outputFound); for (String lineFound : outputFound) { for (String lineExpected : expectedOutputLines) { - if (lineFound.indexOf(lineExpected)!= -1) { + if (lineFound.contains(lineExpected)) { found.remove(lineFound); expected.remove(lineExpected); continue; diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcTest.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcTest.java index cd07733ea..64588ba93 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcTest.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcTest.java @@ -417,7 +417,7 @@ public class AjcTest extends RunSpecIterator { !gotHit && iter.hasNext(); ) { String substring = (String) iter.next(); - if (-1 != this.description.indexOf(substring)) { + if (this.description.contains(substring)) { gotHit = true; } } diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunSpecTest.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunSpecTest.java index 12b91679a..abac95dfe 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunSpecTest.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunSpecTest.java @@ -141,7 +141,7 @@ public class CompilerRunSpecTest extends TestCase { } } else { String messages = "" + handler; - if (-1 == messages.indexOf(contains)) { + if (!messages.contains(contains)) { assertTrue(messages, false); } } @@ -398,7 +398,7 @@ public class CompilerRunSpecTest extends TestCase { } if (null != resultContains) { String result = "" + spec.testSetup.commandOptions; - if (-1 == result.indexOf(resultContains)) { + if (!result.contains(resultContains)) { assertTrue( "expected " + resultContains + " got " + result, false); @@ -411,7 +411,7 @@ public class CompilerRunSpecTest extends TestCase { assertTrue("expected " + messagesContain, false); } else { String messages = handler.toString(); - if (-1 == messages.indexOf(messagesContain)) { + if (!messages.contains(messagesContain)) { assertTrue( "expected " + messagesContain diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunTest.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunTest.java index c5f68d03a..9de7642bb 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunTest.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunTest.java @@ -91,7 +91,7 @@ public class CompilerRunTest extends TestCase { String command = (String) dummyReports.remove(0); assertTrue(0 == dummyReports.size()); if ((null == command) - || (-1 == command.indexOf(expectedInCommand))) { + || (!command.contains(expectedInCommand))) { assertTrue("expected " + expectedInCommand + "got " diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/FlatSuiteReader.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/FlatSuiteReader.java index b3249feeb..16d1d6d19 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/FlatSuiteReader.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/FlatSuiteReader.java @@ -162,7 +162,7 @@ public class FlatSuiteReader implements SFileReader.Maker { // so compile succeeds but run not attempted //result.errors = Main.RA_ErrorLine; // result.runOptions = Main.RA_String; - } else if (isNumber(first) || (-1 != first.indexOf(":"))) { + } else if (isNumber(first) || (first.contains(":"))) { exp.addAll(makeMessages(IMessage.ERROR, words, 0, lastFile)); } else { String[] args = new String[words.length - 1]; @@ -275,13 +275,13 @@ public class FlatSuiteReader implements SFileReader.Maker { } input = description.toString(); String error = null; - if (-1 != input.indexOf("&")) { + if (input.contains("&")) { error = "char &"; - } else if (-1 != input.indexOf("<")) { + } else if (input.contains("<")) { error = "char <"; - } else if (-1 != input.indexOf(">")) { + } else if (input.contains(">")) { error = "char >"; - } else if (-1 != input.indexOf("\"")) { + } else if (input.contains("\"")) { error = "char \""; } if (null != error) { diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java index 7aa817f05..db7428816 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java @@ -434,7 +434,7 @@ public class JavaRun implements IAjcRun { protected boolean expectedException(Throwable thrown) { if (null != spec.expectedException) { String cname = thrown.getClass().getName(); - if (-1 != cname.indexOf(spec.expectedException)) { + if (cname.contains(spec.expectedException)) { return true; // caller sets value for returns normally } } @@ -443,7 +443,7 @@ public class JavaRun implements IAjcRun { protected boolean expectedException(ByteArrayOutputStream bout) { return ((null != spec.expectedException) - && (-1 != bout.toString().indexOf(spec.expectedException))); + && (bout.toString().contains(spec.expectedException))); } /** diff --git a/testing/src/test/java/org/aspectj/testing/util/BridgeUtil.java b/testing/src/test/java/org/aspectj/testing/util/BridgeUtil.java index a6e4c7cab..7013160dc 100644 --- a/testing/src/test/java/org/aspectj/testing/util/BridgeUtil.java +++ b/testing/src/test/java/org/aspectj/testing/util/BridgeUtil.java @@ -134,8 +134,8 @@ public class BridgeUtil { || LangUtil.isEmpty(rhs_s)) { return 0; } - if ((-1 != lhs_s.indexOf(rhs_s)) - || (-1 != rhs_s.indexOf(lhs_s))) { + if ((lhs_s.contains(rhs_s)) + || (rhs_s.contains(lhs_s))) { return 0; } return String.CASE_INSENSITIVE_ORDER.compare(lhs_s, rhs_s); diff --git a/testing/src/test/java/org/aspectj/testing/util/Diffs.java b/testing/src/test/java/org/aspectj/testing/util/Diffs.java index fee19a3e1..f42197873 100644 --- a/testing/src/test/java/org/aspectj/testing/util/Diffs.java +++ b/testing/src/test/java/org/aspectj/testing/util/Diffs.java @@ -438,7 +438,7 @@ public class Diffs { } else if (null == actual) { return false; // expected something } else { - return (-1 != actual.indexOf(expected)); + return (actual.contains(expected)); } } diff --git a/testing/src/test/java/org/aspectj/testing/util/FileUtil.java b/testing/src/test/java/org/aspectj/testing/util/FileUtil.java index a47f694e4..ab780cd29 100644 --- a/testing/src/test/java/org/aspectj/testing/util/FileUtil.java +++ b/testing/src/test/java/org/aspectj/testing/util/FileUtil.java @@ -169,7 +169,7 @@ public class FileUtil { String exp = (String) o; if (path.startsWith(exp)) { String suffix = path.substring(exp.length()); - if (-1 == suffix.indexOf("/")) { // normalized... + if (!suffix.contains("/")) { // normalized... expected.remove(path); // found - do not add to unexpected return false; diff --git a/testing/src/test/java/org/aspectj/testing/util/LangUtil.java b/testing/src/test/java/org/aspectj/testing/util/LangUtil.java index e78ec84c8..ddf3a832a 100644 --- a/testing/src/test/java/org/aspectj/testing/util/LangUtil.java +++ b/testing/src/test/java/org/aspectj/testing/util/LangUtil.java @@ -68,9 +68,9 @@ public class LangUtil { ps = ";"; String cp = System.getProperty("java.class.path"); if (null != cp) { - if (-1 != cp.indexOf(";")) { + if (cp.contains(";")) { ps = ";"; - } else if (-1 != cp.indexOf(":")) { + } else if (cp.contains(":")) { ps = ":"; } // else warn? @@ -105,7 +105,7 @@ public class LangUtil { public static void escape(String input, String target, String escape, StringBuffer sink) { if ((null == sink) || isEmpty(input) || isEmpty(target) || isEmpty(escape)) { return; - } else if (-1 == input.indexOf(target)) { // avoid StringTokenizer construction + } else if (!input.contains(target)) { // avoid StringTokenizer construction sink.append(input); return; } @@ -377,7 +377,7 @@ public class LangUtil { if (isEmpty(input)) { return result; } - if ((!haveDelim) || (-1 == input.indexOf(delim))) { + if ((!haveDelim) || (!input.contains(delim))) { result.add(input); return result; } @@ -482,7 +482,7 @@ public class LangUtil { StringBuffer sb = new StringBuffer(); sb.append(SPLIT_START); for (int i = 0; i < input.length; i++) { - if (-1 != input[i].indexOf(SPLIT_DELIM)) { + if (input[i].contains(SPLIT_DELIM)) { if (null != errs) { errs.append("\nLangUtil.unsplit(..) - item " + i + ": \"" + input[i] + " contains \"" + SPLIT_DELIM + "\""); diff --git a/testing/src/test/java/org/aspectj/testing/util/LinkCheck.java b/testing/src/test/java/org/aspectj/testing/util/LinkCheck.java index 380766a3b..fd1edaf6f 100644 --- a/testing/src/test/java/org/aspectj/testing/util/LinkCheck.java +++ b/testing/src/test/java/org/aspectj/testing/util/LinkCheck.java @@ -414,8 +414,8 @@ public class LinkCheck { // only info if redirect from http to https String m = e.getMessage(); if ((m != null) - && (-1 != m.indexOf("protocol")) - && (-1 != m.indexOf("https")) + && (m.contains("protocol")) + && (m.contains("https")) && "http".equals(link.url.getProtocol())) { info("httpsRedirect", link); return; diff --git a/testing/src/test/java/org/aspectj/testing/util/ValidFileFilter.java b/testing/src/test/java/org/aspectj/testing/util/ValidFileFilter.java index 8d069af0f..db0e12f5a 100644 --- a/testing/src/test/java/org/aspectj/testing/util/ValidFileFilter.java +++ b/testing/src/test/java/org/aspectj/testing/util/ValidFileFilter.java @@ -98,7 +98,7 @@ public class ValidFileFilter implements FileFilter { if ((null != prefix) && (!(path.startsWith(prefix)))) { return false; } - if ((null != substring) && (-1 == path.indexOf(substring))) { + if ((null != substring) && (!path.contains(substring))) { return false; } if ((null != suffix) && (!(path.endsWith(suffix)))) { diff --git a/testing/src/test/java/org/aspectj/testing/util/options/OptionChecker.java b/testing/src/test/java/org/aspectj/testing/util/options/OptionChecker.java index 87748f0b1..79d1ff286 100644 --- a/testing/src/test/java/org/aspectj/testing/util/options/OptionChecker.java +++ b/testing/src/test/java/org/aspectj/testing/util/options/OptionChecker.java @@ -104,7 +104,7 @@ public class OptionChecker { String m = e.getFullMessage(); boolean ok = (null != expectedInExceptionMessage) - && (-1 != m.indexOf(expectedInExceptionMessage)); + && (m.contains(expectedInExceptionMessage)); if (!ok) { e.printStackTrace(System.err); if (null != expectedInExceptionMessage) { @@ -144,7 +144,7 @@ public class OptionChecker { } } else { if ((null == expectedIn) - || (-1 == expectedIn.indexOf(expected))) { + || (!expectedIn.contains(expected))) { assertionFailed( "expected \"" + expected diff --git a/testing/src/test/java/org/aspectj/testing/xml/XMLWriter.java b/testing/src/test/java/org/aspectj/testing/xml/XMLWriter.java index eaa42326e..7a8b176b7 100644 --- a/testing/src/test/java/org/aspectj/testing/xml/XMLWriter.java +++ b/testing/src/test/java/org/aspectj/testing/xml/XMLWriter.java @@ -132,7 +132,7 @@ public class XMLWriter { printed = true; } String s = o.toString(); - if (-1 != s.indexOf(",")) { + if (s.contains(",")) { throw new IllegalArgumentException("comma in " + s); } sb.append(s); diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc121/Ajc121Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc121/Ajc121Tests.java index 000a72010..8bc4ad814 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc121/Ajc121Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc121/Ajc121Tests.java @@ -88,17 +88,17 @@ public class Ajc121Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void test016_ByteConversionInstructions() { runTest("RuntimeException thrown: Could not find instruction: org.apache.bcel.generic.B2I"); String output = getLastRunResult().getStdErr(); - assertTrue("Expected to find [b2] in this output but didn't:"+output,output.indexOf("[b2]")!=-1); - assertTrue("Expected to find [b127] in this output but didn't:"+output,output.indexOf("[b127]")!=-1); - assertTrue("Expected to find [b0] in this output but didn't:"+output,output.indexOf("[b0]")!=-1); + assertTrue("Expected to find [b2] in this output but didn't:"+output, output.contains("[b2]")); + assertTrue("Expected to find [b127] in this output but didn't:"+output, output.contains("[b127]")); + assertTrue("Expected to find [b0] in this output but didn't:"+output, output.contains("[b0]")); - assertTrue("Expected to find [c65] in this output but didn't:"+output,output.indexOf("[c65]")!=-1); - assertTrue("Expected to find [c66] in this output but didn't:"+output,output.indexOf("[c66]")!=-1); - assertTrue("Expected to find [c67] in this output but didn't:"+output,output.indexOf("[c67]")!=-1); + assertTrue("Expected to find [c65] in this output but didn't:"+output, output.contains("[c65]")); + assertTrue("Expected to find [c66] in this output but didn't:"+output, output.contains("[c66]")); + assertTrue("Expected to find [c67] in this output but didn't:"+output, output.contains("[c67]")); - assertTrue("Expected to find [s1] in this output but didn't:"+output,output.indexOf("[s1]")!=-1); - assertTrue("Expected to find [s32767] in this output but didn't:"+output,output.indexOf("[s32767]")!=-1); - assertTrue("Expected to find [b0] in this output but didn't:"+output,output.indexOf("[b0]")!=-1); + assertTrue("Expected to find [s1] in this output but didn't:"+output, output.contains("[s1]")); + assertTrue("Expected to find [s32767] in this output but didn't:"+output, output.contains("[s32767]")); + assertTrue("Expected to find [b0] in this output but didn't:"+output, output.contains("[b0]")); } public void test017_PrivateMethodCallsInAroundAdvice() { @@ -229,7 +229,7 @@ public class Ajc121Tests extends org.aspectj.testing.XMLBasedAjcTestCase { runTest("proper handling of ExceptionInIntializer inside clinit in presence of after throwing advice"); String s = getLastRunResult().getStdErr(); assertTrue("Output should contain java.lang.ExceptionInInitializerError but is '"+s+"'", - s.indexOf("java.lang.ExceptionInInitializerError")!=-1); + s.contains("java.lang.ExceptionInInitializerError")); // No getCause on 1.3 JVMs // assertTrue("Output should contain 'CAUSE=org.aspectj.lang.NoAspectBoundException' but is '"+s+"'", // s.indexOf("CAUSE=org.aspectj.lang.NoAspectBoundException")!=-1); diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/Ajc150Tests.java index c105e881d..8dcb8c34d 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -412,7 +412,7 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { AsmManager.dumptree(pw, AsmManager.lastActiveStructureModel.getHierarchy().getRoot(), 0); pw.flush(); String tree = baos.toString(); - assertTrue("Expected 'Red [enumvalue]' somewhere in here:" + tree, tree.indexOf("Red [enumvalue]") != -1); + assertTrue("Expected 'Red [enumvalue]' somewhere in here:" + tree, tree.contains("Red [enumvalue]")); } } diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java index f03ebe3f0..8c277a906 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java @@ -243,7 +243,7 @@ public class SynchronizationTransformTests extends XMLBasedAjcTestCase { String[] lines = ls.getLines(); for (int i = 0; i < lines.length; i++) { String existingLine = lines[i]; - if (fileContents[i].indexOf("MethodDeclarationLineNumber") == -1 && !fileContents[i].equals(existingLine)) { + if (!fileContents[i].contains("MethodDeclarationLineNumber") && !fileContents[i].equals(existingLine)) { dump("File contents:", fileContents); dump("Actual:", lines); fail("\nDifference in method " + m.getName() + " on line " + i + " between the expected:\n" + fileContents[i] diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java index 5e9e5b25e..b728b8862 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java @@ -300,11 +300,11 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { String warning = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_WARNING, "declare warning: \"warning\"").getHandleIdentifier(); assertTrue("shouldn't have incremented counter for declare warning handle " + "because only one declare warning statement", - warning.indexOf("!0") == -1 && warning.indexOf("!2") == -1); + !warning.contains("!0") && !warning.contains("!2")); String error = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_ERROR, "declare error: \"error\"") .getHandleIdentifier(); assertTrue("shouldn't have incremented counter for declare error handle " + "because only one declare error statement", - error.indexOf("!0") == -1 && error.indexOf("!2") == -1); + !error.contains("!0") && !error.contains("!2")); } // public void testOnlyIncrementSameAdviceKindFromInjar_pr159896() { diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc161/Ajc161Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc161/Ajc161Tests.java index bba565a3a..621c1917c 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc161/Ajc161Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc161/Ajc161Tests.java @@ -143,7 +143,7 @@ public class Ajc161Tests extends org.aspectj.testing.XMLBasedAjcTestCase { String expected = "<recursivepackage{RecursiveCatcher.java'RecursiveCatcher~recursiveCall~I?method-call(void recursivepackage.RecursiveCatcher.recursiveCall(int))"; for (Object entry : entries) { String str = (String) entry; - if (str.indexOf(expected) != -1) { + if (str.contains(expected)) { gotSomethingValid = true; } } diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc165/Ajc165Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc165/Ajc165Tests.java index 762865c57..46d2c9038 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc165/Ajc165Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc165/Ajc165Tests.java @@ -87,7 +87,7 @@ public class Ajc165Tests extends org.aspectj.testing.XMLBasedAjcTestCase { // Look for the message relating to 'List' and check the offsets for (IMessage iMessage : ms) { LintMessage m = (LintMessage) iMessage; - if (m.toString().indexOf("List") != -1) { + if (m.toString().contains("List")) { // 225/228 on windows - 237/240 on linux if (!(m.getSourceStart() == 225 || m.getSourceStart() == 237)) { fail("Did not get expected start position, was:" + m.getSourceStart()); diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc169/IntertypeTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc169/IntertypeTests.java index a91b3a13e..7278a35be 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc169/IntertypeTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc169/IntertypeTests.java @@ -156,8 +156,8 @@ public class IntertypeTests extends org.aspectj.testing.XMLBasedAjcTestCase { pw.write(irm.toString()); pw.flush(); String model = baos.toString(); - assertTrue(model.indexOf("<{Choice.java[Choice=[aspect declarations]") != -1); - assertTrue(model.indexOf("<{Choice.java'X[Keys=[declared on]") != -1); + assertTrue(model.contains("<{Choice.java[Choice=[aspect declarations]")); + assertTrue(model.contains("<{Choice.java'X[Keys=[declared on]")); } public void testGenerics1() throws Exception { diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/IncrementalTests.java b/tests/src/test/java/org/aspectj/systemtest/incremental/IncrementalTests.java index fc1fa68d8..1d0a546dd 100644 --- a/tests/src/test/java/org/aspectj/systemtest/incremental/IncrementalTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/IncrementalTests.java @@ -179,7 +179,7 @@ public class IncrementalTests extends org.aspectj.testing.XMLBasedAjcTestCase { public void testIncrementalResourceAdditionToInPath() throws Exception { runTest("incremental with addition of resource to inpath directory"); RunResult result = run("Hello"); - assertTrue("Should have been advised",result.getStdOut().indexOf("World") != -1); + assertTrue("Should have been advised", result.getStdOut().contains("World")); nextIncrement(false); assertFalse("Resource file should not exist yet",new File(ajc.getSandboxDirectory(),"AResourceFile.txt").exists()); copyFileAndDoIncrementalBuild("changes/AResourceFile.txt", "indir/AResourceFile.txt"); diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java index 916801690..dd032b3a4 100644 --- a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java @@ -238,9 +238,9 @@ public class AbstractMultiProjectIncrementalAjdeInteractionTestbed extends AjdeI BufferedReader reader = new BufferedReader(new FileReader(aopXML)); String line = reader.readLine(); while (line != null) { - if (aspectName.equals("") && line.indexOf("aspect name=\"") != -1) { + if (aspectName.equals("") && line.contains("aspect name=\"")) { aspectCount++; - } else if (line.indexOf("aspect name=\"" + aspectName + "\"") != -1) { + } else if (line.contains("aspect name=\"" + aspectName + "\"")) { aspectCount++; } line = reader.readLine(); @@ -257,7 +257,7 @@ public class AbstractMultiProjectIncrementalAjdeInteractionTestbed extends AjdeI protected void assertContains(String expectedSubstring, Object object) { String actualString = object.toString(); - if (actualString.indexOf(expectedSubstring) == -1) { + if (!actualString.contains(expectedSubstring)) { fail("Expected to find '" + expectedSubstring + "' in '" + actualString + "'"); } } diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java index 9c5770ef8..ec1965ca5 100644 --- a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java @@ -364,7 +364,7 @@ public class AjdeInteractionTestbed extends TestCase { AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); List<IMessage> messages = ((MultiProjTestMessageHandler) compiler.getMessageHandler()).getErrorMessages(); for (IMessage element : messages) { - if (element.getMessage().indexOf(anError) != -1) { + if (element.getMessage().contains(anError)) { return; } } diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java index 538d2dcbd..3c13ccb71 100644 --- a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java @@ -113,7 +113,7 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen // the unwovenClassFiles should have filenames that point to the output dir // (which in this case is the sandbox dir) and not where they came from. for (UnwovenClassFile ucf: unwovenClassFiles) { - if (ucf.getFilename().indexOf(expectedOutputDir) == -1) { + if (!ucf.getFilename().contains(expectedOutputDir)) { fileNames.add(ucf.getFilename()); } } @@ -152,7 +152,7 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen // the unwovenClassFiles should have filenames that point to the output dir // (which in this case is the sandbox dir) and not where they came from. for (UnwovenClassFile ucf: unwovenClassFiles) { - if (ucf.getFilename().indexOf(expectedOutputDir) == -1) { + if (!ucf.getFilename().contains(expectedOutputDir)) { fileNames.add(ucf.getFilename()); } } @@ -182,7 +182,7 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen List<String> fileNames = new ArrayList<>(); for (UnwovenClassFile ucf: unwovenClassFiles) { - if (ucf.getFilename().indexOf(expectedOutputDir) == -1) { + if (!ucf.getFilename().contains(expectedOutputDir)) { fileNames.add(ucf.getFilename()); } } diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java index 75600dded..c4ea8f120 100644 --- a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java @@ -707,7 +707,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // 2 errors are reported when there is a clash - one against the aspect, one against the affected target type. // each of the two errors are recorded against the compilation result for the aspect and the target // So it comes out as 4 - but for now I am tempted to leave it because at least it shows there is a problem... - assertTrue("Was:" + getErrorMessages(p).get(0), getErrorMessages(p).get(0).toString().indexOf("conflicts") != -1); + assertTrue("Was:" + getErrorMessages(p).get(0), getErrorMessages(p).get(0).toString().contains("conflicts")); } public void testOutputLocationCallbacks2() { @@ -789,8 +789,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa build(p); checkWasFullBuild(); assertEquals(1, getErrorMessages(p).size()); - assertTrue(((Message) getErrorMessages(p).get(0)).getMessage().indexOf( - "Syntax error on token \")\", \"name pattern\" expected") != -1); + assertTrue(((Message) getErrorMessages(p).get(0)).getMessage().contains("Syntax error on token \")\", \"name pattern\" expected")); } public void testIncrementalMixin() { @@ -1160,15 +1159,15 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa initialiseProject(p); build(p); List<IMessage> l = getErrorMessages(p); - assertTrue(l.toString().indexOf("ManagedResource cannot be resolved to a type") != -1); + assertTrue(l.toString().contains("ManagedResource cannot be resolved to a type")); // checkWasFullBuild(); alter(p, "inc1"); build(p); // checkWasntFullBuild(); List<String> compilerErrors = getCompilerErrorMessages(p); - assertTrue(compilerErrors.toString().indexOf("NullPointerException") == -1); + assertTrue(!compilerErrors.toString().contains("NullPointerException")); l = getErrorMessages(p); - assertTrue(l.toString().indexOf("ManagedResource cannot be resolved to a type") != -1); + assertTrue(l.toString().contains("ManagedResource cannot be resolved to a type")); } public void testIncrementalAnnoStyle_pr286341() { @@ -1514,13 +1513,13 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa private IProgramElement findFile(IProgramElement whereToLook, String filesubstring) { if (whereToLook.getSourceLocation() != null && whereToLook.getKind().isSourceFile() - && whereToLook.getSourceLocation().getSourceFile().toString().indexOf(filesubstring) != -1) { + && whereToLook.getSourceLocation().getSourceFile().toString().contains(filesubstring)) { return whereToLook; } for (IProgramElement element : whereToLook.getChildren()) { Kind k = element.getKind(); ISourceLocation sloc = element.getSourceLocation(); - if (sloc != null && k.isSourceFile() && sloc.getSourceFile().toString().indexOf(filesubstring) != -1) { + if (sloc != null && k.isSourceFile() && sloc.getSourceFile().toString().contains(filesubstring)) { return element; } if (k.isSourceFile()) { @@ -2961,7 +2960,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa List<String> files = getCompiledFiles(projectName); boolean found = false; for (String object: files) { - if (object.indexOf(typeNameSubstring) != -1) { + if (object.contains(typeNameSubstring)) { found = true; } } @@ -3053,7 +3052,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa List<IMessage> warnings = getWarningMessages("PR133117"); List<IMessage> noGuardWarnings = new ArrayList<>(); for (IMessage warning: warnings) { - if (warning.getMessage().indexOf("Xlint:noGuardForLazyTjp") != -1) { + if (warning.getMessage().contains("Xlint:noGuardForLazyTjp")) { noGuardWarnings.add(warning); } } @@ -3137,7 +3136,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa String decisions = AjdeInteractionTestbed.MyStateListener.getDecisions(); String expect = "Need to recompile 'A.aj'"; assertTrue("Couldn't find build decision: '" + expect + "' in the list of decisions made:\n" + decisions, - decisions.indexOf(expect) != -1); + decisions.contains(expect)); } public void testPr133532_3() { diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/OutputLocationManagerTests.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/OutputLocationManagerTests.java index 333495399..6f6be1256 100644 --- a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/OutputLocationManagerTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/OutputLocationManagerTests.java @@ -114,11 +114,11 @@ public class OutputLocationManagerTests extends AbstractMultiProjectIncrementalA public File getOutputLocationForClass(File compilationUnit) { String relativePath = ""; String compilationUnitName = compilationUnit.getAbsolutePath(); - if (compilationUnitName.indexOf("srcRootOne") != -1) { + if (compilationUnitName.contains("srcRootOne")) { relativePath = "target/main/classes"; - } else if (compilationUnitName.indexOf("srcRootTwo") != -1) { + } else if (compilationUnitName.contains("srcRootTwo")) { relativePath = "target/test/classes"; - } else if (compilationUnitName.indexOf("srcRootThree") != -1) { + } else if (compilationUnitName.contains("srcRootThree")) { relativePath = "target/anotherTest/classes"; } File ret = new File(projectHome, relativePath); diff --git a/util/src/main/java/org/aspectj/util/FileUtil.java b/util/src/main/java/org/aspectj/util/FileUtil.java index 6e55742b1..1927f47a0 100644 --- a/util/src/main/java/org/aspectj/util/FileUtil.java +++ b/util/src/main/java/org/aspectj/util/FileUtil.java @@ -1404,7 +1404,7 @@ public class FileUtil { /** @return true if input is not null and contains no path separator */ private static boolean isValidFileName(String input) { - return ((null != input) && (-1 == input.indexOf(File.pathSeparator))); + return ((null != input) && (!input.contains(File.pathSeparator))); } private static void listFiles(final File baseDir, String dir, ArrayList<String> result) { diff --git a/util/src/main/java/org/aspectj/util/LangUtil.java b/util/src/main/java/org/aspectj/util/LangUtil.java index a0967cfcc..49a65df52 100644 --- a/util/src/main/java/org/aspectj/util/LangUtil.java +++ b/util/src/main/java/org/aspectj/util/LangUtil.java @@ -356,7 +356,7 @@ public class LangUtil { } ArrayList<String> result = new ArrayList<String>(); - if (LangUtil.isEmpty(delim) || (-1 == input.indexOf(delim))) { + if (LangUtil.isEmpty(delim) || (!input.contains(delim))) { result.add(input.trim()); } else { StringTokenizer st = new StringTokenizer(input, delim); @@ -1018,7 +1018,7 @@ public class LangUtil { boolean result = false; if (!LangUtil.isEmpty(input)) { for (int i = 0; !result && (i < infixes.length); i++) { - result = (-1 != input.indexOf(infixes[i])); + result = (input.contains(infixes[i])); } } return result; diff --git a/util/src/test/java/org/aspectj/util/FileUtilTest.java b/util/src/test/java/org/aspectj/util/FileUtilTest.java index 367c0ea5e..663352be6 100644 --- a/util/src/test/java/org/aspectj/util/FileUtilTest.java +++ b/util/src/test/java/org/aspectj/util/FileUtilTest.java @@ -162,7 +162,7 @@ public class FileUtilTest extends TestCase { * @param useSuffix if true, then use dir as suffix to path */ private static void doDirPaths(File dir, ArrayList<String> paths) { - if ((null == dir) || !dir.canRead() || (-1 != dir.getPath().indexOf("CVS"))) { + if ((null == dir) || !dir.canRead() || (dir.getPath().contains("CVS"))) { return; } File[] files = dir.listFiles(); diff --git a/util/src/test/java/org/aspectj/util/GenericSignatureParserTest.java b/util/src/test/java/org/aspectj/util/GenericSignatureParserTest.java index 73a272369..79cd0bbe9 100644 --- a/util/src/test/java/org/aspectj/util/GenericSignatureParserTest.java +++ b/util/src/test/java/org/aspectj/util/GenericSignatureParserTest.java @@ -189,7 +189,7 @@ public class GenericSignatureParserTest extends TestCase { GenericSignature.FieldTypeSignature cSig = parser.parseAsFieldSignature("Ljava/util/List</;"); fail("Expected IllegalStateException"); } catch (IllegalStateException ex) { - assertTrue(ex.getMessage().indexOf("Ljava/util/List</;") != -1); + assertTrue(ex.getMessage().contains("Ljava/util/List</;")); } } diff --git a/util/src/test/java/org/aspectj/util/LangUtilTest.java b/util/src/test/java/org/aspectj/util/LangUtilTest.java index 7e95858b9..545cdd904 100644 --- a/util/src/test/java/org/aspectj/util/LangUtilTest.java +++ b/util/src/test/java/org/aspectj/util/LangUtilTest.java @@ -229,7 +229,7 @@ public class LangUtilTest extends TestCase { LangUtil.elideEndingLines(LangUtil.StringChecker.TEST_PACKAGES, stackBuffer, 10); String result = stackBuffer.toString(); - if (-1 == result.indexOf("(... ")) { + if (!result.contains("(... ")) { // brittle - will fail under different top-level drivers String m = "when running under eclipse or Ant, expecting (... in trace: "; assertTrue(m + result, false); @@ -264,7 +264,7 @@ public class LangUtilTest extends TestCase { LangUtil.elideEndingLines(LangUtil.StringChecker.TEST_PACKAGES, stackBuffer, 25); result = stackBuffer.toString(); - assertTrue(result, -1 != result.indexOf("(... ")); - assertTrue(result, -1 == result.indexOf("org.aspectj.testing")); + assertTrue(result, result.contains("(... ")); + assertTrue(result, !result.contains("org.aspectj.testing")); } } diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/AtAjAttributes.java b/weaver/src/main/java/org/aspectj/weaver/bcel/AtAjAttributes.java index f49a1bb33..971ee314d 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/AtAjAttributes.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/AtAjAttributes.java @@ -1958,7 +1958,7 @@ public class AtAjAttributes { Pointcut pointcut = parser.parsePointcut(); parser.checkEof(); pointcut.check(null, struct.enclosingType.getWorld()); - if (!allowIf && pointcutString.indexOf("if()") >= 0 && hasIf(pointcut)) { + if (!allowIf && pointcutString.contains("if()") && hasIf(pointcut)) { reportError("if() pointcut is not allowed at this pointcut location '" + pointcutString + "'", struct); return null; } diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelTypeMunger.java index 1eae17682..60f366e5a 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelTypeMunger.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelTypeMunger.java @@ -185,7 +185,7 @@ public class BcelTypeMunger extends ConcreteTypeMunger { // TAG: WeavingMessage if (changed && worthReporting && munger != null && !weaver.getWorld().getMessageHandler().isIgnoring(IMessage.WEAVEINFO)) { String tName = weaver.getLazyClassGen().getType().getSourceLocation().getSourceFile().getName(); - if (tName.indexOf("no debug info available") != -1) { + if (tName.contains("no debug info available")) { tName = "no debug info available"; } else { tName = getShortname(weaver.getLazyClassGen().getType().getSourceLocation().getSourceFile().getPath()); diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWorld.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWorld.java index 1ee675655..5916e0117 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWorld.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWorld.java @@ -230,7 +230,7 @@ public class BcelWorld extends World implements Repository { */ private String beautifyLocation(ISourceLocation isl) { StringBuffer nice = new StringBuffer(); - if (isl == null || isl.getSourceFile() == null || isl.getSourceFile().getName().indexOf("no debug info available") != -1) { + if (isl == null || isl.getSourceFile() == null || isl.getSourceFile().getName().contains("no debug info available")) { nice.append("no debug info available"); } else { // can't use File.getName() as this fails when a Linux box encounters a path created on Windows and vice-versa @@ -242,7 +242,7 @@ public class BcelWorld extends World implements Repository { if (binary != -1 && binary < takeFrom) { // we have been woven by a binary aspect String pathToBinaryLoc = isl.getSourceFile().getPath().substring(0, binary + 1); - if (pathToBinaryLoc.indexOf(".jar") != -1) { + if (pathToBinaryLoc.contains(".jar")) { // only want to add the extra info if we're from a jar file int lastSlash = pathToBinaryLoc.lastIndexOf('/'); if (lastSlash == -1) { diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/ExtensibleURLClassLoader.java b/weaver/src/main/java/org/aspectj/weaver/bcel/ExtensibleURLClassLoader.java index 3480b8172..76bd4b84b 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/ExtensibleURLClassLoader.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/ExtensibleURLClassLoader.java @@ -71,7 +71,7 @@ public abstract class ExtensibleURLClassLoader extends URLClassLoader { try { unresolvedType = UnresolvedType.forName(name); } catch (BCException bce) { - if (bce.getMessage().indexOf("nameToSignature") == -1) { + if (!bce.getMessage().contains("nameToSignature")) { bce.printStackTrace(System.err); } return null; diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/Utility.java b/weaver/src/main/java/org/aspectj/weaver/bcel/Utility.java index bb4a38817..c29721d4a 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/Utility.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/Utility.java @@ -113,7 +113,7 @@ public class Utility { */ public static String beautifyLocation(ISourceLocation isl) { StringBuffer nice = new StringBuffer(); - if (isl == null || isl.getSourceFile() == null || isl.getSourceFile().getName().indexOf("no debug info available") != -1) { + if (isl == null || isl.getSourceFile() == null || isl.getSourceFile().getName().contains("no debug info available")) { nice.append("no debug info available"); } else { // can't use File.getName() as this fails when a Linux box diff --git a/weaver/src/main/java/org/aspectj/weaver/model/AsmRelationshipProvider.java b/weaver/src/main/java/org/aspectj/weaver/model/AsmRelationshipProvider.java index 2e8a91291..7df7f438c 100644 --- a/weaver/src/main/java/org/aspectj/weaver/model/AsmRelationshipProvider.java +++ b/weaver/src/main/java/org/aspectj/weaver/model/AsmRelationshipProvider.java @@ -715,7 +715,7 @@ public class AsmRelationshipProvider { if (kind == ResolvedTypeMunger.Field) { // ITD FIELD // String name = rtMunger.getSignature().toString(); String name = sig.getDeclaringType().getClassName() + "." + sig.getName(); - if (name.indexOf("$") != -1) { + if (name.contains("$")) { name = name.substring(name.indexOf("$") + 1); } IProgramElement pe = new ProgramElement(model, name, IProgramElement.Kind.INTER_TYPE_FIELD, getBinarySourceLocation( @@ -725,7 +725,7 @@ public class AsmRelationshipProvider { } else if (kind == ResolvedTypeMunger.Method) { // ITD // METHOD String name = sig.getDeclaringType().getClassName() + "." + sig.getName(); - if (name.indexOf("$") != -1) { + if (name.contains("$")) { name = name.substring(name.indexOf("$") + 1); } IProgramElement pe = new ProgramElement(model, name, IProgramElement.Kind.INTER_TYPE_METHOD, getBinarySourceLocation( @@ -734,7 +734,7 @@ public class AsmRelationshipProvider { return pe; } else if (kind == ResolvedTypeMunger.Constructor) { String name = sig.getDeclaringType().getClassName() + "." + sig.getDeclaringType().getClassName(); - if (name.indexOf("$") != -1) { + if (name.contains("$")) { name = name.substring(name.indexOf("$") + 1); } IProgramElement pe = new ProgramElement(model, name, IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR, diff --git a/weaver/src/test/java/org/aspectj/weaver/DumpTestCase.java b/weaver/src/test/java/org/aspectj/weaver/DumpTestCase.java index 752473533..ba78b686b 100644 --- a/weaver/src/test/java/org/aspectj/weaver/DumpTestCase.java +++ b/weaver/src/test/java/org/aspectj/weaver/DumpTestCase.java @@ -122,7 +122,7 @@ public class DumpTestCase extends TestCase { String record; while ((null != (record = reader.readLine())) && (result == false)) { if (record.startsWith("----")) currentHeading = record; - else if ((record.indexOf(contents) != -1) && currentHeading.indexOf(heading) != -1) result = true; + else if ((record.contains(contents)) && currentHeading.contains(heading)) result = true; } reader.close(); } diff --git a/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java b/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java index 6852da6b7..8e84a71e5 100644 --- a/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java +++ b/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java @@ -125,7 +125,7 @@ public class AnnotationPatternMatchingTestCase extends TestCase { String expected = "Type referred to is not an annotation type"; String msg = ((IMessage) mh.messages.get(0)).toString(); - assertTrue("Expected: " + expected + " but got " + msg, msg.indexOf(expected) != -1); + assertTrue("Expected: " + expected + " but got " + msg, msg.contains(expected)); } public void testReferenceViaFormalToNonAnnotationType() { @@ -142,7 +142,7 @@ public class AnnotationPatternMatchingTestCase extends TestCase { String expected = "Type referred to is not an annotation type"; String msg = ((IMessage) mh.messages.get(0)).toString(); - assertTrue("Expected: " + expected + " but got " + msg, msg.indexOf(expected) != -1); + assertTrue("Expected: " + expected + " but got " + msg, msg.contains(expected)); // expected = "Binding not supported in @pcds (1.5.0 M1 limitation): null"; // msg = ((IMessage)mh.messages.get(1)).toString(); diff --git a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutDesignatorHandlerTest.java b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutDesignatorHandlerTest.java index ca9835c29..1ea33c465 100644 --- a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutDesignatorHandlerTest.java +++ b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutDesignatorHandlerTest.java @@ -47,7 +47,7 @@ public class PointcutDesignatorHandlerTest extends TestCase { .parsePointcutExpression("bean(service.*"); fail("should not be able to parse bean(service.*)"); } catch(IllegalArgumentException ex) { - assertTrue("contains bean",ex.getMessage().indexOf("bean") != -1); + assertTrue("contains bean", ex.getMessage().contains("bean")); } } diff --git a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java index 9488a5e90..fbf4d3068 100644 --- a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java +++ b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java @@ -336,14 +336,14 @@ public class PointcutParserTest extends TestCase { pc = parser.parsePointcutExpression("args(String)", null, new PointcutParameter[] { param }); fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { - assertTrue("formal unbound", ex.getMessage().indexOf("formal unbound") != -1); + assertTrue("formal unbound", ex.getMessage().contains("formal unbound")); } try { pc = parser.parsePointcutExpression("args(y)"); fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { - assertTrue("no match for type name", ex.getMessage().indexOf("warning no match for this type name: y") != -1); + assertTrue("no match for type name", ex.getMessage().contains("warning no match for this type name: y")); } } @@ -357,7 +357,7 @@ public class PointcutParserTest extends TestCase { try { p.parsePointcutExpression("this(FooBar)"); } catch (IllegalArgumentException ex) { - assertTrue("should have xlint:invalidAbsoluteTypeName", ex.getMessage().indexOf("Xlint:invalidAbsoluteTypeName") != -1); + assertTrue("should have xlint:invalidAbsoluteTypeName", ex.getMessage().contains("Xlint:invalidAbsoluteTypeName")); } Properties props = new Properties(); props.put("invalidAbsoluteTypeName", "ignore"); |