You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2009/06/15 08:24:14 UTC

svn commit: r784666 - in /felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om: Component.java Reference.java

Author: cziegeler
Date: Mon Jun 15 06:24:14 2009
New Revision: 784666

URL: http://svn.apache.org/viewvc?rev=784666&view=rev
Log:
FELIX-1229 : Correct handling method visibility and warnings 

Modified:
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java?rev=784666&r1=784665&r2=784666&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java Mon Jun 15 06:24:14 2009
@@ -381,7 +381,7 @@
                         JavaMethod found = method;
                         final JavaMethod[] methods = javaClass.getMethods();
                         int i = 0;
-                        while ( i < methods.length && found == null ) {
+                        while ( i < methods.length ) {
                             if ( methodName.equals(methods[i].getName()) ) {
 
                                 if ( methods[i].getParameters().length == 0 ) {
@@ -400,7 +400,12 @@
                                         }
                                     }
                                     if ( valid ) {
-                                        found = methods[i];
+                                        if ( found == null ) {
+                                            found = methods[i];
+                                        } else {
+                                            // print warning
+                                            iLog.addWarning(this.getMessage("Lifecycle method " + methods[i].getName() + " occurs several times with different matching signature."));
+                                        }
                                     }
                                 }
                             }
@@ -419,7 +424,6 @@
                 final JavaMethod[] methods = javaClass.getMethods();
                 for(int i=0; i<methods.length; i++) {
                     if ( methodName.equals(methods[i].getName()) ) {
-
                         if ( methods[i].getParameters().length != 1 ) {
                             iLog.addWarning(this.getMessage("Lifecycle method " + methods[i].getName() + " has wrong number of arguments"));
                         } else {
@@ -429,7 +433,8 @@
                 }
             }
         }
-        if ( method != null ) {
+        // method must be protected for version 1.0
+        if ( method != null && specVersion == Constants.VERSION_1_0) {
             // check protected
             if (method.isPublic()) {
                 iLog.addWarning(this.getMessage("Lifecycle method " + method.getName() + " should be declared protected"));

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java?rev=784666&r1=784665&r2=784666&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java Mon Jun 15 06:24:14 2009
@@ -230,13 +230,15 @@
             return null;
         }
 
-        if (method.isPublic()) {
-            iLog.addWarning(this.getMessage("Method " + method.getName() + " should be declared protected"));
-        } else if (!method.isProtected()) {
-            iLog.addError(this.getMessage("Method " + method.getName() + " has wrong qualifier, public or protected required"));
-            return null;
+        // method needs to be protected for 1.0
+        if ( specVersion == Constants.VERSION_1_0 ) {
+            if (method.isPublic()) {
+                iLog.addWarning(this.getMessage("Method " + method.getName() + " should be declared protected"));
+            } else if (!method.isProtected()) {
+                iLog.addError(this.getMessage("Method " + method.getName() + " has wrong qualifier, public or protected required"));
+                return null;
+            }
         }
-
         return method.getName();
     }