]> source.dussan.org Git - aspectj.git/commitdiff
no-arg ctor test for @decp
authoravasseur <avasseur>
Mon, 19 Dec 2005 14:18:43 +0000 (14:18 +0000)
committeravasseur <avasseur>
Mon, 19 Dec 2005 14:18:43 +0000 (14:18 +0000)
weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java

index 9297f1d16819632965f4f062d9df89806c73cbe5..b6f30374fe726801e000e1b9f1a2cc8895a18909 100644 (file)
@@ -693,8 +693,34 @@ public class AtAjAttributes {
                         defaultImplClassName = UnresolvedType.forSignature(defaultImpl.getClassString()).getName();
                         if (defaultImplClassName.equals("org.aspectj.lang.annotation.DeclareParents")) {
                             defaultImplClassName = null;
+                        } else {
+                            // check public no arg ctor
+                            ResolvedType impl = struct.enclosingType.getWorld().resolve(
+                                    defaultImplClassName,
+                                    false
+                            );
+                            ResolvedMember[] mm  = impl.getDeclaredMethods();
+                            boolean hasNoCtorOrANoArgOne = true;
+                            for (int i = 0; i < mm.length; i++) {
+                                ResolvedMember resolvedMember = mm[i];
+                                if (resolvedMember.getName().equals("<init>")) {
+                                    hasNoCtorOrANoArgOne = false;
+                                    if (resolvedMember.getParameterTypes().length == 0
+                                        && resolvedMember.isPublic()) {
+                                        hasNoCtorOrANoArgOne = true;
+                                    }
+                                }
+                                if (hasNoCtorOrANoArgOne) {
+                                    break;
+                                }
+                            }
+                            if (!hasNoCtorOrANoArgOne) {
+                                reportError("@DeclareParents: defaultImpl=\""
+                                            + defaultImplClassName
+                                            + "\" has no public no-arg constructor", struct);
+                            }
                         }
-                        //TODO check public no arg ctor
+
                     }
 
                     // then iterate on field interface hierarchy (not object)
@@ -709,7 +735,7 @@ public class AtAjAttributes {
                                 return false;
                             }
                             hasAtLeastOneMethod = true;
-                            
+
                             struct.ajAttributes.add(
                                     new AjAttribute.TypeMunger(
                                             new MethodDelegateTypeMunger(