JiBX
  1. JiBX
  2. JIBX-117

receive and error from the compiler when adding more elements (value or structure) to my binding definition.

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JiBX 1.1
    • Fix Version/s: JiBX 1.1.2
    • Component/s: core
    • Labels:
      None
    • Environment:
      Windows XP
    • Number of attachments :
      0

      Description

      in the following binding definition:
      <binding>
      <mapping name="ca.promutuel.transformation.copybook.sadg.PoliceHabitation" class="ca.promutuel.transformation.copybook.PoliceHabitation" ordered="false" flexible="true">
      <value name="codeAssureurPrecedent" field="codeAssPrecedent" usage="optional"/>
      <value name="classeFiscale" field="classeFiscale" usage="optional"/>
      <value name="etatCompteUnique" field="codeEtatCompte" usage="optional"/>
      <value name="nbrSinistresEnCours" field="nbSinistresEnCours" usage="optional"/>
      <value name="codeSuccursale" field="succursale" usage="optional"/>
      <value name="typePolice" field="typePolice" usage="optional"/>
      <value name="dateAnnulation" field="dateAnnulation" usage="optional"/>
      <value name="causeAnnulation" field="causeAnnulation" usage="optional"/>
      <value name="statut" field="statut" usage="optional"/>
      <value name="datePremiereAssurance" field="dateEntreeVigueur" usage="optional"/>
      <value name="dateEntreeSysteme" field="dateEntreeSysteme" usage="optional"/>
      <value name="ancienNoPolice" field="ancienNoPolice" usage="optional"/>
      <value name="noPolice" field="noPolice" usage="optional"/>

      <structure name="terme" usage="optional" flexible="true" ordered="false">
      <value name="dateProduction" field="dateProductionImage" usage="optional"/>
      <value name="montantCommission" field="montantCommissionImage" usage="optional"/>
      <value name="tauxCommission" field="tauxCommissionImage" usage="optional"/>
      <value name="typeRabais" field="typeRabais" usage="optional"/>
      <value name="montantRabais" field="montantRabais" usage="optional"/>
      <value name="tauxRabais" field="tauxRabais" usage="optional"/>
      <value name="montantDejaPercu" field="montantDejaPercu" usage="optional"/>
      <value name="totalPrimesSouscrites" field="primeSouscriteCumulative" usage="optional"/>
      <value name="primeSouscrite" field="primeSouscriteImage" usage="optional"/>
      <value name="dateEcheance" field="dateExpirationTerme" usage="optional"/>
      <value name="dateEffective" field="dateEffectiveTransaction" usage="optional"/>
      <value name="dateEntreeVigueur" field="dateEntreeVigueurTerme" usage="optional"/>
      <value name="noImage" field="noImage" usage="optional"/>
      <value name="noTerme" field="noTerme" usage="optional"/>
      <value name="noFlotte" field="noFlotte" usage="optional"/>

      <structure name="repres" usage="optional" ordered="false" flexible="true">
      <!-- Can add value element here-->
      <value name="noRepresentant" field="noRepresentantImage" usage="optional"/>
      <!-- Can't add any value element here-->
      </structure>

      <!-- Unable to add any structure or value element here-->
      </structure>
      </mapping>
      </binding>,

      it is impossible to add any element after the last value element. However, it is possible to add a value element between two existing element, but the same is not true for a structure element: it cannot be added anywhere in the binding definition.

      The error I receive from the compiler is:

      bind:
      [echo] Running JiBX binding compiler
      [bind] Error running binding compiler
      [bind] *** Error during code generation - please enter a bug report for this error in Jira if the problem is not listed as fixed on the online status page ***
      [bind] java.lang.ArrayIndexOutOfBoundsException: -1
      [bind] at java.util.ArrayList.get(Unknown Source)
      [bind] at org.jibx.binding.classes.MethodBuilder.appendLoadLocal(MethodBuilder.java:1094)
      [bind] at org.jibx.binding.def.NestedStructure.genFlagTest(NestedStructure.java:327)
      [bind] at org.jibx.binding.def.NestedStructure.genContentUnmarshal(NestedStructure.java:244)
      [bind] at org.jibx.binding.def.ObjectBinding.genUnmarshalContentCall(ObjectBinding.java:795)
      [bind] at org.jibx.binding.def.ObjectBinding.genContentUnmarshal(ObjectBinding.java:940)
      [bind] at org.jibx.binding.def.ElementWrapper.genContentUnmarshal(ElementWrapper.java:315)
      [bind] at org.jibx.binding.def.MappingDefinition.generateCode(MappingDefinition.java:582)
      [bind] at org.jibx.binding.def.DefinitionContext.generateCode(DefinitionContext.java:603)
      [bind] at org.jibx.binding.def.BindingDefinition.generateCode(BindingDefinition.java:661)
      [bind] at org.jibx.binding.Compile.compile(Compile.java:305)
      [bind] at org.jibx.binding.ant.CompileTask.execute(CompileTask.java:248)
      [bind] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
      [bind] at org.apache.tools.ant.Task.perform(Task.java:364)
      [bind] at org.apache.tools.ant.Target.execute(Target.java:341)
      [bind] at org.apache.tools.ant.Target.performTasks(Target.java:369)
      [bind] at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
      [bind] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:379)
      [bind] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:135)
      BUILD FAILED: C:\Documents and Settings\Sebastien\My Documents\workspaces\esb\esb\src\build.xml:76: JiBXException in JiBX binding compilation
      Total time: 1 second

      If you need more information or if this error is due to a bad use or understanding of JiBX, please let me know.

        Activity

        Hide
        Joshua Davies added a comment -

        I'm running into the same issue; here's a smaller binding (the smallest possible, I beleive) that produces the same stack trace:

        <binding direction="input">
        <mapping name="top" class="Top" ordered="false">
        <structure name="element1" ordered="false" usage="optional">
        <structure name="element1a" usage="optional" />
        </structure>
        <structure name="element2" ordered="false" usage="optional">
        <structure name="element2a" usage="optional" />
        </structure>
        </mapping>
        </binding>

        Show
        Joshua Davies added a comment - I'm running into the same issue; here's a smaller binding (the smallest possible, I beleive) that produces the same stack trace: <binding direction="input"> <mapping name="top" class="Top" ordered="false"> <structure name="element1" ordered="false" usage="optional"> <structure name="element1a" usage="optional" /> </structure> <structure name="element2" ordered="false" usage="optional"> <structure name="element2a" usage="optional" /> </structure> </mapping> </binding>
        Hide
        Joshua Davies added a comment -

        The issue appears to be the inclusion of two back-to-back "ordered=false" structures inside another "ordered=false" structuer. Tracing through the code, I beleive I've narrowed it down to line 305 of the file build/src/org/jibx/binding/def/NestedStructure.java, in function "genContentUnmarshal":

        mb.freeSlot(FLAG_ARRAY_SLOT);

        This will be invoked early, when the second structure completes its binding, because of line 259 of the same function:

        child.genContentUnmarshal(mb);

        This will end up recursively calling itself, but it doesn't change the "mb" (ContextMethodBuilder) parameter (and it doesn't look like it's supposed to). When it completes (generating unmarshal for "element1"), it will execute line 305 on the containing contextMethodBuilder, remove the FLAG_ARRAY_SLOT, and then the "for" loop that started on line 234 will continue on to try to generate unmarshal content for "element2", but will throw a null pointer exception when it no longer finds the "FLAG_ARRAY_SLOT".

        I can see the issue, but I can't see how to resolve it; it seems like you'd want to put off freeing the FLAG_ARRAY_SLOT until after you had processed everything relative to the current ContextMethodBuilder, but I can't see any way to figure out that you're at the "top" of the stack.

        Show
        Joshua Davies added a comment - The issue appears to be the inclusion of two back-to-back "ordered=false" structures inside another "ordered=false" structuer. Tracing through the code, I beleive I've narrowed it down to line 305 of the file build/src/org/jibx/binding/def/NestedStructure.java, in function "genContentUnmarshal": mb.freeSlot(FLAG_ARRAY_SLOT); This will be invoked early, when the second structure completes its binding, because of line 259 of the same function: child.genContentUnmarshal(mb); This will end up recursively calling itself, but it doesn't change the "mb" (ContextMethodBuilder) parameter (and it doesn't look like it's supposed to). When it completes (generating unmarshal for "element1"), it will execute line 305 on the containing contextMethodBuilder, remove the FLAG_ARRAY_SLOT, and then the "for" loop that started on line 234 will continue on to try to generate unmarshal content for "element2", but will throw a null pointer exception when it no longer finds the "FLAG_ARRAY_SLOT". I can see the issue, but I can't see how to resolve it; it seems like you'd want to put off freeing the FLAG_ARRAY_SLOT until after you had processed everything relative to the current ContextMethodBuilder, but I can't see any way to figure out that you're at the "top" of the stack.
        Hide
        Joshua Davies added a comment -

        And, in case you're curious, commenting out that line (line 305, "freeSlot") allows the binding to complete, but yields a runtime error of:

        Exception in thread "main" java.lang.VerifyError (class: Top, method: JiBX_binding_unmarshal_1_0 signature: (Lorg/jibx/runtime/impl/UnmrashallingContext;)LTop Accessing value from uninitialized register 3)

        (which makes sense).

        Show
        Joshua Davies added a comment - And, in case you're curious, commenting out that line (line 305, "freeSlot") allows the binding to complete, but yields a runtime error of: Exception in thread "main" java.lang.VerifyError (class: Top, method: JiBX_binding_unmarshal_1_0 signature: (Lorg/jibx/runtime/impl/UnmrashallingContext;)LTop Accessing value from uninitialized register 3) (which makes sense).
        Hide
        Joshua Davies added a comment -

        It looks like this might already be fixed, just not released yet - browsing through the CVS repository for NestedStructure, I see that revision 1.6 has the following comment:

        "Fix problem where nested unordered groupings used same slot for boolean array."

        Seb Boudreau, if you have CVS access, you might want to try downloading the latest branch and compiling it. I just grabbed the 1.6 revision of NestedStructure, applied it to my branch, and the problem seems to have gone away (of course, I eagerly await the next "official" release).

        (BTW, JIRA added the smiley you see above - I was cutting and pasting an actual semicolon followed by an actual end parenthesis).

        Show
        Joshua Davies added a comment - It looks like this might already be fixed, just not released yet - browsing through the CVS repository for NestedStructure, I see that revision 1.6 has the following comment: "Fix problem where nested unordered groupings used same slot for boolean array." Seb Boudreau, if you have CVS access, you might want to try downloading the latest branch and compiling it. I just grabbed the 1.6 revision of NestedStructure, applied it to my branch, and the problem seems to have gone away (of course, I eagerly await the next "official" release). (BTW, JIRA added the smiley you see above - I was cutting and pasting an actual semicolon followed by an actual end parenthesis).
        Hide
        Dennis Sosnoski added a comment -

        Yes, this should now be fixed. If you can test with the current CVS code it'd be good to verify the fix before the 1.1.2 release. Note that current jars are available as -SNAPSHOT from http://jibx.sourceforge.net/maven/jibx/jars/

        Show
        Dennis Sosnoski added a comment - Yes, this should now be fixed. If you can test with the current CVS code it'd be good to verify the fix before the 1.1.2 release. Note that current jars are available as -SNAPSHOT from http://jibx.sourceforge.net/maven/jibx/jars/

          People

          • Assignee:
            Dennis Sosnoski
            Reporter:
            Seb boudreau
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: