aboutsummaryrefslogtreecommitdiffstats
path: root/loadtime/src
diff options
context:
space:
mode:
authorLars Grefer <eclipse@larsgrefer.de>2020-08-08 03:11:12 +0200
committerLars Grefer <eclipse@larsgrefer.de>2020-08-08 03:11:12 +0200
commitc1c373f4278426308689db61f7758185e8f0401b (patch)
tree9e03af2feb69782c50464fc1e1e2ce0d6b6bb8c5 /loadtime/src
parenta508fd5315c6330f2057c219aebc35b15d0ea497 (diff)
downloadaspectj-c1c373f4278426308689db61f7758185e8f0401b.tar.gz
aspectj-c1c373f4278426308689db61f7758185e8f0401b.zip
'String.indexOf()' expression is replaceable with 'contains()'
Reports any String.indexOf() expressions which can be replaced with a call to the String.contains() method available in Java 5 and newer. Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>
Diffstat (limited to 'loadtime/src')
-rw-r--r--loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java2
-rw-r--r--loadtime/src/main/java/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java4
-rw-r--r--loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingURLClassLoaderTest.java6
3 files changed, 6 insertions, 6 deletions
diff --git a/loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java b/loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
index 173310591..5827f2e64 100644
--- a/loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
+++ b/loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
@@ -662,7 +662,7 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
* Checks if the pattern looks like "com.foo.Bar" - an exact name
*/
private String looksLikeExactName(String typePattern) {
- if (hasSpaceAnnotationPlus(typePattern, 0) || typePattern.indexOf("*") != -1) {
+ if (hasSpaceAnnotationPlus(typePattern, 0) || typePattern.contains("*")) {
return null;
}
return typePattern.replace('$', '.');
diff --git a/loadtime/src/main/java/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java b/loadtime/src/main/java/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java
index 6f5b58702..7f87e40c9 100644
--- a/loadtime/src/main/java/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java
+++ b/loadtime/src/main/java/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java
@@ -164,7 +164,7 @@ public class ConcreteAspectCodeGen {
String parentAspectName = concreteAspect.extend;
- if (parentAspectName.indexOf("<") != -1) {
+ if (parentAspectName.contains("<")) {
// yikes, generic parent
parent = world.resolve(UnresolvedType.forName(parentAspectName), true);
if (parent.isMissing()) {
@@ -741,7 +741,7 @@ public class ConcreteAspectCodeGen {
return null;
}
String clazz = value.substring(0, value.length() - 6);
- boolean qualified = clazz.indexOf(".") != -1;
+ boolean qualified = clazz.contains(".");
if (!qualified) {
// if not qualified, have to assume java.lang
clazz = "java.lang." + clazz;
diff --git a/loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingURLClassLoaderTest.java b/loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingURLClassLoaderTest.java
index 406847eb2..5ae1d50e3 100644
--- a/loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingURLClassLoaderTest.java
+++ b/loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingURLClassLoaderTest.java
@@ -359,7 +359,7 @@ public class WeavingURLClassLoaderTest extends TestCase {
} catch (Exception ex) {
// Expecting: java.lang.NoClassDefFoundError: LTWAspect
String m = ex.getMessage();
- if (-1 == m.indexOf("java.lang.NoClassDefFoundError")) {
+ if (!m.contains("java.lang.NoClassDefFoundError")) {
fail("Expecting java.lang.NoClassDefFoundError but caught " + ex);
}
}
@@ -426,7 +426,7 @@ public class WeavingURLClassLoaderTest extends TestCase {
// expecting error
String message = ex.getMessage();
// expecting error - seems to be wrapped wrong
- if (-1 == message.indexOf("around advice")) {
+ if (!message.contains("around advice")) {
failWithException(ex);
}
} catch (Error ex) {
@@ -461,7 +461,7 @@ public class WeavingURLClassLoaderTest extends TestCase {
invokeMain(clazz, new String[] {});
fail("Should reject bad aspect MissingFile");
} catch (AbortException ae) {
- assertTrue("Unexpected cause: " + ae.getMessage(), ae.getMessage().indexOf("bad aspect library") != -1);
+ assertTrue("Unexpected cause: " + ae.getMessage(), ae.getMessage().contains("bad aspect library"));
}
}