summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan de Konink <stefan@konink.de>2021-01-05 20:11:29 +0100
committerGitHub <noreply@github.com>2021-01-05 11:11:29 -0800
commit1bf1ec027011ea562757f2b85d8cd0b7831b9baa (patch)
treed7a5ae3c4644aa363be706c6a0a978a89d1b7dfe
parent0800976533ac2b54790635a5eef8b5d9dbc5e8eb (diff)
downloadflatbuffers-1bf1ec027011ea562757f2b85d8cd0b7831b9baa.tar.gz
flatbuffers-1bf1ec027011ea562757f2b85d8cd0b7831b9baa.tar.bz2
flatbuffers-1bf1ec027011ea562757f2b85d8cd0b7831b9baa.zip
Implements type promotion for Java enum (#6382)
* Implements type promotion for Java enum as suggested in #3890, #5111, #6369 * After generate_code.sh
-rw-r--r--src/idl_gen_java.cpp2
-rw-r--r--tests/MyGame/Example/Color.java6
2 files changed, 4 insertions, 4 deletions
diff --git a/src/idl_gen_java.cpp b/src/idl_gen_java.cpp
index c51f7bc1..e80f3796 100644
--- a/src/idl_gen_java.cpp
+++ b/src/idl_gen_java.cpp
@@ -316,7 +316,7 @@ class JavaGenerator : public BaseGenerator {
auto &ev = **it;
GenComment(ev.doc_comment, code_ptr, &comment_config, " ");
code += " public static final ";
- code += GenTypeBasic(enum_def.underlying_type);
+ code += GenTypeBasic(DestinationType(enum_def.underlying_type, false));
code += " ";
code += ev.name + " = ";
code += enum_def.ToString(ev);
diff --git a/tests/MyGame/Example/Color.java b/tests/MyGame/Example/Color.java
index 0563c0ab..dd19a615 100644
--- a/tests/MyGame/Example/Color.java
+++ b/tests/MyGame/Example/Color.java
@@ -7,16 +7,16 @@ package MyGame.Example;
*/
public final class Color {
private Color() { }
- public static final byte Red = 1;
+ public static final int Red = 1;
/**
* \brief color Green
* Green is bit_flag with value (1u << 1)
*/
- public static final byte Green = 2;
+ public static final int Green = 2;
/**
* \brief color Blue (1u << 3)
*/
- public static final byte Blue = 8;
+ public static final int Blue = 8;
public static final String[] names = { "Red", "Green", "", "", "", "", "", "Blue", };