]> source.dussan.org Git - aspectj.git/commitdiff
'String.indexOf()' expression is replaceable with 'contains()'
authorLars Grefer <eclipse@larsgrefer.de>
Sat, 8 Aug 2020 01:11:12 +0000 (03:11 +0200)
committerLars Grefer <eclipse@larsgrefer.de>
Sat, 8 Aug 2020 01:11:12 +0000 (03:11 +0200)
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:
ajde.core/src/test/java/org/aspectj/ajde/core/AjdeCoreTestCase.java
ajde.core/src/test/java/org/aspectj/ajde/core/TestBuildProgressMonitor.java
ajde.core/src/test/java/org/aspectj/ajde/core/tests/InpathTest.java
ajde.core/src/test/java/org/aspectj/ajde/core/tests/ResourceCopyTest.java
ajde/src/main/java/org/aspectj/ajde/ui/StructureSearchManager.java
ajde/src/test/java/org/aspectj/ajde/ExtensionTest.java
ajde/src/test/java/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java
ajde/src/test/java/org/aspectj/ajde/ui/utils/TestBuildProgressMonitor.java
ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java
ajdoc/src/main/java/org/aspectj/tools/ajdoc/StubFileGenerator.java
ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocOutputChecker.java
asm/src/main/java/org/aspectj/asm/internal/JDTLikeHandleProvider.java
asm/src/main/java/org/aspectj/asm/internal/ProgramElement.java
bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Utility.java
bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java
bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/ElementValueGenTest.java
bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java
bcel-builder/src/test/java/org/aspectj/apache/bcel/util/ClassPathTests.java
bridge/src/main/java/org/aspectj/bridge/MessageUtil.java
build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java
build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java
build/src/main/java/org/aspectj/internal/tools/build/Builder.java
build/src/main/java/org/aspectj/internal/tools/build/Module.java
loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
loadtime/src/main/java/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java
loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingURLClassLoaderTest.java
org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/AjdtCommand.java
org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java
org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java
org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java
org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java
org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java
org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java
org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java
org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/AjdtCommandTestCase.java
org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java
org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/DumpTestCase.java
org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java
org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java
org.aspectj.matcher/src/main/java/org/aspectj/weaver/NameMangler.java
org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedMemberImpl.java
org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedType.java
org.aspectj.matcher/src/main/java/org/aspectj/weaver/ShadowMunger.java
org.aspectj.matcher/src/main/java/org/aspectj/weaver/UnresolvedType.java
org.aspectj.matcher/src/main/java/org/aspectj/weaver/Utils.java
org.aspectj.matcher/src/main/java/org/aspectj/weaver/World.java
org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java
org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildTypePattern.java
org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/BindingTestCase.java
runtime/src/main/java/org/aspectj/internal/lang/reflect/StringToType.java
runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeTest.java
runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeWithAspectsTest.java
runtime/src/test/java/org/aspectj/runtime/RuntimeTest.java
taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java
taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java
taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java
testing-client/src/test/java/org/aspectj/testing/TesterTest.java
testing-drivers/src/test/java/org/aspectj/testing/drivers/Harness.java
testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java
testing-util/src/test/java/org/aspectj/testingutil/TestUtilTest.java
testing/src/test/java/org/aspectj/testing/AntSpec.java
testing/src/test/java/org/aspectj/testing/CompileSpec.java
testing/src/test/java/org/aspectj/testing/OutputSpec.java
testing/src/test/java/org/aspectj/testing/harness/bridge/AjcTest.java
testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunSpecTest.java
testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunTest.java
testing/src/test/java/org/aspectj/testing/harness/bridge/FlatSuiteReader.java
testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java
testing/src/test/java/org/aspectj/testing/util/BridgeUtil.java
testing/src/test/java/org/aspectj/testing/util/Diffs.java
testing/src/test/java/org/aspectj/testing/util/FileUtil.java
testing/src/test/java/org/aspectj/testing/util/LangUtil.java
testing/src/test/java/org/aspectj/testing/util/LinkCheck.java
testing/src/test/java/org/aspectj/testing/util/ValidFileFilter.java
testing/src/test/java/org/aspectj/testing/util/options/OptionChecker.java
testing/src/test/java/org/aspectj/testing/xml/XMLWriter.java
tests/src/test/java/org/aspectj/systemtest/ajc121/Ajc121Tests.java
tests/src/test/java/org/aspectj/systemtest/ajc150/Ajc150Tests.java
tests/src/test/java/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java
tests/src/test/java/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java
tests/src/test/java/org/aspectj/systemtest/ajc161/Ajc161Tests.java
tests/src/test/java/org/aspectj/systemtest/ajc165/Ajc165Tests.java
tests/src/test/java/org/aspectj/systemtest/ajc169/IntertypeTests.java
tests/src/test/java/org/aspectj/systemtest/incremental/IncrementalTests.java
tests/src/test/java/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java
tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java
tests/src/test/java/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java
tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java
tests/src/test/java/org/aspectj/systemtest/incremental/tools/OutputLocationManagerTests.java
util/src/main/java/org/aspectj/util/FileUtil.java
util/src/main/java/org/aspectj/util/LangUtil.java
util/src/test/java/org/aspectj/util/FileUtilTest.java
util/src/test/java/org/aspectj/util/GenericSignatureParserTest.java
util/src/test/java/org/aspectj/util/LangUtilTest.java
weaver/src/main/java/org/aspectj/weaver/bcel/AtAjAttributes.java
weaver/src/main/java/org/aspectj/weaver/bcel/BcelTypeMunger.java
weaver/src/main/java/org/aspectj/weaver/bcel/BcelWorld.java
weaver/src/main/java/org/aspectj/weaver/bcel/ExtensibleURLClassLoader.java
weaver/src/main/java/org/aspectj/weaver/bcel/Utility.java
weaver/src/main/java/org/aspectj/weaver/model/AsmRelationshipProvider.java
weaver/src/test/java/org/aspectj/weaver/DumpTestCase.java
weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java
weaver/src/test/java/org/aspectj/weaver/tools/PointcutDesignatorHandlerTest.java
weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java

index eafa22f0438f50472fc21760fb8567d08e8066ef..c692d6d50eb52bb8112d05e65f728e00c29f267c 100644 (file)
@@ -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;
index 2a293b626ebcfdef86073f5a9f9403ed79e88bee..e214faeae7ce0b08c3e43223452bf9e7ef031cf1 100644 (file)
@@ -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;
        }
index 0696aa9086ff1a8de102e0b6a0213ca72fd0e72f..2d1b3fd7c7de68e09ee5d05f6c9a868d17964c92 100644 (file)
@@ -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);
                        }
                }
index b6f44ae7d663ee9b15ba1c2485e6af670488abc0..889e2e5ce652671a6c395623e296934ee1fb55b3 100644 (file)
@@ -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"));
                }
        };
index d9e9a0f52daa797f6217d40204b2c32ef95e8f19..8839b00daf8cd7ac28f276a2938411ab1d184f46 100644 (file)
@@ -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);
                        }
index a8ce3d922d11942f81dd633181cc5aebe6463f12..ce0269930b9934992ae4eb1a387d31f55d5426a7 100644 (file)
@@ -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;
                }
index c80f33bb62693da0a1b315d5f8ea53ce66a44c17..fe642ff95ee8486766fceca7d375554408932a04 100644 (file)
@@ -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"));
        
        }
 
index 6ccddefc02c48e36c198cce5ee19416b718e17ab..09d7941913ae5213dcca1c0578d0afb283fece71 100644 (file)
@@ -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;
        }
index 35e84ca5a47b83d1fe2ba510774a2f27930efca1..44708bb01c7aaf35f6d162e0130a1ef461e6b76a 100644 (file)
@@ -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
index cd8a01e261718a000adfe677855a6f371a2202da..4b9301ce817afba06b63f517889ec38b33a2836a 100644 (file)
@@ -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(" { }");
index b22d1250d49a182e21d2c931df8076c3cfc462e8..797c766604e18c4c65e5bb19942e4ae9362da6cf 100644 (file)
@@ -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)) {
index 15eb990eeab9017646ead5500830fe6cb80ae3e3..5e518c51f32377fe26763a052bd151a89d729190 100644 (file)
@@ -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;"));
                                }
index c1479f70fb2dd8ddcf9279aac6862c801905cb2e..77fe7a66b1ffd08c26d4b96e3f10072c189e1224 100644 (file)
@@ -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 {
index 2d4b2a81f26f018bd96f816db7e7f7a5e90cd822..9168847b085744926394a8999c7e59c9dd0dbf9c 100644 (file)
@@ -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) != '(') {
index 426ebbea953ee753f6d72d274e5e127c0a72747e..d9a4ce780cf1713899e283eec099323a3a9fd075 100644 (file)
@@ -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");
 
index 7d91bd7d34cc4aa5d059b20038d64062eeb3b563..ec7645aebf7d2cc2e2a9326d05c6731c683f38c8 100644 (file)
@@ -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);
        }
index f49b4fb464e1b87f1c2eb2d00ab959f38b39b519..351caa002b78d6eb6770f6b9757aedab9c7afd7b 100644 (file)
@@ -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"));
                
        }
index 711011213e79000d3a05917c0a86448fa7b552a9..53488df0e301d720921091fc5ddd39182ab64260 100644 (file)
@@ -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;
                }
index 0393a5a584cc65e4d63c5c8a99b56ca757f6058d..77f9c90a884fc30ad1b627f3702b371c6da6aa40 100644 (file)
@@ -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) {
index bef3fb0aa64977a025e5ed59c2a95afc0b41c9c0..12286748e25b4bb70cf8662a1cf6857f3f0f6f17 100644 (file)
@@ -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;
                        }
                }
index afa3c71d3239ad22ebd5b050caa2252a135a6c6e..aa0c35e354f5ffbe24313fc20c2b273ce90eedbb 100644 (file)
@@ -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
index 1d7bfa7d841c18ccb324be99ec61fc27caaecb22..fe80190ada2a01d798f3c675ee321336d28e6c79 100644 (file)
@@ -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);
         }
index acc8fd90b676a4c362ace6a9fc406ab6ac665c76..65d929707b1d7db5c4e861d1f53d598c1c7e1b25 100644 (file)
@@ -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;
index 173310591321d77a00c80be9ebbcb5ef16550827..5827f2e646d0da112e165b71be46206e2cd1a6f4 100644 (file)
@@ -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('$', '.');
index 6f5b58702ab9b7b3bca0e40cfd24da982ae0950d..7f87e40c9442726d9e4a3863212553c357318aed 100644 (file)
@@ -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;
index 406847eb2fd0d1ee2d5ca52ff9e02386571d7177..5ae1d50e36fab2e54a61d6e35af64ab78177ab73 100644 (file)
@@ -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"));
                }
        }
 
index 25de41c2dfd5a72ee187409d38b56442e0b65b1b..7fa4e9c3676c679b112b83d2e7bd4db3002ae6a0 100644 (file)
@@ -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;
index 70a610950f4e38aa17f23654a416be1e2a42c97d..365f569402d66062a89baa1921bcf3bb0ca55d39 100644 (file)
@@ -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) {
index ec5a2a545bbecd3bdde8edb91c939241de6ff134..c42a503c6137ac3e5dafa987e46bb6553a64cd7d 100644 (file)
@@ -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();
index 219f2fd48e0f51cabffecf1992f2096a4f539d05..4cd8445901508d20c90b2487dc093d0474511dfd 100644 (file)
@@ -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,",");
index 98c115190b87ba878acca6590cbb8a21aedc67ae..dfdcba12cbdff7288a568ba487d80e4713f34b08 100644 (file)
@@ -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;
             }
index 833ce2382672a5d359727e7b6bdb9dca30123765..7e08c02a7b813bea578f751267aff8ea3a646487 100644 (file)
@@ -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
index 77862dddfa2d181e48f47bfb23d7d13c959f61cb..776696aff45d2d52502f12b289930624bbb6359b 100644 (file)
@@ -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);
index 8a3acaec8315dfd1e6e21e9f98ca774e8d931a9a..795176c6156e515cad8ed8a5ab573822e2046894 100644 (file)
@@ -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());
index 6f7a1dd7c0533d31300b02222dce1b99a1eb0dd7..88558fed0aae5242d229237471989eaaf3ee060c 100644 (file)
@@ -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());
index 9c504a300ed87d928fdc476fc7fc30a4554aa426..57c2f8e4c8088abd754fbced391dd10e0636d360 100644 (file)
@@ -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 {
index 1f936661eff1e2a4a3f6120cf3186542d5748cd4..c4439c9f713f89e58899f828efedf832fa54fef3 100644 (file)
@@ -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(),
index dad021a7c14aad85a7b3c470a9acf9260eeda900..4f40922d6967894dc9aa2bdb0c6306c4a0ae369c 100644 (file)
@@ -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();
                }
index 6887d79fe043e54c603bc4e3f6b4bdd97b21bb77..1dc1182831eb3f265a35fb249a006ca624711627 100644 (file)
@@ -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) {
index a9442de739cc37685fca69a2f943e121c7f0eac7..7aa97ad1eae14c2a71020f8bfcdbb3862f7a6b10 100644 (file)
@@ -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];
                        }
index f9162684ab5433e53285a9101cc20ae6a0751dd0..a2b2f5d1cbf6be89072e4dea5b72022dd5f0a427 100644 (file)
@@ -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
index 90fd3ece3d9040c99a423203d4ed98b9c1150345..bb609f104c506fea2e95a7a30880d67aa63edc3e 100644 (file)
@@ -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 + ")");
                }
index a5a5eea5dc97182120429c135537d26bf5fef48a..8e48b02d467cf44aebcf36baa79d68edd2050641 100644 (file)
@@ -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() {
index a0e49becc915fd27128d41f0038ed0dd32a15c2f..809cc58de92fcda46791489323f3cfbd14358540 100644 (file)
@@ -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('.');
index 155bc09551f447684cda6154ca069489ca3dad37..19f1ca5ce90eb0a03f07512b68a5f4d45284513a 100644 (file)
@@ -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('.');
index 501ffa4181bc73f91d205eddf67676367492af8f..2ca0173be03de5cf26f0eceef255b8806c45301c 100644 (file)
@@ -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;
                                }
                        }
index 4e625d841155c15565aac2bb94dde3afa1895dcc..3b69a5d73f373017fefa06d52d0da8bb47020205 100644 (file)
@@ -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;
                }
        }
index 35f2dc674daf55f043d17b29e8e42af347588475..531b3d09fd2232e7525d987e55edff298c9128c1 100644 (file)
@@ -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);
index 3dad2ce6b292a3d83d9ab1827f6016d7021f3766..39d4a387be74c5395aeda0e0fafa9c9959a91f0f 100644 (file)
@@ -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);
index 7303191ddbbce0d31ff0ca807736547090471c80..132512e5a16c6b4edca08e4b6134040955ee936e 100644 (file)
@@ -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);
index c658bbbd031fe5a28e7b9d9c9586063bacaecad7..b953fa1cef8556bbc1025253c7a648dfe22f80c6 100644 (file)
@@ -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);
index 542de36d5681469ec5bc457d18977cd88bfa6c33..9ddb5c0dcfc908cf70ce437ecbee1056036519ff 100644 (file)
@@ -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 {
index a2f33f91be5c943b50f82f9933d644a8342fd824..5431a74579c16445eaa5f9072468b0eb00f9163c 100644 (file)
@@ -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() {
index a908a8ae025f6f93e3022489e3066f7a05eca7e5..2eb92e97b96d7d1b02c33faf161af4371ceea0af 100644 (file)
@@ -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"));
     }
 }  
index 9aea9ae6d6a08c4232bf506493d9758b5e3e433f..84f661cd5c585b6b2e72a6f756ad562339a1962f 100644 (file)
@@ -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);
                 }
index c68a1eb596fc8b7000ed2e4ff4a71229b6d9294d..8a7c8a51133ddb09f5d795eefef07b0814cb07f1 100644 (file)
@@ -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();
index b1f7c7b4fb611d9b82dfe26490731bcd3a648dae..4b387c21b224fb42d17472c394d155d695f154aa 100644 (file)
@@ -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));
index 544e46e2ffdc5635aa8c90db252eb8783e5463fa..5533739a386d4b3b85a8d2d2760feb73a9309cfe 100644 (file)
@@ -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;
                 }
                        }
index e932a027daba98c6f987de1b8bc038277b962f07..6c0a84fe9f8d430e7aa1d1653e01e54617473584 100644 (file)
@@ -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;
                                                }
                                        }
index 6be6cc61ecf4e207034458c72af578da539a9b2e..76b7a181a6ab8616e582609851ff229c08e37088 100644 (file)
@@ -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) {
index 0807bd2a3f6f4c0c3d5ab86cbfbc7a4b9a89b07e..1427ccc8a855d9f80340e8dee368209fd44c8094 100644 (file)
@@ -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);
                 }
             }
index 64ff4f3647bca69282860dc1109331493e7e9278..b5f23ca74c553b8e5e1a7508cb7dbbaf284cfb71 100644 (file)
@@ -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
index 97cba2bc5fecf06df1162d600c6136a4250ae6f7..e950ee1bacad204a181ef238d936a539e508031e 100644 (file)
@@ -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");
                }
        }
index 80e928bc971fa4f282cee3d2a8aa558d7adf1da2..d3b06490787ea324c4ec4207069e25f3f18b876b 100644 (file)
@@ -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;
index cd07733ea9f4bffb89b6d0719d7f4fcc954565f2..64588ba93b9516b51defd3597a96807b6587172b 100644 (file)
@@ -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;
                                                }
                                        }
index 12b91679abb1f84cf45a102cb1d66da422fc5b75..abac95dfe1e917f2be77242cb470f15bddb8b4f9 100644 (file)
@@ -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
index c5f68d03a7c279cb96d8c44300ed8c9d20f76bc4..9de7642bbb009e5c00a7df496ac100172de0db10 100644 (file)
@@ -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 "
index b3249feeb952660dae9ee7e5c84fc43ed6bd2c5e..16d1d6d19438dd51538e9b2337f69e67605b16dd 100644 (file)
@@ -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) {
index 7aa817f05a314c1c7fa05a6831d6b30d44b781f8..db74288165fe3c9104169bec5c60b06fd271a751 100644 (file)
@@ -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)));
        }
 
        /**
index a6e4c7cab78a45fde24bff27fbd889fc0011b198..7013160dc2be4d022cd1e4d01cd16ace6017bf66 100644 (file)
@@ -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);
index fee19a3e1792a9140425b9a15329944a6c44a537..f42197873729bd33fa7107226b359241ae7c9288 100644 (file)
@@ -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));
                }
        }
 
index a47f694e4f42b1dd6f546361885997d7aaf26fe1..ab780cd29e52dc174ba1f7eed4d3a6e294bfaaec 100644 (file)
@@ -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;
index e78ec84c8c1d971f5fa8f3fa78d3076a5d50491b..ddf3a832a20090e22ac8ac0915193befd63db58b 100644 (file)
@@ -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 + "\"");
index 380766a3b3d9c2cd56da225fa2e3271a65e27496..fd1edaf6fa38e875f5d25bbe6584f8f67e83685b 100644 (file)
@@ -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;
index 8d069af0fad4d126af17a9b775112099e8340001..db0e12f5ac1f7d2ef8d24fc30822df0e0c867dba 100644 (file)
@@ -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)))) {
index 87748f0b17fde92607f002f0110e4b6d8efb34e0..79d1ff2867d12b305303af746e134371a62b6002 100644 (file)
@@ -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
index eaa42326ed70ec9161fafa83da1b4cd814a86c07..7a8b176b7fd5a95983b291b5de0ca4674afd7d67 100644 (file)
@@ -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);
index 000a72010234cf3ffb8bca7052548247ffb19a04..8bc4ad81493bcc0bfeec318a3da2e81060e3be7a 100644 (file)
@@ -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);
index c105e881da9975a8a4c3ca651db89e3a650abf34..8dcb8c34d5375a3c4fe76d04e18cbd8d6d17c164 100644 (file)
@@ -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]"));
                }
        }
 
index f03ebe3f0575cb392fe76f2e535b48e6aabc35a8..8c277a90690b3620561935f8f93fef452781b11e 100644 (file)
@@ -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]
index 5e9e5b25ec7da7356ee289321caf094c1494f7bd..b728b8862e3ecb44dfe60a0a7583757e1e7ad7d5 100644 (file)
@@ -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() {
index bba565a3aaf5b1ffad2c4231d618748dbc5baff2..621c1917c5413be5c99b158c185891fae6a4b212 100644 (file)
@@ -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;
                        }
                }
index 762865c57b23a5d114d1e2069c341bce8fff968c..46d2c9038810c1d93e6ce9bd9909b8e0b957ae5f 100644 (file)
@@ -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());
index a91b3a13e7075f9b48f1c6ec3a30ab8270beeef0..7278a35be3ce81046ccaca20081bbcff57cdce00 100644 (file)
@@ -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 {
index fc1fa68d80d3cc1302fb4421c8e1dde0ce916832..1d0a546dd326a846e987cf508204e5e6f378b63e 100644 (file)
@@ -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");
index 9168016900d2d23eb7cf9d25996038c910019bec..dd032b3a4342bd41035e13d27e633b2f88b03add 100644 (file)
@@ -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 + "'");
                }
        }
index 9c5770ef86763c120280fd8dc3baf5283c07be1f..ec1965ca539f1351d4f8d4ae3ed27b79c6f4534c 100644 (file)
@@ -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;
                        }
                }
index 538d2dcbdd0591fa9b9cc8670cfe79087918d299..3c13ccb714f3b8719c8b6ba495b0460085c70401 100644 (file)
@@ -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());
                        }
                }
index 75600ddedf641eb96ac24745e7fa3d453c2f6f59..c4ea8f120a5bff46310e4e244813a0d917802cfc 100644 (file)
@@ -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() {
index 333495399e8ca5072678b4c89667b5c24bf40c36..6f6be125666c2b0f502a6a03008840c2f36cf3e2 100644 (file)
@@ -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);
index 6e55742b1dcdc34272cd482137595165e36933c4..1927f47a09fa1270579196665012699a31350d7c 100644 (file)
@@ -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) {
index a0967cfcca754180b9a5afae9e3cc6c1fb9c1383..49a65df52847a73c571526038ff0fdf982d0468b 100644 (file)
@@ -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;
index 367c0ea5e3d81d889e470ac0f03b7fc99bb785ab..663352be6cd8183d58345bf2f3833e43b66f70d3 100644 (file)
@@ -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();
index 73a2723696f87e122dadf5ba42c0a275713b1d78..79cd0bbe9a91c5b4602d25a2aaacb0411d82a861 100644 (file)
@@ -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</;"));
                }
        }
 
index 7e95858b95973646415bf3ab666a40f92b90aefd..545cdd904c20f868af6220cedca4619de18f6439 100644 (file)
@@ -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"));
        }
 }
index f49a1bb33368b4b5ae2fc96cf74eae2a281a147c..971ee314dda7149cc2532aec4e88167920be9644 100644 (file)
@@ -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;
                        }
index 1eae17682229d76a5437158cef58aba51b6e22b5..60f366e5a4cf48d2b83ed75e29511a0d5fff0cce 100644 (file)
@@ -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());
index 1ee675655e1801513624c834b2c1d53fdb473f18..5916e0117f55f457e50953b8373941f84978b2ec 100644 (file)
@@ -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) {
index 3480b8172dbfcd637688fc89c04566832e3d10ff..76bd4b84b1bbee1746edb154d05db1c8f4103c5c 100644 (file)
@@ -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;
index bb4a38817cc80760ad015cbdf493812dfcf228da..c29721d4a061224a227a28e322e7b8375685186e 100644 (file)
@@ -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
index 2e8a91291e77a8f483c236c4ba61269760d1af0e..7df7f438c2ac8b60655883a37f5d8efdb510dfec 100644 (file)
@@ -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,
index 7524735337e3253d9a67e4cd0bc059d3e00a490a..ba78b686b61fe02cd96136770e4a0f2d156f8330 100644 (file)
@@ -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();
                }
index 6852da6b7fd69c7e1f2a3d9d1573e10ff9615656..8e84a71e51bc488ef6b1ef5cef4dc0c1674e39ee 100644 (file)
@@ -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();
index ca9835c29b811eb1ade3323b3c5293da863195de..1ea33c46597e5fc8518c99cafdedc630a5baf322 100644 (file)
@@ -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"));
                }
        }
        
index 9488a5e9057d196e59cc22ea82a862805157908a..fbf4d3068b45b57e43f1233ae5c2d0206b69c3a8 100644 (file)
@@ -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");