[
https://issues.apache.org/jira/browse/THRIFT-3301?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15626686#comment-15626686
]
Jens Geyer commented on THRIFT-3301:
------------------------------------
{quote}
Also one thing to note is that the Java code generated from following valid IDL
will still fail to compile because the names match Java primitive types... I
know of no way to avoid this problem:
{quote}
That is part of a General Problem, not only with Java. There are tickets around
where People solved that already for other languages. Single biggest issue is,
that aside from a buch of really common standard keywords there is no General
set of keywords and no generic solution. Happy are those who have the ability
to escape keywords, like C# which can just precede them with a @ character.
Unfortunately, not all languages have such an option.
{quote}
the "reserved" keyword list for the thrift Compiler
{quote}
I personally tend to think of this one being a crutch, at least partially.
While it makes sense to just plain forbid some keywords that are keywords in
virtually all languages, it is not the solution that fits all. Adding one
keyword to the list because it is a keyword in one of ~20 languages sounds just
strange to me.
> Java generated code uses imports that can lead to class name collisions with
> IDL defined types
> ----------------------------------------------------------------------------------------------
>
> Key: THRIFT-3301
> URL: https://issues.apache.org/jira/browse/THRIFT-3301
> Project: Thrift
> Issue Type: Bug
> Components: Java - Compiler
> Affects Versions: 0.8, 0.9, 0.9.1, 0.9.2
> Environment: Tested on Linux (Ubuntu 14) with Oracle JDK 8
> Reporter: Alexander Volanis
> Attachments: thrift-issue-3301.tgz
>
>
> The Java generator will produce Java classes with the following set of imports
> {code}
> import org.apache.thrift.scheme.IScheme;
> import org.apache.thrift.scheme.SchemeFactory;
> import org.apache.thrift.scheme.StandardScheme;
> import org.apache.thrift.scheme.TupleScheme;
> import org.apache.thrift.protocol.TTupleProtocol;
> import java.util.List;
> import java.util.ArrayList;
> import java.util.Map;
> import java.util.HashMap;
> import java.util.EnumMap;
> import java.util.Set;
> import java.util.HashSet;
> import java.util.EnumSet;
> import java.util.Collections;
> import java.util.BitSet;
> import java.nio.ByteBuffer;
> import java.util.Arrays;
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
> {code}
> Any one of the imported classes may cause a name conflict with generated code
> that happens to define a same name class and uses such class as argument or
> result to methods.
> The generated code should always use fully qualified references to the
> classes when necessary and avoid all use of imports.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)