diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg index 492c56644..1683a18f8 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg @@ -236,9 +236,12 @@ public class extends { public static final int = }; separator=", ", wrap, anchor>; - public static final String[] ruleNames = { - "}; separator=", ", wrap, anchor> - }; + private static String[] makeRuleNames() { + return new String[] { + "}; separator=", ", wrap, anchor> + }; + } + public static final String[] ruleNames = makeRuleNames(); @@ -275,12 +278,18 @@ case : >> vocabulary(literalNames, symbolicNames) ::= << -private static final String[] _LITERAL_NAMES = { - }; null="null", separator=", ", wrap, anchor> -}; -private static final String[] _SYMBOLIC_NAMES = { - }; null="null", separator=", ", wrap, anchor> -}; +private static String[] makeLiteralNames() { + return new String[] { + }; null="null", separator=", ", wrap, anchor> + }; +} +private static final String[] _LITERAL_NAMES = makeLiteralNames(); +private static String[] makeSymbolicNames() { + return new String[] { + }; null="null", separator=", ", wrap, anchor> + }; +} +private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); /** @@ -914,9 +923,12 @@ public class extends { "}; separator=", ", wrap, anchor> }; - public static final String[] ruleNames = { - "}; separator=", ", wrap, anchor> - }; + private static String[] makeRuleNames() { + return new String[] { + "}; separator=", ", wrap, anchor> + }; + } + public static final String[] ruleNames = makeRuleNames();