You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by cs...@apache.org on 2006/10/26 23:58:52 UTC

svn commit: r468164 - in /beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator: AptControlClient.java AptControlImplementation.java AptType.java apt/strings.properties

Author: cschoett
Date: Thu Oct 26 14:58:51 2006
New Revision: 468164

URL: http://svn.apache.org/viewvc?view=rev&rev=468164
Log:
Fix for BEEHIVE-1133, updated AptControlClient and AptControlImplementation to check methods annotated with EventHandler annotation to report an error if that method is private.  No new tests added since the end result either way is a compilation failure.

Controls DRTs: passed.

Modified:
    beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlClient.java
    beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlImplementation.java
    beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptType.java
    beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/strings.properties

Modified: beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlClient.java
URL: http://svn.apache.org/viewvc/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlClient.java?view=diff&rev=468164&r1=468163&r2=468164
==============================================================================
--- beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlClient.java (original)
+++ beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlClient.java Thu Oct 26 14:58:51 2006
@@ -240,6 +240,15 @@
                 continue;
 
             //
+            // EventHandler annotations on private methods cause compilation error.
+            //
+            if (isPrivateMethod(clientMethod))
+            {
+                _ap.printError( clientMethod, "eventhandler.method.is.private");
+                continue;
+            }
+
+            //
             // If found, we must actually read the value using an AnnotationMirror, since it
             // contains a Class element (eventSet) that cannot be loaded
             //

Modified: beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlImplementation.java
URL: http://svn.apache.org/viewvc/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlImplementation.java?view=diff&rev=468164&r1=468163&r2=468164
==============================================================================
--- beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlImplementation.java (original)
+++ beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlImplementation.java Thu Oct 26 14:58:51 2006
@@ -313,6 +313,15 @@
             if (implMethod.getAnnotation(EventHandler.class) == null ||
                 implMethod.toString().equals("<clinit>()"))
                 continue;
+            
+            //
+            // EventHandler annotations on private methods cause compilation error.
+            //
+            if (isPrivateMethod(implMethod))
+            {
+                _ap.printError(implMethod, "eventhandler.method.is.private");
+                continue;
+            }
 
             //
             // If found, we must actually read the value using an AnnotationMirror, since it

Modified: beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptType.java
URL: http://svn.apache.org/viewvc/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptType.java?view=diff&rev=468164&r1=468163&r2=468164
==============================================================================
--- beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptType.java (original)
+++ beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptType.java Thu Oct 26 14:58:51 2006
@@ -22,6 +22,8 @@
 
 import com.sun.mirror.declaration.TypeDeclaration;
 import com.sun.mirror.declaration.TypeParameterDeclaration;
+import com.sun.mirror.declaration.MethodDeclaration;
+import com.sun.mirror.declaration.Modifier;
 
 /**
  * The AptType abstract class defines a base set of methods that are generally available
@@ -35,6 +37,23 @@
     protected void setDeclaration(TypeDeclaration typeDecl)
     {
         _typeDecl = typeDecl;
+    }
+
+    /**
+     * Checks a MethodDeclaration for a 'private' modifier.
+     *
+     * @param md MethodDeclaration to check.
+     * @return true if private modifier is present.
+     */
+    protected boolean isPrivateMethod(MethodDeclaration md)
+    {
+        Collection<Modifier> modifiers = md.getModifiers();
+        for (Modifier m : modifiers)
+        {
+            if (m.compareTo(Modifier.PRIVATE) == 0)
+                return true;
+        }
+        return false;
     }
 
     /**

Modified: beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/strings.properties
URL: http://svn.apache.org/viewvc/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/strings.properties?view=diff&rev=468164&r1=468163&r2=468164
==============================================================================
--- beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/strings.properties (original)
+++ beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/strings.properties Thu Oct 26 14:58:51 2006
@@ -142,6 +142,9 @@
 eventhandler.eventset.not.found=\
 Cannot find EventSet interface: {0}.
 
+eventhandler.method.is.private=\
+Methods annotated with the EventHandler annotation can not be private.
+
 eventhandler.method.not.found=\
 No event method with matching name and signature found on EventSet: {0}.