JiBX
  1. JiBX
  2. JIBX-156

binding compiler is not aware of inherited interfaces

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JiBX 1.1.3
    • Fix Version/s: 1.0-RC1
    • Component/s: core
    • Labels:
      None
    • Environment:
      win xp / java 1.4.2_08 / jibx 1.1.3 (December 18, 2006)
    • Testcase included:
      yes
    • Number of attachments :
      1

      Description

      Here is a short exmple (see attachment for full code):

      ==========================
      public interface Bug_Itf
      { }

      public abstract class Bug_Abstract implements Bug_Itf
      { }

      public class Bug_Impl extends Bug_Abstract
      // implements Bug_Itf // ==> if not explicitly mentioned, JiBX is not aware of this relationship
      { }

      public class Bug_Test {
      private Bug_Itf m_impl; // ==> Note: If m_impl is of type Bug_Impl or Bug_Abstract, the pb doesn't appear

      public static void main (String[] args) throws Exception

      { Bug_Test t = new Bug_Test(); IBindingFactory bfact = BindingDirectory.getFactory(Bug_Test.class); IMarshallingContext mctx = bfact.createMarshallingContext(); mctx.marshalDocument(t, "UTF-8", null, System.out); }

      }
      ==========================

      when applying the binding (see it below),
      javac -classpath '.;jibx-run.jar' *.java
      java -jar jibx-bind.jar Bug_binding.xml
      I get the error
      Error: No compatible mapping defined for type Bug_Itf; on structure element at (line 20, col 50, in Bug_binding.xml)
      Error running binding compiler
      org.jibx.runtime.JiBXException: Binding Bug_binding.xml is unusable because of validation errors
      at org.jibx.binding.Utility.loadBinding(Utility.java:346)
      at org.jibx.binding.Utility.loadFileBinding(Utility.java:413)
      at org.jibx.binding.Compile.compile(Compile.java:296)
      at org.jibx.binding.Compile.main(Compile.java:385)

      Mentioning explicitly the Bug_Impl implements Bug_Itf resolves the pb.

      Bug_binding.xml:
      =============================
      <?xml version='1.0' encoding='UTF-8' ?>

      <binding>

      <!-- abstract mapping for
      Bug_Abstract (implements interface Bug_Itf) -->
      <mapping class="Bug_Abstract" abstract="true" type-name="A_abstract" />

      <!-- abstract and concrete mappings for
      Bug_Impl (extends abstract class Bug_Itf) -->
      <mapping class="Bug_Impl" abstract="true" type-name="A_impl">
      <structure map-as="A_abstract" />
      </mapping>
      <mapping name="impl" class="Bug_Impl">
      <structure map-as="A_impl" />
      </mapping>

      <!-- the test class, contains a "private Bug_Itf m_impl" -->
      <mapping class="Bug_Test" abstract="true" type-name="A_test">
      <structure field="m_impl" usage="optional" />
      </mapping>
      <mapping name="test" class="Bug_Test">
      <structure map-as="A_test" />
      </mapping>

      </binding>
      =============================

        Activity

        Hide
        Robert Light added a comment -

        Can anyone give me a clue as to how to deal with multiple classes which implement the same interface?

        Right now I'm trying (without success):

        <mapping class="CommonImpl" abstract="true" />
        <mapping name="commentrecord" class="CommentRecord" extends="CommonImpl">
        <value name="comment" field="comment" usage="optional"/>
        </mapping>
        <mapping name="simpleresourcerecord" class="SimpleRecord" extends="CommonImpl">
        <value name="namepattern" field="namePattern" />
        <value name="ttl" field="ttl" usage="optional"/>
        </mapping>

        Show
        Robert Light added a comment - Can anyone give me a clue as to how to deal with multiple classes which implement the same interface? Right now I'm trying (without success): <mapping class="CommonImpl" abstract="true" /> <mapping name="commentrecord" class="CommentRecord" extends="CommonImpl"> <value name="comment" field="comment" usage="optional"/> </mapping> <mapping name="simpleresourcerecord" class="SimpleRecord" extends="CommonImpl"> <value name="namepattern" field="namePattern" /> <value name="ttl" field="ttl" usage="optional"/> </mapping>
        Hide
        Dennis Sosnoski added a comment -

        Fixed for 1.1.5 release.

        Show
        Dennis Sosnoski added a comment - Fixed for 1.1.5 release.
        Hide
        Dennis Sosnoski added a comment -

        Oh, and Robert - it's not clear what you're trying to do, but this Jira issue is not the proper place for asking questions of this type in any case. Please take your question to the users list.

        Show
        Dennis Sosnoski added a comment - Oh, and Robert - it's not clear what you're trying to do, but this Jira issue is not the proper place for asking questions of this type in any case. Please take your question to the users list.
        Hide
        Jaquar added a comment -

        The issue still exists if there is an interface extending another interface.

        public interface IFoo
        { }

        public interface IBar extends IFoo
        { }

        public class Bug_Test implements IBar { }

        If I have structure field which is of type IFoo, it fails to realize that Bug_Test is actually implementing it indirectly and throws the error:-
        Error: No compatible mapping defined for type IFoo;

        However, if I have a seperate mapping for IBar, it realizes that IBar extends to IFoo and eventually realizes that Bug_Test is implementing. It is similar to the above issue with the exception of interface instead of abstract class.

        Is there a bug fix available ?

        Show
        Jaquar added a comment - The issue still exists if there is an interface extending another interface. public interface IFoo { } public interface IBar extends IFoo { } public class Bug_Test implements IBar { } If I have structure field which is of type IFoo, it fails to realize that Bug_Test is actually implementing it indirectly and throws the error:- Error: No compatible mapping defined for type IFoo; However, if I have a seperate mapping for IBar, it realizes that IBar extends to IFoo and eventually realizes that Bug_Test is implementing. It is similar to the above issue with the exception of interface instead of abstract class. Is there a bug fix available ?

          People

          • Assignee:
            Dennis Sosnoski
            Reporter:
            Pierre Kobylanski
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: