Uploaded image for project: 'JaxMe'
  1. JaxMe
  2. JAXME-48

ClassCastException in IndentationEngineImpl (write method) when a primitive array

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • current (nightly)
    • JaxMeJS
    • None

    Description

      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)
        Unknown macro: {+ 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(); ) {

      Attachments

        1. JAXME-48.patch
          3 kB
          Jochen Wiedmann

        Activity

          People

            Unassigned Unassigned
            ignaciogmd Nacho G. Mac Dowell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment