summaryrefslogtreecommitdiffstats
path: root/aspectj5rt
diff options
context:
space:
mode:
authoravasseur <avasseur>2005-10-17 10:49:11 +0000
committeravasseur <avasseur>2005-10-17 10:49:11 +0000
commitbb2d44016148994e99f8a2389754b69f18b710b2 (patch)
treeaf8d62f1f9df15f44b915be60b221a908cfc9d49 /aspectj5rt
parent0b5a5420704f7e32509fffaef66d8c94dcedcf17 (diff)
downloadaspectj-bb2d44016148994e99f8a2389754b69f18b710b2.tar.gz
aspectj-bb2d44016148994e99f8a2389754b69f18b710b2.zip
implement @AspectJ ITD @DeclareParents and @DeclareImplements
changed AjType as ITD field is meaningless (as @AJ ITD is interface driven)
Diffstat (limited to 'aspectj5rt')
-rw-r--r--aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java153
-rw-r--r--aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareImplements.java31
-rw-r--r--aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareParents.java2
3 files changed, 138 insertions, 48 deletions
diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java
index ca179ad6d..747902e3e 100644
--- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java
+++ b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java
@@ -658,42 +658,72 @@ public class AjTypeImpl<T> implements AjType<T> {
private void addAnnotationStyleITDMethods(List<InterTypeMethodDeclaration> toList, boolean publicOnly) {
if (isAspect()) {
- Class<?>[] classes = clazz.getDeclaredClasses();
- for(Class<?> c : classes) {
- if (c.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)) {
- if (c.getInterfaces().length == 0) continue;
- AjType<?> targetType = AjTypeSystem.getAjType((Class<?>)c.getInterfaces()[0]);
- Method[] meths = c.getDeclaredMethods();
- for (Method m : meths) {
- if (!Modifier.isPublic(m.getModifiers()) && publicOnly) continue;
- InterTypeMethodDeclaration itdm =
- new InterTypeMethodDeclarationImpl(
- this,targetType,m);
- toList.add(itdm);
- }
- }
- }
+ for (Field f : clazz.getDeclaredFields()) {
+ if (!f.getType().isInterface()) continue;
+ if (!Modifier.isPublic(f.getModifiers()) || !Modifier.isStatic(f.getModifiers())) continue;
+ if (f.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)) {
+ for (Method itdM : f.getType().getDeclaredMethods()) {
+ if (!Modifier.isPublic(itdM.getModifiers()) && publicOnly) continue;
+ InterTypeMethodDeclaration itdm = new InterTypeMethodDeclarationImpl(
+ this, AjTypeSystem.getAjType(f.getType()), itdM
+ );
+ toList.add(itdm);
+ }
+ }
+ }
+// Class<?>[] classes = clazz.getDeclaredClasses();
+// for(Class<?> c : classes) {
+// if (c.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)) {
+// if (c.getInterfaces().length == 0) continue;
+// AjType<?> targetType = AjTypeSystem.getAjType((Class<?>)c.getInterfaces()[0]);
+// Method[] meths = c.getDeclaredMethods();
+// for (Method m : meths) {
+// if (!Modifier.isPublic(m.getModifiers()) && publicOnly) continue;
+// InterTypeMethodDeclaration itdm =
+// new InterTypeMethodDeclarationImpl(
+// this,targetType,m);
+// toList.add(itdm);
+// }
+// }
+// }
}
}
private void addAnnotationStyleITDFields(List<InterTypeFieldDeclaration> toList, boolean publicOnly) {
- if (isAspect()) {
- Class<?>[] classes = clazz.getDeclaredClasses();
- for(Class<?> c : classes) {
- if (c.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)) {
- if (c.getInterfaces().length == 0) continue;
- AjType<?> targetType = AjTypeSystem.getAjType((Class<?>)c.getInterfaces()[0]);
- Field[] fields = c.getDeclaredFields();
- for (Field f : fields) {
- if (!Modifier.isPublic(f.getModifiers()) && publicOnly) continue;
- InterTypeFieldDeclaration itdf =
- new InterTypeFieldDeclarationImpl(
- this,targetType,f);
- toList.add(itdf);
- }
- }
- }
- }
+ return;
+ //AV: I think it is meaningless
+ //@AJ decp is interface driven ie no field
+// if (isAspect()) {
+// for (Field f : clazz.getDeclaredFields()) {
+// if (!f.getType().isInterface()) continue;
+// if (!Modifier.isPublic(f.getModifiers()) || !Modifier.isStatic(f.getModifiers())) continue;
+// if (f.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)) {
+// for (Field itdF : f.getType().getDeclaredFields()) {
+// if (!Modifier.isPublic(itdF.getModifiers()) && publicOnly) continue;
+// InterTypeFieldDeclaration itdf = new InterTypeFieldDeclarationImpl(
+// this, AjTypeSystem.getAjType(f.getType()), itdF
+// );
+// toList.add(itdf);
+// }
+// }
+// }
+//---old impl.
+// Class<?>[] classes = clazz.getDeclaredClasses();
+// for(Class<?> c : classes) {
+// if (c.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)) {
+// if (c.getInterfaces().length == 0) continue;
+// AjType<?> targetType = AjTypeSystem.getAjType((Class<?>)c.getInterfaces()[0]);
+// Field[] fields = c.getDeclaredFields();
+// for (Field f : fields) {
+// if (!Modifier.isPublic(f.getModifiers()) && publicOnly) continue;
+// InterTypeFieldDeclaration itdf =
+// new InterTypeFieldDeclarationImpl(
+// this,targetType,f);
+// toList.add(itdf);
+// }
+// }
+// }
+// }
}
/* (non-Javadoc)
* @see org.aspectj.lang.reflect.AjType#getDeclaredITDConstructor(java.lang.Class, java.lang.Class...)
@@ -963,21 +993,50 @@ public class AjTypeImpl<T> implements AjType<T> {
}
private void addAnnotationStyleDeclareParents(List<DeclareParents> toList) {
- Class<?>[] classes = clazz.getDeclaredClasses();
- for (Class<?> c : classes) {
- if (c.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)) {
- org.aspectj.lang.annotation.DeclareParents ann = c.getAnnotation(org.aspectj.lang.annotation.DeclareParents.class);
- if (c.getInterfaces().length == 0) continue;
- String parentType = c.getInterfaces()[0].getName();
- DeclareParentsImpl decp = new DeclareParentsImpl(
- ann.value(),
- parentType,
- false,
- this
- );
- toList.add(decp);
- }
- }
+ for (Field f : clazz.getDeclaredFields()) {
+ if (f.isAnnotationPresent(org.aspectj.lang.annotation.DeclareImplements.class)) {
+ if (!f.getType().isInterface()) continue;
+ org.aspectj.lang.annotation.DeclareImplements ann = f.getAnnotation(org.aspectj.lang.annotation.DeclareImplements.class);
+ String parentType = f.getType().getName();
+ DeclareParentsImpl decp = new DeclareParentsImpl(
+ ann.value(),
+ parentType,
+ false,
+ this
+ );
+ toList.add(decp);
+ }
+ if (f.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)
+ && Modifier.isStatic(f.getModifiers())
+ && Modifier.isPublic(f.getModifiers())) {
+ if (!f.getType().isInterface()) continue;
+ org.aspectj.lang.annotation.DeclareParents ann = f.getAnnotation(org.aspectj.lang.annotation.DeclareParents.class);
+ String parentType = f.getType().getName();
+ DeclareParentsImpl decp = new DeclareParentsImpl(
+ ann.value(),
+ parentType,
+ false,
+ this
+ );
+ toList.add(decp);
+ }
+ }
+//
+// Class<?>[] classes = clazz.getDeclaredClasses();
+// for (Class<?> c : classes) {
+// if (c.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)) {
+// org.aspectj.lang.annotation.DeclareParents ann = c.getAnnotation(org.aspectj.lang.annotation.DeclareParents.class);
+// if (c.getInterfaces().length == 0) continue;
+// String parentType = c.getInterfaces()[0].getName();
+// DeclareParentsImpl decp = new DeclareParentsImpl(
+// ann.value(),
+// parentType,
+// false,
+// this
+// );
+// toList.add(decp);
+// }
+// }
}
/* (non-Javadoc)
diff --git a/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareImplements.java b/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareImplements.java
new file mode 100644
index 000000000..dbb1bf1d9
--- /dev/null
+++ b/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareImplements.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * initial implementation Adrian Colyer
+ *******************************************************************************/
+package org.aspectj.lang.annotation;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Declare parents mixin annotation
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+public @interface DeclareImplements {
+
+ /**
+ * The target types expression
+ */
+ String value();
+
+}
diff --git a/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareParents.java b/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareParents.java
index 3dec04f27..e26e8c778 100644
--- a/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareParents.java
+++ b/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareParents.java
@@ -20,7 +20,7 @@ import java.lang.annotation.RetentionPolicy;
* Declare parents mixin annotation
*/
@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
+@Target(ElementType.FIELD)
public @interface DeclareParents {
/**