diff options
author | Andy Clement <aclement@pivotal.io> | 2020-08-12 15:20:45 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-12 15:20:45 -0700 |
commit | b6eee2e1052116aa22ebbd3c2baf05c2b709bee5 (patch) | |
tree | 01fb5493dc348d42e4fb9fb6ce1cd41e361d666b /runtime | |
parent | cacc9d5602b7bbe6192d5ff1351605dc180cc108 (diff) | |
parent | 29f947156e58f3f0c60e721d42e7f3e98de7180a (diff) | |
download | aspectj-b6eee2e1052116aa22ebbd3c2baf05c2b709bee5.tar.gz aspectj-b6eee2e1052116aa22ebbd3c2baf05c2b709bee5.zip |
Merge pull request #1 from larsgrefer/feature/java5
Update the code to Java 5 features
Diffstat (limited to 'runtime')
9 files changed, 35 insertions, 35 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..b953fa1ce 100644 --- a/runtime/src/main/java/org/aspectj/internal/lang/reflect/StringToType.java +++ b/runtime/src/main/java/org/aspectj/internal/lang/reflect/StringToType.java @@ -40,7 +40,7 @@ public class StringToType { public static Type stringToType(String typeName, Class classScope) throws ClassNotFoundException { try { - if (typeName.indexOf("<") == -1) { + if (!typeName.contains("<")) { return AjTypeSystem.getAjType(Class.forName(typeName,false,classScope.getClassLoader())); } else { return makeParameterizedType(typeName,classScope); @@ -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/lang/Aspects.java b/runtime/src/main/java/org/aspectj/lang/Aspects.java index 726b7ed63..ecc388bdb 100644 --- a/runtime/src/main/java/org/aspectj/lang/Aspects.java +++ b/runtime/src/main/java/org/aspectj/lang/Aspects.java @@ -94,7 +94,7 @@ public class Aspects { */ public static boolean hasAspect(Class<?> aspectClass) throws NoAspectBoundException { try { - return ((Boolean)getSingletonOrThreadHasAspect(aspectClass).invoke(null, EMPTY_OBJECT_ARRAY)).booleanValue(); + return (Boolean) getSingletonOrThreadHasAspect(aspectClass).invoke(null, EMPTY_OBJECT_ARRAY); } catch (Exception e) { return false; } @@ -108,7 +108,7 @@ public class Aspects { */ public static boolean hasAspect(Class<?> aspectClass, Object perObject) throws NoAspectBoundException { try { - return ((Boolean)getPerObjectHasAspect(aspectClass).invoke(null, new Object[]{perObject})).booleanValue(); + return (Boolean) getPerObjectHasAspect(aspectClass).invoke(null, new Object[]{perObject}); } catch (Exception e) { return false; } @@ -122,7 +122,7 @@ public class Aspects { */ public static boolean hasAspect(Class<?> aspectClass, Class<?> perTypeWithin) throws NoAspectBoundException { try { - return ((Boolean)getPerTypeWithinHasAspect(aspectClass).invoke(null, new Object[]{perTypeWithin})).booleanValue(); + return (Boolean) getPerTypeWithinHasAspect(aspectClass).invoke(null, new Object[]{perTypeWithin}); } catch (Exception e) { return false; } diff --git a/runtime/src/main/java/org/aspectj/lang/Aspects14.java b/runtime/src/main/java/org/aspectj/lang/Aspects14.java index b59374d76..4ddb6b123 100644 --- a/runtime/src/main/java/org/aspectj/lang/Aspects14.java +++ b/runtime/src/main/java/org/aspectj/lang/Aspects14.java @@ -95,7 +95,7 @@ public class Aspects14 { */ public static boolean hasAspect(Class aspectClass) throws NoAspectBoundException { try { - return ((Boolean)getSingletonOrThreadHasAspect(aspectClass).invoke(null, EMPTY_OBJECT_ARRAY)).booleanValue(); + return (Boolean) getSingletonOrThreadHasAspect(aspectClass).invoke(null, EMPTY_OBJECT_ARRAY); } catch (Exception e) { return false; } @@ -110,7 +110,7 @@ public class Aspects14 { */ public static boolean hasAspect(Class aspectClass, Object perObject) throws NoAspectBoundException { try { - return ((Boolean)getPerObjectHasAspect(aspectClass).invoke(null, new Object[]{perObject})).booleanValue(); + return (Boolean) getPerObjectHasAspect(aspectClass).invoke(null, new Object[]{perObject}); } catch (Exception e) { return false; } @@ -125,7 +125,7 @@ public class Aspects14 { */ public static boolean hasAspect(Class aspectClass, Class perTypeWithin) throws NoAspectBoundException { try { - return ((Boolean)getPerTypeWithinHasAspect(aspectClass).invoke(null, new Object[]{perTypeWithin})).booleanValue(); + return (Boolean) getPerTypeWithinHasAspect(aspectClass).invoke(null, new Object[]{perTypeWithin}); } catch (Exception e) { return false; } diff --git a/runtime/src/main/java/org/aspectj/runtime/internal/Conversions.java b/runtime/src/main/java/org/aspectj/runtime/internal/Conversions.java index 13e8d9edd..0d784266b 100644 --- a/runtime/src/main/java/org/aspectj/runtime/internal/Conversions.java +++ b/runtime/src/main/java/org/aspectj/runtime/internal/Conversions.java @@ -20,25 +20,25 @@ public final class Conversions { // we might want to keep a cache of small integers around public static Object intObject(int i) { - return new Integer(i); + return i; } public static Object shortObject(short i) { - return new Short(i); + return i; } public static Object byteObject(byte i) { - return new Byte(i); + return i; } public static Object charObject(char i) { - return new Character(i); + return i; } public static Object longObject(long i) { - return new Long(i); + return i; } public static Object floatObject(float i) { - return new Float(i); + return i; } public static Object doubleObject(double i) { - return new Double(i); + return i; } public static Object booleanObject(boolean i) { return i; @@ -112,7 +112,7 @@ public final class Conversions { if (o == null) { return 0; } else if (o instanceof Character) { - return ((Character)o).charValue(); + return (Character) o; } else { throw new ClassCastException(o.getClass().getName() + " can not be converted to char"); @@ -122,7 +122,7 @@ public final class Conversions { if (o == null) { return false; } else if (o instanceof Boolean) { - return ((Boolean)o).booleanValue(); + return (Boolean) o; } else { throw new ClassCastException(o.getClass().getName() + " can not be converted to boolean"); 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/AjTypeTest.java b/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeTest.java index 542de36d5..9ddb5c0dc 100644 --- a/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeTest.java +++ b/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeTest.java @@ -139,8 +139,8 @@ public class AjTypeTest extends TestCase { assertEquals(2,fooTypes.length); // Alex -> Adrian: looks like you can not make assumption on the ordering String s = " " + fooTypes[0].getName() + " " + fooTypes[1].getName(); - assertTrue(s.indexOf(" org.aspectj.internal.lang.reflect.Foo$Z") >= 0); - assertTrue(s.indexOf(" org.aspectj.internal.lang.reflect.Foo$XX") >= 0); + assertTrue(s.contains(" org.aspectj.internal.lang.reflect.Foo$Z")); + assertTrue(s.contains(" org.aspectj.internal.lang.reflect.Foo$XX")); } public void testGetConstructor() throws Exception { diff --git a/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeWithAspectsTest.java b/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeWithAspectsTest.java index af72d26f5..5431a7457 100644 --- a/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeWithAspectsTest.java +++ b/runtime/src/test/java/org/aspectj/internal/lang/reflect/AjTypeWithAspectsTest.java @@ -146,10 +146,10 @@ 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(); - } - assertTrue(match.indexOf("aMethod") >=0); + for (Method m : ms) { + match = match + "--" + m.getName(); + } + assertTrue(match.contains("aMethod")); } public void testGetDeclaredPointcut() throws Exception { @@ -200,8 +200,8 @@ public class AjTypeWithAspectsTest extends TestCase { assertEquals(2,pcs.length); // AV was corrupted, cannot rely on ordering String match = "simpleAspectMethodExecution--simpleAspectCall"; - assertTrue(match.indexOf(pcs[0].getName()) >= 0); - assertTrue(match.indexOf(pcs[1].getName()) >= 0); + assertTrue(match.contains(pcs[0].getName())); + assertTrue(match.contains(pcs[1].getName())); } public void testGetPointcuts() { diff --git a/runtime/src/test/java/org/aspectj/runtime/RuntimeTest.java b/runtime/src/test/java/org/aspectj/runtime/RuntimeTest.java index a908a8ae0..2eb92e97b 100644 --- a/runtime/src/test/java/org/aspectj/runtime/RuntimeTest.java +++ b/runtime/src/test/java/org/aspectj/runtime/RuntimeTest.java @@ -69,9 +69,9 @@ public class RuntimeTest extends TestCase { static void checkSoftExceptionString(String s) { - assertTrue(-1 != s.indexOf("SoftException")); - assertTrue(-1 != s.indexOf("Caused by: java.lang.Error")); - assertTrue(-1 != s.indexOf("xyz")); - assertTrue(-1 != s.indexOf("testSoftExceptionPrintStackTrace")); + assertTrue(s.contains("SoftException")); + assertTrue(s.contains("Caused by: java.lang.Error")); + assertTrue(s.contains("xyz")); + assertTrue(s.contains("testSoftExceptionPrintStackTrace")); } } |