[YANGTOOLS-20] Generated code throws compiler errors Created: 24/Sep/13  Updated: 10/Apr/22  Resolved: 26/Sep/13

Status: Resolved
Project: yangtools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement
Reporter: Suchitra Raman Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: Mac OS
Platform: PC


Attachments: Zip Archive projectx.zip    

 Description   

Seeing a problem with generated code in the affinity yang file.

The compiler errors is:

[ERROR] /Users/sraman/affinity/affinity/yang/target/generated-sources/sal/org/opendaylight/yang/gen/v1/urn/opendaylight/affinity/rev130916/CreateAffinityGroupInputBuilder.java:[54,19] error: CreateAffinityGroupInputImpl is not abstract and does not override abstract method getAffinityIdentifier() in AffinityGroup
[ERROR] /Users/sraman/affinity/affinity/yang/target/generated-sources/sal/org/opendaylight/yang/gen/v1/urn/opendaylight/affinity/rev130916/CreateAffinityGroupInputBuilder.java:[66,8] error: method does not override or implement a method from a supertype

(1) The first error may be due to incorrect order of following blocks of code.

(2) There seems to be an issue with the @Override directive at line 66. This is the getAffinityIdentifers() method.

Affinity-topology-all.yang is checked into the affinity repo.

====
public CreateAffinityGroupInput build()

{ return new CreateAffinityGroupInputImpl(this); }

private static class CreateAffinityGroupInputImpl implements CreateAffinityGroupInput {

private final List<AffinityIdentifiers> _affinityIdentifiers;
private final String _id;
private Map<Class<? extends Augmentation<CreateAffinityGroupInput>>, Augmentation<CreateAffinityGroupInput>> augmentation = new HashMap<>();

private CreateAffinityGroupInputImpl(CreateAffinityGroupInputBuilder builder)

{ this._affinityIdentifiers = builder.getAffinityIdentifiers(); this._id = builder.getId(); this.augmentation.putAll(builder.augmentation); }

@Override
public List<AffinityIdentifiers> getAffinityIdentifiers()

{ return _affinityIdentifiers; }

@Override
public String getId()

{ return _id; }

@SuppressWarnings("unchecked")
@Override
public <E extends Augmentation<CreateAffinityGroupInput>> E getAugmentation(Class<E> augmentationType) {
if (augmentationType == null)

{ throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); }

return (E) augmentation.get(augmentationType);
}

}



 Comments   
Comment by Martin Vitez [ 25/Sep/13 ]

Hello,
I can't replicate this bug with affinity-topology-all.yang which is currently in your repo. Did you make some local changes? For example at line 8 there is an import statement "import inventory

{prefix inv;}

" which cannot be resolved (correct name should be opendaylight-inventory). Can you please attach actual affinity-topology-all.yang file for which code generation fails?

Comment by Suchitra Raman [ 25/Sep/13 ]

(1) inventory vs. opendaylight-inventory.
Sorry I removed some content in order to pass pyang validation.
(FYI, calling this opendaylight-inventory also does not work. See error from pyang below. Any case, I've commented this out of the file to get through the yangtools code gen issue. See item 2 below.)

Pro:yang sraman$ pyang -p $YANG_MODPATH -f tree affinity-topology-all.yang
affinity-topology-all.yang:8: error: module "opendaylight-inventory" not found in search path
affinity-topology-all.yang:8: warning: imported module opendaylight-inventory not used
module: affinity-topology-all

(2) The new file is checked in now, please pull from repo.

Comment by Martin Vitez [ 25/Sep/13 ]

I tried it now with updated affinity-topology-all.yang on simple example and it works for me. I add this example in attachments.
Running "mvn clean install" for this example produce valid compilable java sources. Tested with version 0.5.7-SNAPSHOT and 0.5.8-SNAPSHOT.
Please try it and let me know if it works for you.

Comment by Martin Vitez [ 25/Sep/13 ]

Attachment projectx.zip has been added with description: working example

Comment by Suchitra Raman [ 25/Sep/13 ]

Error message with 0.5.8 says that there was another yang file with the same revision (not in the main tree, perhaps in the generated-sources, not sure).

After updating the revision number this seemed to work fine.

Generated at Wed Feb 07 20:52:02 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.