Support arrays of reference types as JavaBean properties
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 2ea9f6e..5d88f71 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -7,7 +7,10 @@
 	</properties>

 	<body>

 		<release version="1.5" date="in Mercurial" description="development: improve performance">

-			<action dev="py4fun" type="fix" issue="17" due-to="jcucurull">

+			<action dev="py4fun" type="fix" issue="21" due-to="ashwin.jayaprakash">

+                Support arrays of reference types as JavaBean properties (2009-09-22)

+            </action>

+            <action dev="py4fun" type="fix" issue="17" due-to="jcucurull">

                 Respect root tag for sequences (2009-09-04)

             </action>

             <action dev="py4fun" type="fix" issue="18" due-to="creiniger">

diff --git a/src/main/java/org/yaml/snakeyaml/constructor/Constructor.java b/src/main/java/org/yaml/snakeyaml/constructor/Constructor.java
index cab1b28..d64c68f 100644
--- a/src/main/java/org/yaml/snakeyaml/constructor/Constructor.java
+++ b/src/main/java/org/yaml/snakeyaml/constructor/Constructor.java
@@ -214,6 +214,9 @@
                 try {
                     Property property = getProperty(beanType, key);
                     valueNode.setType(property.getType());
+                    if (property.getType().isArray()) {
+                        isArray = true;
+                    }
                     TypeDescription memberDescription = typeDefinitions.get(beanType);
                     if (memberDescription != null) {
                         switch (valueNode.getNodeId()) {
@@ -239,7 +242,7 @@
                         }
                     }
                     Object value = constructObject(valueNode);
-                    if (isArray) {
+                    if (isArray && value instanceof List) {
                         List<Object> list = (List<Object>) value;
                         value = list.toArray(createArray(property.getType()));
                     }
diff --git a/src/test/java/org/yaml/snakeyaml/javabeans/StringArrayTest.java b/src/test/java/org/yaml/snakeyaml/javabeans/StringArrayTest.java
new file mode 100644
index 0000000..2f12e28
--- /dev/null
+++ b/src/test/java/org/yaml/snakeyaml/javabeans/StringArrayTest.java
@@ -0,0 +1,55 @@
+/**

+ * Copyright (c) 2008-2009 Andrey Somov

+ *

+ * Licensed under the Apache License, Version 2.0 (the "License");

+ * you may not use this file except in compliance with the License.

+ * You may obtain a copy of the License at

+ *

+ *     http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS,

+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+ * See the License for the specific language governing permissions and

+ * limitations under the License.

+ */

+package org.yaml.snakeyaml.javabeans;

+

+import java.util.Arrays;

+

+import junit.framework.TestCase;

+

+import org.yaml.snakeyaml.Yaml;

+

+public class StringArrayTest extends TestCase {

+    public void testStrings() {

+        A a = new A();

+        a.setNames(new String[] { "aaa", "bbb", "ccc" });

+        Yaml yaml = new Yaml();

+        String output = yaml.dump(a);

+        assertEquals("!!org.yaml.snakeyaml.javabeans.StringArrayTest$A\nnames: [aaa, bbb, ccc]\n",

+                output);

+        A b = (A) yaml.load(output);

+        assertTrue(Arrays.equals(a.getNames(), b.getNames()));

+    }

+

+    public static class A {

+        String[] names;

+

+        public String[] getNames() {

+            return names;

+        }

+

+        public void setNames(String[] names) {

+            this.names = names;

+        }

+

+        public String getName(int index) {

+            return names[index];

+        }

+

+        public void setName(int index, String name) {

+            this.names[index] = name;

+        }

+    }

+}