You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Bryan Duxbury (JIRA)" <ji...@apache.org> on 2009/05/28 00:29:45 UTC
[jira] Commented: (THRIFT-489) Java enum validation only validates
explicitly assigned values
[ https://issues.apache.org/jira/browse/THRIFT-489?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12713778#action_12713778 ]
Bryan Duxbury commented on THRIFT-489:
--------------------------------------
This is a good change. I'm ok with spreading out the init over many lines, but is there some compelling reason to introduce a bunch of extra whitespace in the constructor call? Also, can you resubmit a patch that is taken relative to the root of the project instead of way down in the source tree?
> Java enum validation only validates explicitly assigned values
> --------------------------------------------------------------
>
> Key: THRIFT-489
> URL: https://issues.apache.org/jira/browse/THRIFT-489
> Project: Thrift
> Issue Type: Bug
> Components: Compiler (Java)
> Reporter: Kevin Barrett
> Attachments: jvalidv.patch
>
>
> Java client enum validation code is rejecting any value other than those explicitly assigned inside the enum declaration. For example:
> {noformat}
> enum testEnum {
> valueZero = 0,
> valueOne,
> valueTwo
> }
> {noformat}
> generates the following code (excerpt):
> {noformat}
> public class testEnum {
> public static final int valueZero = 0;
> public static final int valueOne = 1;
> public static final int valueTwo = 2;
> public static final IntRangeSet VALID_VALUES = new IntRangeSet(valueZero);
> public static final Map<Integer, String> VALUES_TO_NAMES = new HashMap<Integer, String>() {{
> put(valueZero, "valueZero");
> put(valueOne, "valueOne");
> put(valueTwo, "valueTwo");
> }};
> }
> {noformat}
> If all enums are given explicit values, VALID_VALUES is initialized as follows:
> {noformat}
> public static final IntRangeSet VALID_VALUES = new IntRangeSet(valueZero, valueOne, valueTwo);
> {noformat}
> If no explicit values are assigned, VALID_VALUES is initialized with no parameters.
> Verified with r764072 and r771969.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.