Fix FELIX-2779 iPOJO manipulator badly supports custom annotation attributes of type Class


Just applied the provided patch and update the changelog.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1058663 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/manipulator/doc/changelog.txt b/ipojo/manipulator/doc/changelog.txt
index dd40a55..d9972cd 100644
--- a/ipojo/manipulator/doc/changelog.txt
+++ b/ipojo/manipulator/doc/changelog.txt
@@ -1,6 +1,7 @@
 Changes from the 1.6.4 to 1.8.0

 -------------------------------

 ** Bug

+    * [FELIX-2779] - iPOJO manipulator badly supports custom annotation attributes of type Class

     * [FELIX-2664] - Native methods should not be manipulated

 

 ** Improvement

diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/CustomAnnotationVisitor.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/CustomAnnotationVisitor.java
index a5e9f45..e3e14f0 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/CustomAnnotationVisitor.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/CustomAnnotationVisitor.java
@@ -163,8 +163,15 @@
             m_elem.addAttribute(new Attribute(arg0, v));

             return;

         }

+        

         // Attributes are added as normal attributes

-        m_elem.addAttribute(new Attribute(arg0, arg1.toString()));

+        if (!(arg1 instanceof Type)) {

+            m_elem.addAttribute(new Attribute(arg0, arg1.toString()));            

+        } else {

+            // Attributes of type class need a special handling

+            m_elem.addAttribute(new Attribute(arg0, ((Type) arg1).getClassName()));        

+        }

+        

         if (m_root) {

             if (arg0.equals("id")) {

                 m_id = arg1.toString();

@@ -278,9 +285,19 @@
          */

         public void visit(String arg0, Object arg1) {

             if (m_acc == null) {

-                m_acc = "{" + arg1.toString();

+                if (!(arg1 instanceof Type)) {

+                    m_acc = "{" + arg1.toString();            

+                } else {

+                    // Attributes of type class need a special handling

+                    m_acc = "{" + ((Type) arg1).getClassName();

+                }

             } else {

-                m_acc = m_acc + "," + arg1.toString();

+                if (!(arg1 instanceof Type)) {

+                    m_acc = m_acc + "," + arg1.toString();

+                } else {

+                    // Attributes of type class need a special handling

+                    m_acc = m_acc + "," + ((Type) arg1).getClassName();

+                }

             }

         }