From: avasseur Date: Mon, 19 Dec 2005 14:18:43 +0000 (+0000) Subject: no-arg ctor test for @decp X-Git-Tag: POST_MEMORY_CHANGES~220 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=87014ebdc6aedf4fef7d8bced8419634b20a5dd5;p=aspectj.git no-arg ctor test for @decp --- diff --git a/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java b/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java index 9297f1d16..b6f30374f 100644 --- a/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java +++ b/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java @@ -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("")) { + 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(