[MDSAL-728] Build error on generated code for Enumeration Created: 28/Feb/22  Updated: 03/Mar/22  Resolved: 03/Mar/22

Status: Resolved
Project: mdsal
Component/s: Binding codegen
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Medium
Reporter: Jorge Matias Assignee: Robert Varga
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File bbg.tar.gz     Zip Archive enumeration-error.zip    

 Description   

I'm getting this build error when trying to build some thirdparty YANG modules (sorry I'm not sure if I can provide all of them because of IP issues):

 

[ERROR] ~/src/restconf/test/target/generated-sources/BindingJavaFileGenerator/org/opendaylight/yang/gen/v1/urn/bbf/yang/bbf/vdsl/rev191021/LineSpectrumProfile.java:[338,29] cannot find symbol
  symbol:   method getValue()
  location: variable _bits of type org.opendaylight.yang.gen.v1.urn.bbf.yang.bbf.vdsl.rev191021.LineSpectrumProfile.PowerManagementMode.Bits

 

This fails with the following pom configuration:

 

<plugin>
    <groupId>org.opendaylight.yangtools</groupId>
    <artifactId>yang-maven-plugin</artifactId>
    <version>7.0.14</version>
    <dependencies>
        <dependency>
            <groupId>org.opendaylight.mdsal</groupId>
            <artifactId>mdsal-binding-java-api-generator</artifactId>
            <version>8.0.7</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>30.1.1-jre</version>
        </dependency>

 

But used to work in former plugin versions:

 

<plugin>
    <groupId>org.opendaylight.yangtools</groupId>
    <artifactId>yang-maven-plugin</artifactId>
    <version>3.0.16</version>
    <dependencies>
        <dependency>
            <groupId>org.opendaylight.mdsal</groupId>
            <artifactId>maven-sal-api-gen-plugin</artifactId>
            <version>2.0.17</version>
            <type>jar</type>
        </dependency>
    </dependencies>

I'm attaching the pom I used, the offending generated file (which also includes the YANG file), and the mvn -X results for the previous and current versions (note that I used JDK11 for the recent versions and JDK8 for the former, and I also used 15.1.0 as the lighty parent pom)

The error comes from this generated code:

public String stringValue() {
    if (_enumeration != null) {
        return _enumeration.toString();
    }
    if (_profiles != null) {
        return Arrays.toString(_profiles.getValue());
    }

    throw new IllegalStateException("No value assinged");
}

 Where profiles is an enumeration too, but the method getValue() is not implemented ( I guess in that case toString() should be called too?)



 Comments   
Comment by Robert Varga [ 03/Mar/22 ]

These are BBF models, freely available at https://github.com/BroadbandForum/yang . Using those, I have no trouble generating bindings with mdsal-8.0.11, as evidenced in attached project.

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