[
https://issues.apache.org/jira/browse/THRIFT-2435?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jens Geyer closed THRIFT-2435.
------------------------------
> Java compiler doesn't like struct member names that are identical to an
> existing enum or struct type
> ----------------------------------------------------------------------------------------------------
>
> Key: THRIFT-2435
> URL: https://issues.apache.org/jira/browse/THRIFT-2435
> Project: Thrift
> Issue Type: Bug
> Components: Java - Compiler
> Affects Versions: 0.9
> Reporter: Lucas Partridge
> Assignee: Jens Geyer
> Priority: Minor
> Fix For: 0.9.2
>
> Attachments: DataType.java, Metadata.java,
> THRIFT-2435_java_enum_type__conflicts_with_struct_member.patch,
> TestService.java, test.thrift
>
>
> The following IDL works fine in Python and C# but generates a compiler error
> in Java:
> {code}
> namespace * test
> enum DataType {
> Text
> }
> struct Metadata {
> 1: string Name,
> 2: DataType DataType
> }
> service TestService {
> void SendData(1:string Data, 2:Metadata Metadata)
> }
> {code}
> The generated test.Metadata.java file has 2 compile errors:
> {{Cannot make a static reference to the non-static field DataType}}
> at line 422:
> {code}
> struct.DataType = DataType.findByValue(iprot.readI32());
> {code}
> and line 495:
> {code}
> struct.DataType = DataType.findByValue(iprot.readI32());
> {code}
> If the IDL is changed to use {{DataType dataType}} instead then the compile
> errors don't occur.
> This issue is annoying because the same IDL works fine in Python and C#. To
> make the IDL work for Java we have to change the IDL, which means we have to
> change our Python clients (I haven't checked the C# clients yet). See also
> http://stackoverflow.com/questions/22691634/what-is-the-recommended-naming-convention-for-thrift-identifiers-in-order-to-max
--
This message was sent by Atlassian JIRA
(v6.2#6252)