[MDSAL-807] typedef/bits generates invalid code Created: 16/Jan/23  Updated: 19/Jan/23  Resolved: 19/Jan/23

Status: Resolved
Project: mdsal
Component/s: Binding codegen
Affects Version/s: 11.0.0, 11.0.1, 11.0.2, 11.0.3
Fix Version/s: 11.0.4

Type: Bug Priority: Highest
Reporter: Robert Varga Assignee: Matúš Matok
Resolution: Done Votes: 0
Labels: pt, regression
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The following snippet (from OpenFlowJava):

  typedef table-config {
    type bits {
      bit OFPTC_DEPRECATED_MASK {
        position 3;
      }
    }
  }

ends up generating the following bit of code:

    public TableConfig(boolean _oFPTCDEPRECATEDMASK) {
        this._oFPTCDEPRECATEDMASK = _oFPTCDEPRECATEDMASK;
    }

    public TableConfig(TableConfig source) {
        this._oFPTCDEPRECATEDMASK = source._oFPTCDEPRECATEDMASK;
    }

    public static TableConfig getDefaultInstance(final String defaultValue) {
        return new TableConfig(new boolean(defaultValue));
    } 

Obviously getDefaultInstance() is completely wrong and triggers a javac failure:

[ERROR] /home/nite/odl/openflowplugin/openflowjava/openflow-protocol-api/target/generated-sources/BindingJavaFileGenerator/org/opendaylight/yang/gen/v1/urn/opendaylight/openflow/common/types/rev130731/TableConfig.java:[51,43] '[' expected
[ERROR] /home/nite/odl/openflowplugin/openflowjava/openflow-protocol-api/target/generated-sources/BindingJavaFileGenerator/org/opendaylight/yang/gen/v1/urn/opendaylight/openflow/common/types/rev130731/TableConfig.java:[51,57] ']' expected

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