aboutsummaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authoraclement <aclement>2009-03-04 03:00:28 +0000
committeraclement <aclement>2009-03-04 03:00:28 +0000
commitb331fa862e3296cb26b3d6b47a5c8a4dfe2110a8 (patch)
tree63abff10e11932cdf0a612ba5fef5e2e9ae1bce1 /weaver
parent436c81f1fd28a1ffb89933f1f541bd1e323ccd4a (diff)
downloadaspectj-b331fa862e3296cb26b3d6b47a5c8a4dfe2110a8.tar.gz
aspectj-b331fa862e3296cb26b3d6b47a5c8a4dfe2110a8.zip
declaremixin: check signature of factory method
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java b/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java
index c2fb10049..e77ef9313 100644
--- a/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java
+++ b/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java
@@ -829,6 +829,28 @@ public class AtAjAttributes {
}
/**
+ * Return a nicely formatted method string, for example: int X.foo(java.lang.String)
+ */
+ public static String getMethodForMessage(AjAttributeMethodStruct methodstructure) {
+ StringBuffer sb = new StringBuffer();
+ sb.append("Method '");
+ sb.append(methodstructure.method.getReturnType().toString());
+ sb.append(" ").append(methodstructure.enclosingType).append(".").append(methodstructure.method.getName());
+ sb.append("(");
+ Type[] args = methodstructure.method.getArgumentTypes();
+ if (args != null) {
+ for (int t = 0; t < args.length; t++) {
+ if (t > 0) {
+ sb.append(",");
+ }
+ sb.append(args[t].toString());
+ }
+ }
+ sb.append(")'");
+ return sb.toString();
+ }
+
+ /**
* Process any @DeclareMixin annotation.
*
* Example Declaration <br>
@@ -858,6 +880,17 @@ public class AtAjAttributes {
// Return value of the annotated method is the interface or class that the mixin delegate should have
ResolvedType methodReturnType = UnresolvedType.forSignature(annotatedMethod.getReturnType().getSignature()).resolve(world);
+ if (methodReturnType.isPrimitiveType()) {
+ reportError(getMethodForMessage(struct) + ": factory methods for a mixin cannot return void or a primitive type",
+ struct);
+ return false;
+ }
+
+ if (annotatedMethod.getArgumentTypes().length > 1) {
+ reportError(getMethodForMessage(struct) + ": factory methods for a mixin can take a maximum of one parameter", struct);
+ return false;
+ }
+
// The set of interfaces to be mixed in is either:
// supplied as a list in the 'Class[] interfaces' value in the annotation value
// supplied as just the interface return value of the annotated method