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 07a1c953b..b2c3239ea 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 @@ -183,8 +183,11 @@ public (TokenStream input) { } >> +/* This generates a private method since the actionIndex is generated, making an + * overriding implementation impossible to maintain. + */ RuleActionFunction(r, actions) ::= << -public void _action( _localctx, int actionIndex) { +private void _action( _localctx, int actionIndex) { switch (actionIndex) { : break;}; separator="\n"> @@ -192,8 +195,11 @@ case : break;}; separator="\n"> } >> +/* This generates a private method since the predIndex is generated, making an + * overriding implementation impossible to maintain. + */ RuleSempredFunction(r, actions) ::= << -public boolean _sempred( _localctx, int predIndex) { +private boolean _sempred( _localctx, int predIndex) { switch (predIndex) { : return ;}; separator="\n">