Uploaded image for project: 'mdsal'
  1. mdsal
  2. MDSAL-728

Build error on generated code for Enumeration

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Medium Medium
    • None
    • None
    • Binding codegen
    • None

      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?)

            rovarga Robert Varga
            jmatias Jorge Matias
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: