Recently, I ran into a couple of rather interesting problems with the
whole label/using schtick... One's already in jira as JiBX-16...The
other...

FYI: As I'm running these tests, I'm using the org.jibx.binding.Run
class for runtime bindings, but I get the same error when running the
binding from the command line, instead..

Given the objects:

public class StructureInCollectionTestBase
{
    ArrayList contents = null;
    Internal other = null;
}

public class Internal
{
    public String stringValue;
    public Long longValue;
}

and binding:

<binding name="StructureInCollection">
  <mapping name="base" class="StructureInCollectionTestBase">
    <collection name="collection" field="contents">
      <structure type="Internal" using="internal" name="internal"/>
    </collection>
    <structure name="internal" field="other" label="internal"
        type="Internal">
      <value field="stringValue" name="string" usage="optional"/>
      <value field="longValue" name="long" usage="optional"/>
    </structure>
  </mapping>
</binding>

Everything works as expected.  If, on the other hand, I 'label' the
structure inside the collection, and 'using' it elsewhere, like so:

<binding name="StructureInCollection">
  <mapping name="base" class="StructureInCollectionTestBase">
    <collection name="collection" field="contents">
      <structure type="Internal" label="internal" name="internal">
        <value field="stringValue" name="string" usage="optional"/>
        <value field="longValue" name="long" usage="optional"/>
      </structure>
    </collection>
    <structure name="internal" field="other" using="internal"/>
  </mapping>
</binding>

I receive an exception:

Exception in thread "main" java.lang.IllegalStateException: Internal
error: Expected Internal on stack, found
org.jibx.runtime.impl.MarshallingContext
 full stack:
  0: org.jibx.runtime.impl.MarshallingContext
  1: org.jibx.runtime.impl.MarshallingContext
  2: Internal

        at
org.jibx.binding.classes.MethodBuilder.verifyCompatible(MethodBuilder.java:408)
        at
org.jibx.binding.classes.MethodBuilder.verifyCallStack(MethodBuilder.java:497)
        at
org.jibx.binding.classes.MethodBuilder.appendCall(MethodBuilder.java:807)
        at
org.jibx.binding.def.ObjectBinding.genMarshalContentCall(ObjectBinding.java:684)
        at
org.jibx.binding.def.ObjectBinding.genContentMarshal(ObjectBinding.java:728)
        at
org.jibx.binding.def.ComponentProperty.genContentMarshal(ComponentProperty.java:241)
        at
org.jibx.binding.def.StructureReference.genContentMarshal(StructureReference.java:104)
        at
org.jibx.binding.def.ElementWrapper.genContentMarshal(ElementWrapper.java:380)
        at
org.jibx.binding.def.NestedStructure.genContentMarshal(NestedStructure.java:190)
        at
org.jibx.binding.def.ObjectBinding.genMarshalContentCall(ObjectBinding.java:668)
        at
org.jibx.binding.def.ObjectBinding.genContentMarshal(ObjectBinding.java:728)
        at
org.jibx.binding.def.ElementWrapper.genContentMarshal(ElementWrapper.java:380)
        at
org.jibx.binding.def.MappingDefinition.generateCode(MappingDefinition.java:560)
        at
org.jibx.binding.def.DefinitionContext.generateCode(DefinitionContext.java:593)
        at
org.jibx.binding.def.BindingDefinition.generateCode(BindingDefinition.java:562)
        at org.jibx.binding.Loader.processBindings(Loader.java:292)
        at org.jibx.binding.Run.main(Run.java:190)


Given this simple example, the problem is easily corrected by not
placing the 'label' inside the collection.  On the other hand, where I
first ran into this problem was with a binding where both the 'label'
and the referencing 'using's were inside collections, thus not allowing
me that solution.  Further, since the structure needed to have different
names in different places, I couldn't simply make a mapping for the
object (Name not allowed when using mapping reference at...).  

The only work-around I know of at the moment involves the copy-paste
method of programming, which is doable, but not exactly desirable.

Anyhow, if some sort of decent workaround exists, It would be good to
know.. otherwise, I guess this is a bug report..

Darin Clark
[EMAIL PROTECTED]
ADVENTURE(n): Someone else, far away, in one heck of a fix.



-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
jibx-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to