Skip to content

Commit f7b7344

Browse files
battreDominic Battre
and
Dominic Battre
authored
Fix LongEnum definitions (#7596)
The MyGame/Example/LongEnum.java class did not compile because Java expects an "L" suffix for literals of type long. This CL fixes the code generation to include such a suffix. Co-authored-by: Dominic Battre <[email protected]>
1 parent 5792623 commit f7b7344

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

java/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
<configuration>
6464
<release>8</release>
6565
<testExcludes>
66-
<testExclude>**/LongEnum.java</testExclude>
6766
<testExclude>MyGame/Example/MonsterStorageGrpc.java</testExclude>
6867
<testExclude>MyGame/Example/StructOfStructs**</testExclude>
6968
<testExclude>MyGame/OtherNameSpace/TableBT.java</testExclude>

src/idl_gen_java.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,10 @@ class JavaGenerator : public BaseGenerator {
397397
code += " ";
398398
code += namer_.Variant(ev) + " = ";
399399
code += enum_def.ToString(ev);
400+
if (enum_def.underlying_type.base_type == BASE_TYPE_LONG ||
401+
enum_def.underlying_type.base_type == BASE_TYPE_ULONG) {
402+
code += "L";
403+
}
400404
code += ";\n";
401405
}
402406

tests/MyGame/Example/LongEnum.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
@SuppressWarnings("unused")
66
public final class LongEnum {
77
private LongEnum() { }
8-
public static final long LongOne = 2;
9-
public static final long LongTwo = 4;
10-
public static final long LongBig = 1099511627776;
8+
public static final long LongOne = 2L;
9+
public static final long LongTwo = 4L;
10+
public static final long LongBig = 1099511627776L;
1111
}
1212

0 commit comments

Comments
 (0)