You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Roshan George (JIRA)" <ji...@apache.org> on 2015/04/30 09:20:06 UTC
[jira] [Commented] (THRIFT-2326) Enums generated for Java doesn't
work for types in maps
[ https://issues.apache.org/jira/browse/THRIFT-2326?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14521049#comment-14521049 ]
Roshan George commented on THRIFT-2326:
---------------------------------------
[~hsjunnesson], this is related to some other issues when using no namespaces. If you use `namespace java some.package.name` at the top of the file, you'll be fine for now.
> Enums generated for Java doesn't work for types in maps
> -------------------------------------------------------
>
> Key: THRIFT-2326
> URL: https://issues.apache.org/jira/browse/THRIFT-2326
> Project: Thrift
> Issue Type: Bug
> Components: Java - Compiler
> Affects Versions: 0.9.1
> Environment: Mac OSX
> Reporter: Hans Sjunnesson
>
> I use the following thrift file to illustrate the bug:
> {code:title=test.thrift}
> enum TestEnum {
> ONE,
> TWO,
> THREE,
> FOUR,
> }
> const map<TestEnum,string> TestMap = {
> TestEnum.ONE: "one",
> TestEnum.TWO: "two",
> Testenum.THREE: "three",
> TestEnum.FOUR: "four",
> }
> {code}
> I then run {{thift --gen java test.thrift}} and when I compile the classes I get the following errors:
> {noformat}
> testConstants.java:37: illegal start of expression
> TestMap.put(.TestEnum.ONE, "one");
> ^
> testConstants.java:37: ';' expected
> TestMap.put(.TestEnum.ONE, "one");
> ^
> testConstants.java:37: illegal start of expression
> TestMap.put(.TestEnum.ONE, "one");
> ^
> testConstants.java:37: <identifier> expected
> TestMap.put(.TestEnum.ONE, "one");
> ^
> testConstants.java:37: illegal start of expression
> TestMap.put(.TestEnum.ONE, "one");
> ^
> testConstants.java:38: illegal start of expression
> TestMap.put(.TestEnum.TWO, "two");
> ^
> testConstants.java:38: ';' expected
> TestMap.put(.TestEnum.TWO, "two");
> ^
> testConstants.java:38: illegal start of expression
> TestMap.put(.TestEnum.TWO, "two");
> ^
> testConstants.java:38: <identifier> expected
> TestMap.put(.TestEnum.TWO, "two");
> ^
> testConstants.java:38: illegal start of expression
> TestMap.put(.TestEnum.TWO, "two");
> ^
> testConstants.java:39: illegal start of expression
> TestMap.put(.Testenum.THREE, "three");
> ^
> testConstants.java:39: ';' expected
> TestMap.put(.Testenum.THREE, "three");
> ^
> testConstants.java:39: illegal start of expression
> TestMap.put(.Testenum.THREE, "three");
> ^
> testConstants.java:39: <identifier> expected
> TestMap.put(.Testenum.THREE, "three");
> ^
> testConstants.java:39: illegal start of expression
> TestMap.put(.Testenum.THREE, "three");
> ^
> testConstants.java:40: illegal start of expression
> TestMap.put(.TestEnum.FOUR, "four");
> ^
> testConstants.java:40: ';' expected
> TestMap.put(.TestEnum.FOUR, "four");
> ^
> testConstants.java:40: illegal start of expression
> TestMap.put(.TestEnum.FOUR, "four");
> ^
> testConstants.java:40: <identifier> expected
> TestMap.put(.TestEnum.FOUR, "four");
> ^
> testConstants.java:40: illegal start of expression
> TestMap.put(.TestEnum.FOUR, "four");
> ^
> {noformat}
> The offending piece of code is {{testConstants.java}} which looks like this:
> {code:title=testConstants.java|borderStyle=solid}
> /**
> * Autogenerated by Thrift Compiler (0.9.1)
> *
> * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
> * @generated
> */
> 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 org.apache.thrift.protocol.TProtocolException;
> import org.apache.thrift.EncodingUtils;
> import org.apache.thrift.TException;
> import org.apache.thrift.async.AsyncMethodCallback;
> import org.apache.thrift.server.AbstractNonblockingServer.*;
> 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;
> public class testConstants {
> public static final Map<TestEnum,String> TestMap = new HashMap<TestEnum,String>();
> static {
> TestMap.put(.TestEnum.ONE, "one");
> TestMap.put(.TestEnum.TWO, "two");
> TestMap.put(.Testenum.THREE, "three");
> TestMap.put(.TestEnum.FOUR, "four");
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)