You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Dave Engberg (JIRA)" <ji...@apache.org> on 2009/12/15 23:53:18 UTC
[jira] Updated: (THRIFT-651) Java generator produces incorrect
constant values
[ https://issues.apache.org/jira/browse/THRIFT-651?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Dave Engberg updated THRIFT-651:
--------------------------------
Attachment: thrift-java-enum-const.patch
patch that replaces the numeric constant value with the symbolic name of the enumerated constant
> Java generator produces incorrect constant values
> -------------------------------------------------
>
> Key: THRIFT-651
> URL: https://issues.apache.org/jira/browse/THRIFT-651
> Project: Thrift
> Issue Type: Bug
> Components: Compiler (Java)
> Affects Versions: 0.2
> Reporter: Dave Engberg
> Attachments: thrift-java-enum-const.patch
>
>
> The Thrift Java code generator was modified at some point so that fields of type 'enum' were expressed using the name of the numeration instead of 'Integer'.
> This change broke constants of enum types, since the expressed constant initializer is still a numeric value rather than the named enumeration, which results in a Java compiler error.
> This TestEnum.thrift IDL:
> enum TestEnum {
> FIRST = 1,
> SECOND = 2
> }
> const TestEnum TEST_CONST_VAL = FIRST;
> const list<TestEnum> TEST_CONST_LIST = [ FIRST, SECOND ];
> ... produces this Constants.java that won't compile:
> public class Constants {
> public static final TestEnum TEST_CONST_VAL = 1;
> public static final List<TestEnum> TEST_CONST_LIST = new ArrayList<TestEnum>();
> static {
> TEST_CONST_LIST.add(1);
> TEST_CONST_LIST.add(2);
> }
> }
> The patch replaces these numeric initializers with symbolic enumerated values:
> public class Constants {
> public static final TestEnum TEST_CONST_VAL = TestEnum.FIRST;
> public static final List<TestEnum> TEST_CONST_LIST = new ArrayList<TestEnum>();
> static {
> TEST_CONST_LIST.add(TestEnum.FIRST);
> TEST_CONST_LIST.add(TestEnum.SECOND);
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.