[MDSAL-533] Generated code with incompatible types Created: 11/Mar/20 Updated: 12/Mar/22 Resolved: 19/Dec/20 |
|
| Status: | Resolved |
| Project: | mdsal |
| Component/s: | Binding codegen |
| Affects Version/s: | None |
| Fix Version/s: | 7.0.3 |
| Type: | Bug | Priority: | Medium |
| Reporter: | Miroslav Kovac | Assignee: | Ilya Igushev |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Description |
|
module
module a {
yang-version 1;
namespace "a";
prefix "a";
grouping foo_grp {
leaf key_leaf1 {
type leafref {
path "../../../a:foo_list/a:name";
}
}
leaf key_leaf2 {
type string;
}
leaf key_leaf3 {
type string;
}
}
container foo_cont {
list foo_list {
key "name";
leaf name {
type string {
length "1..255";
}
}
}
container foo_cont2 {
list foo_list2 {
key "key_leaf1 key_leaf2 key_leaf3";
uses foo_grp;
}
}
}
}
generates code with no error but when maven tries to compile it will receive an error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project lighty-models-skeleton: Compilation failure [ERROR] /home/miroslav/projects/java/pt-ldl/distribution/scripts/user/java/lighty-models-skeleton/target/generated-sources/mdsal-binding/org/opendaylight/yang/gen/v1/a/norev/foo_cont/foo_cont2/FooList2Builder.java:[157,60] incompatible types: java.lang.Object cannot be converted to java.lang.String the problem is with following generated code:
FooList2Impl(FooList2Builder base) {
super(base.augmentation);
if (base.key() != null) {
this.key = base.key();
} else {
this.key = new FooList2Key(base.getKeyLeaf1(), base.getKeyLeaf2(), base.getKeyLeaf3());
}
this._keyLeaf1 = key.getKeyLeaf1();
this._keyLeaf2 = key.getKeyLeaf2();
this._keyLeaf3 = key.getKeyLeaf3();
}
here we can see that it is trying to create instance of FooList2KEY with three keys from base. Where base is:
public class FooList2Builder implements Builder<FooList2> { private Object _keyLeaf1; private String _keyLeaf2; private String _keyLeaf3; private FooList2Key key; as you can see the first field is Object _keyLeaf1 which is a problem because FooList2Key constructor is generated like this: public FooList2Key(String _keyLeaf1, String _keyLeaf2, String _keyLeaf3) { this._keyLeaf1 = _keyLeaf1; this._keyLeaf2 = _keyLeaf2; this._keyLeaf3 = _keyLeaf3; } String _keyLeaf1 !!!
|