aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/src
diff options
context:
space:
mode:
authorLars Grefer <eclipse@larsgrefer.de>2020-08-08 03:06:37 +0200
committerLars Grefer <eclipse@larsgrefer.de>2020-08-08 03:06:37 +0200
commit72194b7982ddfa8e9864d0a9934905bb76b90f33 (patch)
treeebed806c358c1a3960c5d6be4c13b26ca41809df /runtime/src
parentc3289ab86bfb2c97cf34147239b3dde46de92a7c (diff)
downloadaspectj-72194b7982ddfa8e9864d0a9934905bb76b90f33.tar.gz
aspectj-72194b7982ddfa8e9864d0a9934905bb76b90f33.zip
'for' loop replaceable with enhanced 'for' loop
Reports for loops which iterate over collections or arrays, and can be replaced with an enhanced for loop (i.e. the foreach iteration syntax). Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>
Diffstat (limited to 'runtime/src')
-rw-r--r--runtime/src/main/java/org/aspectj/internal/lang/reflect/StringToType.java6
-rw-r--r--runtime/src/main/java/org/aspectj/runtime/internal/cflowstack/ThreadCounterImpl11.java4
-rw-r--r--runtime/src/main/java/org/aspectj/runtime/reflect/MethodSignatureImpl.java4
-rw-r--r--runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeWithAspectsTest.java6
4 files changed, 10 insertions, 10 deletions
diff --git a/runtime/src/main/java/org/aspectj/internal/lang/reflect/StringToType.java b/runtime/src/main/java/org/aspectj/internal/lang/reflect/StringToType.java
index 4be9fd71e..c658bbbd0 100644
--- a/runtime/src/main/java/org/aspectj/internal/lang/reflect/StringToType.java
+++ b/runtime/src/main/java/org/aspectj/internal/lang/reflect/StringToType.java
@@ -48,9 +48,9 @@ public class StringToType {
} catch (ClassNotFoundException e) {
// could be a type variable
TypeVariable[] tVars = classScope.getTypeParameters();
- for (int i = 0; i < tVars.length; i++) {
- if (tVars[i].getName().equals(typeName)) {
- return tVars[i];
+ for (TypeVariable tVar : tVars) {
+ if (tVar.getName().equals(typeName)) {
+ return tVar;
}
}
throw new ClassNotFoundException(typeName);
diff --git a/runtime/src/main/java/org/aspectj/runtime/internal/cflowstack/ThreadCounterImpl11.java b/runtime/src/main/java/org/aspectj/runtime/internal/cflowstack/ThreadCounterImpl11.java
index 71aaacd62..bc53f9317 100644
--- a/runtime/src/main/java/org/aspectj/runtime/internal/cflowstack/ThreadCounterImpl11.java
+++ b/runtime/src/main/java/org/aspectj/runtime/internal/cflowstack/ThreadCounterImpl11.java
@@ -49,8 +49,8 @@ public class ThreadCounterImpl11 implements ThreadCounter {
Thread t = (Thread)e.nextElement();
if (!t.isAlive()) dead_stacks.add(t);
}
- for (Iterator e = dead_stacks.iterator(); e.hasNext(); ) {
- Thread t = (Thread)e.next();
+ for (Object dead_stack : dead_stacks) {
+ Thread t = (Thread) dead_stack;
counters.remove(t);
}
change_count = 0;
diff --git a/runtime/src/main/java/org/aspectj/runtime/reflect/MethodSignatureImpl.java b/runtime/src/main/java/org/aspectj/runtime/reflect/MethodSignatureImpl.java
index 17416bada..76ea6c6cf 100644
--- a/runtime/src/main/java/org/aspectj/runtime/reflect/MethodSignatureImpl.java
+++ b/runtime/src/main/java/org/aspectj/runtime/reflect/MethodSignatureImpl.java
@@ -102,8 +102,8 @@ class MethodSignatureImpl extends CodeSignatureImpl implements MethodSignature {
}
Class[] superinterfaces = type.getInterfaces();
if (superinterfaces != null) {
- for (int i = 0; i < superinterfaces.length; i++) {
- m = search(superinterfaces[i], name, params, searched);
+ for (Class superinterface : superinterfaces) {
+ m = search(superinterface, name, params, searched);
if (m != null) {
return m;
}
diff --git a/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeWithAspectsTest.java b/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeWithAspectsTest.java
index af72d26f5..a2f33f91b 100644
--- a/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeWithAspectsTest.java
+++ b/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeWithAspectsTest.java
@@ -146,9 +146,9 @@ public class AjTypeWithAspectsTest extends TestCase {
assertEquals(10,ms.length);
//AV was corrupted, cannot rely on ordering
String match = "";
- for (int i = 0; i < ms.length; i++) {
- match = match + "--" + ms[i].getName();
- }
+ for (Method m : ms) {
+ match = match + "--" + m.getName();
+ }
assertTrue(match.indexOf("aMethod") >=0);
}