How can I keep my using interfaces in classes I want to use JiBX binding with?
Example: I have this very simple model in java:
public interface A {
B getB();
void setB(B b);
}
public interface B {
String getData();
void setData(String data);
}
public class AImpl implements A {
B b;
@Override
public B getB() {
return b;
}
@Override
public void setB(B b) {
this.b = b;
}
}
public class BImpl implements B {
private String data;
@Override
public String getData() {
return data;
}
@Override
public void setData(String data) {
this.data = data;
}
}
And this binding document:
<binding>
<mapping name="A"
class="com.test.AImpl">
<structure name="B" usage="optional" get-method="getB" set-method="setB"/>
</mapping>
<mapping name="B"
class="com.test.BImpl">
<value name="data" set-method="setData" get-method="getData" usage="optional"/>
</mapping>
</binding>
When I try to run my code I get this exception:
java.lang.ClassFormatError: Method in class com/test/B has illegal modifiers: 0x1001
I've tried to use 'abstract="true"' on both mapping, only to get this exception:
...Caused by: org.jibx.runtime.JiBXException: Unable to access binding information for class com.test.A Make sure the binding has been compiled...
The only solution I've found is to have AImpl hold a BImpl instead of a B, and have the getter return BImpl and the setter recieve BImpl. This is very wrong as it breaks the interface completely.
How can I solve this? I've been pulling hairs out, having tantrums (the real issue is much more complex, and JiBX cryptic error messages don't help) - nothing help.
Is this solvable? Is JiBX really that intrusive (in that it requires me to abandon all interface programming?)
Please don't answer "use AbstractB" as it's the same problem, only one level removed.