FELIX-4957 : [DS][RFC-212] Various issues with field references

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1691133 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/helper/FieldHandler.java b/scr/src/main/java/org/apache/felix/scr/impl/helper/FieldHandler.java
index d7244b2..322c8b8 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/helper/FieldHandler.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/helper/FieldHandler.java
@@ -275,6 +275,15 @@
         final Class<?> referenceType = ClassUtils.getClassFromComponentClassLoader(
                 this.componentClass, metadata.getInterface(), logger);
 
+        // ignore static fields
+        if ( Modifier.isStatic(f.getModifiers()))
+        {
+            logger.log( LogService.LOG_ERROR, "Field {0} in component {1} must not be static", new Object[]
+                    {metadata.getField(), this.componentClass}, null );
+        	valueType = ParamType.ignore;
+        	return f;
+        }
+
         // unary reference
         if ( !metadata.isMultiple() )
         {
@@ -380,6 +389,13 @@
                 }
             }
         }
+        // static references only allowed for replace strategy
+        if ( metadata.isStatic() && !metadata.isReplace() )
+        {
+            logger.log( LogService.LOG_ERROR, "Update strategy for field {0} in component {1} only allowed for non static field references.", new Object[]
+                    {metadata.getField(), this.componentClass}, null );
+            valueType = ParamType.ignore;
+        }
         return f;
     }
 
@@ -706,7 +722,7 @@
         // no static fields
         if ( Modifier.isStatic( mod ) )
         {
-            return false;
+            return true;
         }
 
         // accept public and protected fields
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/metadata/ReferenceMetadata.java b/scr/src/main/java/org/apache/felix/scr/impl/metadata/ReferenceMetadata.java
index bac95ea..d92360e 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/metadata/ReferenceMetadata.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/metadata/ReferenceMetadata.java
@@ -721,15 +721,6 @@
                     throw componentMetadata.validationFailure( "Field value type must be one of " + FIELD_VALUE_TYPE_VALID );
                 }
             }
-
-            // static references only allow replace strategy
-            if ( m_isStatic )
-            {
-                if ( ! m_field_option.equals(FIELD_STRATEGY_REPLACE) )
-                {
-                    throw componentMetadata.validationFailure( "Field strategy update not allowed for static field references." );
-                }
-            }
         }
 
         m_validated = true;