From ed1eedbbcb6b7f071372a4e1bb648ffcc2338254 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 10 Feb 2020 07:24:51 +0100 Subject: [PATCH] java: revert "style: avoid useless initializers" This reverts commit ebab1ffca8a728158051481795ae798231cfd93d. This commit removed "useless" initializers, going from /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ private static final byte yypact_[] = yypact_init (); private static final byte[] yypact_init () { return new byte[] { 25, -7, -8, 37, -8, 40, -8, 20, -8, 61, -8, -8, 3, 9, 51, -8, -8, -2, -2, -2, -2, -2, -2, -8, -8, -8, 1, 66, 66, 3, 3, 3 }; } to /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ private static final byte[] yypact_ = { 25, -7, -8, 37, -8, 40, -8, 20, -8, 61, -8, -8, 3, 9, 51, -8, -8, -2, -2, -2, -2, -2, -2, -8, -8, -8, 1, 66, 66, 3, 3, 3 }; But it turns out that this was on purpose, to work around the 64KB limitation in JVM methods. It was introduced on the 2008-11-10 by Di-an Jan in 09ccae9b18a7c09ebf7bb8df2a18c8c4a6def248: "Work around Java's ``code too large'' problem for parser tables". See https://lists.gnu.org/r/help-bison/2008-11/msg00004.html. A real test, where we would hit the JVM limitation, would be nice. To avoid further regressions, add comments. --- data/skeletons/java.m4 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/data/skeletons/java.m4 b/data/skeletons/java.m4 index 920f34bc..984fd3ea 100644 --- a/data/skeletons/java.m4 +++ b/data/skeletons/java.m4 @@ -106,13 +106,20 @@ m4_define([b4_null], [null]) # b4_typed_parser_table_define(TYPE, NAME, DATA, COMMENT) # ------------------------------------------------------- +# We use intermediate functions (e.g., yypact_init) to work around the +# 64KB limit for JVM methods. See +# https://lists.gnu.org/r/help-bison/2008-11/msg00004.html. m4_define([b4_typed_parser_table_define], [m4_ifval([$4], [b4_comment([$4]) ])dnl -[private static final ]$1[[] yy$2_ = +[private static final ]$1[[] yy$2_ = yy$2_init (); + private static final ]$1[[] yy$2_init () { + return new ]$1[[] + { ]$3[ - };]]) + }; + }]]) # b4_integral_parser_table_define(NAME, DATA, COMMENT)