You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Hans Sjunnesson (JIRA)" <ji...@apache.org> on 2014/01/20 12:39:19 UTC
[jira] [Created] (THRIFT-2326) Enums generated for Java doesn't
work for types in maps
Hans Sjunnesson created THRIFT-2326:
---------------------------------------
Summary: 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.1.5#6160)