Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-776

default value for field with enum type generates Java source with compiler error

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.2
    • 0.3
    • Java - Compiler
    • None
    • Windows 7 64-bit
      cygwin-built compiler from thrift-0.2.0 source

    Description

      When I generate Java source from a thrift file where I assign a default enum value, the compiler correctly interprets the thrift file, but the source it generates assigns an integer to an enum field, which is a compiler error.
      A thrift file like this:

      enum MyEnum {
      MY_ENUM_VALUE=7
      }
      struct MyStruct {
      1 : MyEnum myEnum = MY_ENUM_VALUE
      }
      

      generates a constructor that looks like this:

      public MyStruct() {
         this.myEnum = 7
      }
      

      but it should generate this:

      public MyStruct () {
         this.myEnum = MyEnum.MY_ENUM_VALUE
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            jdecew Jeff DeCew
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: