FELIX-1229 : Correct handling method visibility and warnings 

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@784666 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java
index dbec228..e7dccf7 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java
@@ -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"));
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java
index b953725..cc8d538 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java
@@ -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();
     }