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

Piotr Kozikowski commented on THRIFT-409:
-----------------------------------------

In the Java-specific stuff, things seem a bit too type-unsafe to me. A lot of 
it has to do with limitations inherent to Java generics, but in some places 
type info is lost where it mustn't. For instance, the deep copy constructor 
uses generic code in TUnion.java instead of custom generated code like a normal 
struct would do. The constructor could instead check for a valid value of 
setField_, and invoke the corresponding (generated) type-safe code (I see there 
is a checkType() method, but it doesn't work for containers).

Likewise, instead of having just one constructor like this:

TUnion(int setField, Object value)

there could be one with an explicit type for each field, with the corresponding 
check that the appropriate value for setField is used according to the field's 
type. This way user code attempting to assign an object of invalid type to a 
field would not even compile.

> Add "union" to Thrift
> ---------------------
>
>                 Key: THRIFT-409
>                 URL: https://issues.apache.org/jira/browse/THRIFT-409
>             Project: Thrift
>          Issue Type: New Feature
>            Reporter: Bryan Duxbury
>            Assignee: Bryan Duxbury
>             Fix For: 0.2
>
>         Attachments: one_rule.diff, thrift-409-v2.patch, thrift-409-v3.patch, 
> thrift-409-v4.patch, thrift-409-v5.patch, thrift-409-v6.patch, 
> thrift-409-v7.patch, thrift-409.patch
>
>
> It would be very helpful to have a "union" construct in Thrift. Let's decide 
> on the design and then break up into sub-issues to add this feature.

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