diff options
author | acolyer <acolyer> | 2005-03-09 11:16:44 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-03-09 11:16:44 +0000 |
commit | 89ef2959b73dad42d0640d91964005cbf654b247 (patch) | |
tree | 4f11a3d0ffd81c5ace193acb29a2152468eeeb6c /runtime/src | |
parent | ef868243d36ab20062e7aae6828bc17987a018a5 (diff) | |
download | aspectj-89ef2959b73dad42d0640d91964005cbf654b247.tar.gz aspectj-89ef2959b73dad42d0640d91964005cbf654b247.zip |
enhancements to signature to support getAccessibleMember() (see ajdk:annotations)
Diffstat (limited to 'runtime/src')
7 files changed, 88 insertions, 0 deletions
diff --git a/runtime/src/org/aspectj/lang/reflect/MemberSignature.java b/runtime/src/org/aspectj/lang/reflect/MemberSignature.java index 31f21df7d..fb267e080 100644 --- a/runtime/src/org/aspectj/lang/reflect/MemberSignature.java +++ b/runtime/src/org/aspectj/lang/reflect/MemberSignature.java @@ -14,7 +14,10 @@ package org.aspectj.lang.reflect; +import java.lang.reflect.AccessibleObject; + import org.aspectj.lang.Signature; public interface MemberSignature extends Signature { + AccessibleObject getAccessibleObject(); } diff --git a/runtime/src/org/aspectj/runtime/reflect/AdviceSignatureImpl.java b/runtime/src/org/aspectj/runtime/reflect/AdviceSignatureImpl.java index 7efe2cd7d..74bf6e0e4 100644 --- a/runtime/src/org/aspectj/runtime/reflect/AdviceSignatureImpl.java +++ b/runtime/src/org/aspectj/runtime/reflect/AdviceSignatureImpl.java @@ -14,6 +14,8 @@ package org.aspectj.runtime.reflect; +import java.lang.reflect.AccessibleObject; + import org.aspectj.lang.reflect.AdviceSignature; class AdviceSignatureImpl extends CodeSignatureImpl implements AdviceSignature { @@ -52,4 +54,16 @@ class AdviceSignatureImpl extends CodeSignatureImpl implements AdviceSignature { sm.addThrows(buf, getExceptionTypes()); return buf.toString(); } + + /* (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 + } + return null; + } } diff --git a/runtime/src/org/aspectj/runtime/reflect/ConstructorSignatureImpl.java b/runtime/src/org/aspectj/runtime/reflect/ConstructorSignatureImpl.java index 520cfdf09..12ac6ba8e 100644 --- a/runtime/src/org/aspectj/runtime/reflect/ConstructorSignatureImpl.java +++ b/runtime/src/org/aspectj/runtime/reflect/ConstructorSignatureImpl.java @@ -14,6 +14,8 @@ package org.aspectj.runtime.reflect; +import java.lang.reflect.AccessibleObject; + import org.aspectj.lang.reflect.ConstructorSignature; class ConstructorSignatureImpl extends CodeSignatureImpl implements ConstructorSignature { @@ -37,4 +39,16 @@ class ConstructorSignatureImpl extends CodeSignatureImpl implements ConstructorS sm.addThrows(buf, getExceptionTypes()); return buf.toString(); } + + /* (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 + } + return null; + } } diff --git a/runtime/src/org/aspectj/runtime/reflect/FieldSignatureImpl.java b/runtime/src/org/aspectj/runtime/reflect/FieldSignatureImpl.java index c56ca5212..3c14e4050 100644 --- a/runtime/src/org/aspectj/runtime/reflect/FieldSignatureImpl.java +++ b/runtime/src/org/aspectj/runtime/reflect/FieldSignatureImpl.java @@ -14,6 +14,8 @@ package org.aspectj.runtime.reflect; +import java.lang.reflect.AccessibleObject; + import org.aspectj.lang.reflect.FieldSignature; public class FieldSignatureImpl extends MemberSignatureImpl implements FieldSignature { @@ -45,4 +47,16 @@ public class FieldSignatureImpl extends MemberSignatureImpl implements FieldSign buf.append(getName()); return buf.toString(); } + + /* (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 + } + return null; + } } diff --git a/runtime/src/org/aspectj/runtime/reflect/InitializerSignatureImpl.java b/runtime/src/org/aspectj/runtime/reflect/InitializerSignatureImpl.java index 740ec07f3..7b5e41683 100644 --- a/runtime/src/org/aspectj/runtime/reflect/InitializerSignatureImpl.java +++ b/runtime/src/org/aspectj/runtime/reflect/InitializerSignatureImpl.java @@ -16,6 +16,7 @@ package org.aspectj.runtime.reflect; import org.aspectj.lang.reflect.InitializerSignature; +import java.lang.reflect.AccessibleObject; import java.lang.reflect.Modifier; class InitializerSignatureImpl extends CodeSignatureImpl implements InitializerSignature { @@ -40,4 +41,16 @@ class InitializerSignatureImpl extends CodeSignatureImpl implements InitializerS buf.append(getName()); return buf.toString(); } + + /* (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 + } + return null; + } } diff --git a/runtime/src/org/aspectj/runtime/reflect/MemberSignatureImpl.java b/runtime/src/org/aspectj/runtime/reflect/MemberSignatureImpl.java index 66c535a5c..09ebba7ff 100644 --- a/runtime/src/org/aspectj/runtime/reflect/MemberSignatureImpl.java +++ b/runtime/src/org/aspectj/runtime/reflect/MemberSignatureImpl.java @@ -14,9 +14,13 @@ 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); } @@ -24,4 +28,16 @@ abstract class MemberSignatureImpl extends SignatureImpl implements MemberSignat public MemberSignatureImpl(String stringRep) { 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 7e667425d..51ba06237 100644 --- a/runtime/src/org/aspectj/runtime/reflect/MethodSignatureImpl.java +++ b/runtime/src/org/aspectj/runtime/reflect/MethodSignatureImpl.java @@ -14,6 +14,8 @@ package org.aspectj.runtime.reflect; +import java.lang.reflect.AccessibleObject; + import org.aspectj.lang.reflect.MethodSignature; class MethodSignatureImpl extends CodeSignatureImpl implements MethodSignature { @@ -50,4 +52,16 @@ class MethodSignatureImpl extends CodeSignatureImpl implements MethodSignature { sm.addThrows(buf, getExceptionTypes()); return buf.toString(); } + + /* (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 + } + return null; + } } |