From: acolyer Date: Thu, 10 Mar 2005 10:55:05 +0000 (+0000) Subject: remove dependency on 1.2 API - runtime libs must work at 1.1 level X-Git-Tag: V1_5_0M2~96 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=41f7022722208af3bde9cb4b7fe6c5d98915c24d;p=aspectj.git remove dependency on 1.2 API - runtime libs must work at 1.1 level --- diff --git a/runtime/src/org/aspectj/lang/reflect/AdviceSignature.java b/runtime/src/org/aspectj/lang/reflect/AdviceSignature.java index 8afc4e1ac..e88aebbba 100644 --- a/runtime/src/org/aspectj/lang/reflect/AdviceSignature.java +++ b/runtime/src/org/aspectj/lang/reflect/AdviceSignature.java @@ -13,9 +13,11 @@ package org.aspectj.lang.reflect; +import java.lang.reflect.Method; public interface AdviceSignature extends CodeSignature { Class getReturnType(); /* name is consistent with reflection API */ /* before and after always return Void.TYPE */ /* (some around also return Void.Type) */ + Method getAdvice(); } diff --git a/runtime/src/org/aspectj/lang/reflect/ConstructorSignature.java b/runtime/src/org/aspectj/lang/reflect/ConstructorSignature.java index 66ab51397..3aea63dff 100644 --- a/runtime/src/org/aspectj/lang/reflect/ConstructorSignature.java +++ b/runtime/src/org/aspectj/lang/reflect/ConstructorSignature.java @@ -13,6 +13,8 @@ package org.aspectj.lang.reflect; +import java.lang.reflect.Constructor; public interface ConstructorSignature extends CodeSignature { + Constructor getConstructor(); } diff --git a/runtime/src/org/aspectj/lang/reflect/FieldSignature.java b/runtime/src/org/aspectj/lang/reflect/FieldSignature.java index d2973543a..af20d84de 100644 --- a/runtime/src/org/aspectj/lang/reflect/FieldSignature.java +++ b/runtime/src/org/aspectj/lang/reflect/FieldSignature.java @@ -13,7 +13,9 @@ package org.aspectj.lang.reflect; +import java.lang.reflect.Field; public interface FieldSignature extends MemberSignature { public Class getFieldType(); + public Field getField(); } diff --git a/runtime/src/org/aspectj/lang/reflect/InitializerSignature.java b/runtime/src/org/aspectj/lang/reflect/InitializerSignature.java index 2b75f92a6..510a8d288 100644 --- a/runtime/src/org/aspectj/lang/reflect/InitializerSignature.java +++ b/runtime/src/org/aspectj/lang/reflect/InitializerSignature.java @@ -13,5 +13,8 @@ package org.aspectj.lang.reflect; +import java.lang.reflect.Constructor; -public interface InitializerSignature extends CodeSignature { } +public interface InitializerSignature extends CodeSignature { + Constructor getInitializer(); +} diff --git a/runtime/src/org/aspectj/lang/reflect/MemberSignature.java b/runtime/src/org/aspectj/lang/reflect/MemberSignature.java index fb267e080..1dcae6403 100644 --- a/runtime/src/org/aspectj/lang/reflect/MemberSignature.java +++ b/runtime/src/org/aspectj/lang/reflect/MemberSignature.java @@ -14,10 +14,9 @@ package org.aspectj.lang.reflect; -import java.lang.reflect.AccessibleObject; - import org.aspectj.lang.Signature; public interface MemberSignature extends Signature { - AccessibleObject getAccessibleObject(); + // AccessibleObject is a 1.2 API, we run on 1.1... (thanks Wes for catching this) + //AccessibleObject getAccessibleObject(); } diff --git a/runtime/src/org/aspectj/lang/reflect/MethodSignature.java b/runtime/src/org/aspectj/lang/reflect/MethodSignature.java index f26d6c504..ab6b0d4f5 100644 --- a/runtime/src/org/aspectj/lang/reflect/MethodSignature.java +++ b/runtime/src/org/aspectj/lang/reflect/MethodSignature.java @@ -13,7 +13,9 @@ package org.aspectj.lang.reflect; +import java.lang.reflect.Method; public interface MethodSignature extends CodeSignature { Class getReturnType(); /* name is consistent with reflection API */ + Method getMethod(); } diff --git a/runtime/src/org/aspectj/runtime/reflect/AdviceSignatureImpl.java b/runtime/src/org/aspectj/runtime/reflect/AdviceSignatureImpl.java index 74bf6e0e4..e814a5add 100644 --- a/runtime/src/org/aspectj/runtime/reflect/AdviceSignatureImpl.java +++ b/runtime/src/org/aspectj/runtime/reflect/AdviceSignatureImpl.java @@ -14,12 +14,13 @@ package org.aspectj.runtime.reflect; -import java.lang.reflect.AccessibleObject; +import java.lang.reflect.Method; import org.aspectj.lang.reflect.AdviceSignature; class AdviceSignatureImpl extends CodeSignatureImpl implements AdviceSignature { Class returnType; + private Method adviceMethod = null; AdviceSignatureImpl(int modifiers, String name, Class declaringType, Class[] parameterTypes, String[] parameterNames, Class[] exceptionTypes, @@ -58,12 +59,14 @@ class AdviceSignatureImpl extends CodeSignatureImpl implements AdviceSignature { /* (non-Javadoc) * @see org.aspectj.runtime.reflect.MemberSignatureImpl#createAccessibleObject() */ - protected AccessibleObject createAccessibleObject() { - try { - return declaringType.getDeclaredMethod(getName(),getParameterTypes()); - } catch (Exception ex) { - ; // nothing we can do, caller will see null + public Method getAdvice() { + if (adviceMethod == null) { + try { + adviceMethod = declaringType.getDeclaredMethod(getName(),getParameterTypes()); + } catch (Exception ex) { + ; // nothing we can do, caller will see null + } } - return null; + return adviceMethod; } } diff --git a/runtime/src/org/aspectj/runtime/reflect/ConstructorSignatureImpl.java b/runtime/src/org/aspectj/runtime/reflect/ConstructorSignatureImpl.java index 12ac6ba8e..b607df629 100644 --- a/runtime/src/org/aspectj/runtime/reflect/ConstructorSignatureImpl.java +++ b/runtime/src/org/aspectj/runtime/reflect/ConstructorSignatureImpl.java @@ -14,11 +14,13 @@ package org.aspectj.runtime.reflect; -import java.lang.reflect.AccessibleObject; +import java.lang.reflect.Constructor; import org.aspectj.lang.reflect.ConstructorSignature; class ConstructorSignatureImpl extends CodeSignatureImpl implements ConstructorSignature { + private Constructor constructor; + ConstructorSignatureImpl(int modifiers, Class declaringType, Class[] parameterTypes, String[] parameterNames, Class[] exceptionTypes) { @@ -43,12 +45,14 @@ class ConstructorSignatureImpl extends CodeSignatureImpl implements ConstructorS /* (non-Javadoc) * @see org.aspectj.runtime.reflect.MemberSignatureImpl#createAccessibleObject() */ - protected AccessibleObject createAccessibleObject() { - try { - return declaringType.getDeclaredConstructor(getParameterTypes()); - } catch (Exception ex) { - ; // nothing we can do, caller will see null + public Constructor getConstructor() { + if (constructor == null) { + try { + constructor = declaringType.getDeclaredConstructor(getParameterTypes()); + } catch (Exception ex) { + ; // nothing we can do, caller will see null + } } - return null; + return constructor; } } diff --git a/runtime/src/org/aspectj/runtime/reflect/FieldSignatureImpl.java b/runtime/src/org/aspectj/runtime/reflect/FieldSignatureImpl.java index 3c14e4050..ff1e6e452 100644 --- a/runtime/src/org/aspectj/runtime/reflect/FieldSignatureImpl.java +++ b/runtime/src/org/aspectj/runtime/reflect/FieldSignatureImpl.java @@ -14,12 +14,13 @@ package org.aspectj.runtime.reflect; -import java.lang.reflect.AccessibleObject; +import java.lang.reflect.Field; import org.aspectj.lang.reflect.FieldSignature; public class FieldSignatureImpl extends MemberSignatureImpl implements FieldSignature { Class fieldType; + private Field field; FieldSignatureImpl(int modifiers, String name, Class declaringType, Class fieldType) @@ -51,12 +52,14 @@ public class FieldSignatureImpl extends MemberSignatureImpl implements FieldSign /* (non-Javadoc) * @see org.aspectj.runtime.reflect.MemberSignatureImpl#createAccessibleObject() */ - protected AccessibleObject createAccessibleObject() { - try { - return declaringType.getDeclaredField(getName()); - } catch (Exception ex) { - ; // nothing we can do, caller will see null + public Field getField() { + if (field == null) { + try { + field = declaringType.getDeclaredField(getName()); + } catch (Exception ex) { + ; // nothing we can do, caller will see null + } } - return null; + return field; } } diff --git a/runtime/src/org/aspectj/runtime/reflect/InitializerSignatureImpl.java b/runtime/src/org/aspectj/runtime/reflect/InitializerSignatureImpl.java index 7b5e41683..dcf1a3131 100644 --- a/runtime/src/org/aspectj/runtime/reflect/InitializerSignatureImpl.java +++ b/runtime/src/org/aspectj/runtime/reflect/InitializerSignatureImpl.java @@ -16,10 +16,12 @@ package org.aspectj.runtime.reflect; import org.aspectj.lang.reflect.InitializerSignature; -import java.lang.reflect.AccessibleObject; +import java.lang.reflect.Constructor; import java.lang.reflect.Modifier; class InitializerSignatureImpl extends CodeSignatureImpl implements InitializerSignature { + private Constructor constructor; + InitializerSignatureImpl(int modifiers, Class declaringType) { super(modifiers, Modifier.isStatic(modifiers) ? "" : "", declaringType, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY); @@ -45,12 +47,14 @@ class InitializerSignatureImpl extends CodeSignatureImpl implements InitializerS /* (non-Javadoc) * @see org.aspectj.runtime.reflect.MemberSignatureImpl#createAccessibleObject() */ - protected AccessibleObject createAccessibleObject() { - try { - return declaringType.getDeclaredConstructor(getParameterTypes()); - } catch (Exception ex) { - ; // nothing we can do, caller will see null + public Constructor getInitializer() { + if (constructor == null) { + try { + constructor = declaringType.getDeclaredConstructor(getParameterTypes()); + } catch (Exception ex) { + ; // nothing we can do, caller will see null + } } - return null; + return constructor; } } diff --git a/runtime/src/org/aspectj/runtime/reflect/MemberSignatureImpl.java b/runtime/src/org/aspectj/runtime/reflect/MemberSignatureImpl.java index 09ebba7ff..c49c016e1 100644 --- a/runtime/src/org/aspectj/runtime/reflect/MemberSignatureImpl.java +++ b/runtime/src/org/aspectj/runtime/reflect/MemberSignatureImpl.java @@ -14,12 +14,9 @@ package org.aspectj.runtime.reflect; -import java.lang.reflect.AccessibleObject; - import org.aspectj.lang.reflect.MemberSignature; abstract class MemberSignatureImpl extends SignatureImpl implements MemberSignature { - protected AccessibleObject accessibleObj = null; MemberSignatureImpl(int modifiers, String name, Class declaringType) { super(modifiers, name, declaringType); @@ -29,15 +26,4 @@ abstract class MemberSignatureImpl extends SignatureImpl implements MemberSignat super(stringRep); } - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.MemberSignature#getAccessibleObject() - */ - public AccessibleObject getAccessibleObject() { - if (accessibleObj == null) { - accessibleObj = createAccessibleObject(); - } - return accessibleObj; - } - - protected abstract AccessibleObject createAccessibleObject(); } diff --git a/runtime/src/org/aspectj/runtime/reflect/MethodSignatureImpl.java b/runtime/src/org/aspectj/runtime/reflect/MethodSignatureImpl.java index 51ba06237..3331df08d 100644 --- a/runtime/src/org/aspectj/runtime/reflect/MethodSignatureImpl.java +++ b/runtime/src/org/aspectj/runtime/reflect/MethodSignatureImpl.java @@ -14,11 +14,12 @@ package org.aspectj.runtime.reflect; -import java.lang.reflect.AccessibleObject; +import java.lang.reflect.Method; import org.aspectj.lang.reflect.MethodSignature; class MethodSignatureImpl extends CodeSignatureImpl implements MethodSignature { + private Method method; Class returnType; MethodSignatureImpl(int modifiers, String name, Class declaringType, @@ -56,12 +57,14 @@ class MethodSignatureImpl extends CodeSignatureImpl implements MethodSignature { /* (non-Javadoc) * @see org.aspectj.lang.reflect.MemberSignature#getAccessibleObject() */ - public AccessibleObject createAccessibleObject() { - try { - return declaringType.getDeclaredMethod(getName(),getParameterTypes()); - } catch (NoSuchMethodException nsmEx) { - ; // nothing we can do, user will see null return + public Method getMethod() { + if (method == null) { + try { + method = declaringType.getDeclaredMethod(getName(),getParameterTypes()); + } catch (NoSuchMethodException nsmEx) { + ; // nothing we can do, user will see null return + } } - return null; + return method; } }