[jira] [Commented] (THRIFT-3956) Java keywords that are legal in IDL can lead to generated code that will not compile
[ https://issues.apache.org/jira/browse/THRIFT-3956?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17634972#comment-17634972 ] Jens Geyer commented on THRIFT-3956: You certainly are aware that the "Primitives" structure is ambiguous, given the other definitions. Of course Thrift will recognize e.g. the "int" field as being of the basic int type, not of the int structure type defined above. IOW it will be hard to use that defined int struct somewhere else in the IDL. > Java keywords that are legal in IDL can lead to generated code that will not > compile > > > Key: THRIFT-3956 > URL: https://issues.apache.org/jira/browse/THRIFT-3956 > Project: Thrift > Issue Type: Sub-task > Components: Java - Compiler >Affects Versions: 0.10.0, 0.11.0 >Reporter: Benjamin Gould >Assignee: Jens Geyer >Priority: Minor > > Consider the following IDL, which is legal and leads to successful source > code generation using the Java generator: > {noformat} > struct int { > 1: i32 val > } > struct boolean { > 1: bool val > } > struct long { > 1: i64 val > } > struct short { > 1: i16 short > } > struct char { > 1: i16 val > } > struct Primitives { > 1: i32 int, > 2: i64 long, > 3: i16 short, > 4: bool boolean, > 5: i16 char > } > {noformat} > The generated does not compile because the struct names and fields names are > reserved keywords in Java, even though they are not reserved words in the > Thrift compiler. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (THRIFT-3956) Java keywords that are legal in IDL can lead to generated code that will not compile
[ https://issues.apache.org/jira/browse/THRIFT-3956?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16757994#comment-16757994 ] James E. King III commented on THRIFT-3956: --- [~jensg] is this an issue you are looking into resolving? > Java keywords that are legal in IDL can lead to generated code that will not > compile > > > Key: THRIFT-3956 > URL: https://issues.apache.org/jira/browse/THRIFT-3956 > Project: Thrift > Issue Type: Bug > Components: Java - Compiler >Affects Versions: 0.10.0, 0.11.0 >Reporter: Benjamin Gould >Priority: Minor > > Consider the following IDL, which is legal and leads to successful source > code generation using the Java generator: > {noformat} > struct int { > 1: i32 val > } > struct boolean { > 1: bool val > } > struct long { > 1: i64 val > } > struct short { > 1: i16 short > } > struct char { > 1: i16 val > } > struct Primitives { > 1: i32 int, > 2: i64 long, > 3: i16 short, > 4: bool boolean, > 5: i16 char > } > {noformat} > The generated does not compile because the struct names and fields names are > reserved keywords in Java, even though they are not reserved words in the > Thrift compiler. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (THRIFT-3956) Java keywords that are legal in IDL can lead to generated code that will not compile
[ https://issues.apache.org/jira/browse/THRIFT-3956?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15627539#comment-15627539 ] Benjamin Gould commented on THRIFT-3956: Possible solution could be to: 1) Identify all Java keywords that do are not in the thrift reserved words list 2) For those keywords, prefix the field name etc with a '$' character. Underscore is also possible but since Thrift identifiers can have underscores at the beginning, using an underscore might require more thought. > Java keywords that are legal in IDL can lead to generated code that will not > compile > > > Key: THRIFT-3956 > URL: https://issues.apache.org/jira/browse/THRIFT-3956 > Project: Thrift > Issue Type: Bug > Components: Java - Compiler >Affects Versions: 0.10.0, 0.11.0 >Reporter: Benjamin Gould >Priority: Minor > > Consider the following IDL, which is legal and leads to successful source > code generation using the Java generator: > {noformat} > struct int { > 1: i32 val > } > struct boolean { > 1: bool val > } > struct long { > 1: i64 val > } > struct short { > 1: i16 short > } > struct char { > 1: i16 val > } > struct Primitives { > 1: i32 int, > 2: i64 long, > 3: i16 short, > 4: bool boolean, > 5: i16 char > } > {noformat} > The generated does not compile because the struct names and fields names are > reserved keywords in Java, even though they are not reserved words in the > Thrift compiler. -- This message was sent by Atlassian JIRA (v6.3.4#6332)