From 87014ebdc6aedf4fef7d8bced8419634b20a5dd5 Mon Sep 17 00:00:00 2001 From: avasseur Date: Mon, 19 Dec 2005 14:18:43 +0000 Subject: [PATCH] no-arg ctor test for @decp --- .../aspectj/weaver/bcel/AtAjAttributes.java | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) 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( -- 2.39.5