ClassCastException in IndentationEngineImpl (write method) when a primitive 
array
---------------------------------------------------------------------------------

         Key: JAXME-48
         URL: http://issues.apache.org/jira/browse/JAXME-48
     Project: JaxMe
        Type: Bug
  Components: JaxMeJS  
    Reporter: Nacho G. Mac Dowell
    Priority: Minor


The method write(IndentationTarget pTarget, Object pObject) in 
IndentationEngineImpl throws a ClassCastException when object type is a 
primitive array. The solution is (AFAIK) to use reflection. The patch:

Index: IndentationEngineImpl.java
===================================================================
RCS file: 
/home/cvspublic/ws-jaxme/src/js/org/apache/ws/jaxme/js/IndentationEngineImpl.java,v
retrieving revision 1.3
diff -u -r1.3 IndentationEngineImpl.java
--- IndentationEngineImpl.java  16 Feb 2004 23:39:55 -0000      1.3
+++ IndentationEngineImpl.java  19 Apr 2005 07:06:40 -0000
@@ -18,6 +18,7 @@
 
 import java.io.IOException;
 import java.io.StringWriter;
+import java.lang.reflect.Array;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -278,11 +279,11 @@
   public void write(IndentationTarget pTarget, Object pObject)
       throws IOException {
     if (pObject.getClass().isArray()) {
-      Object[] objects = (Object[]) pObject;
-      for (int i = 0;  i < objects.length;  i++) {
-        write(pTarget, objects[i]);
-      }
-         } else if (pObject instanceof JavaSourceObject) {
+       int arrayLength = Array.getLength(pObject);
+               for (int i = 0;  i < arrayLength;  i++) {
+                   write(pTarget, Array.get(pObject, i));
+               }
+       } else if (pObject instanceof JavaSourceObject) {
                  pTarget.write(((JavaSourceObject) pObject).getName());
     } else if (pObject instanceof List) {
        for (Iterator iter = ((List) pObject).iterator();  iter.hasNext();  ) {


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to