[ 
https://issues.apache.org/jira/browse/THRIFT-489?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12713851#action_12713851
 ] 

Kevin Barrett commented on THRIFT-489:
--------------------------------------

The formatting is just for consistency, and without newlines you'd wind up with 
a pretty long line even with moderate-sized enums.  Didn't see a reason not to 
-- I'm not a Java developer so apologies if it introduces a performance hit of 
some kind.  The simplest thing would be to just take out the if 
((*c_iter)->has_value()) test.

I'll resubmit the patch from the project root.

> 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.

Reply via email to