Title: JaCoCo instrumentation of CCJSqlParser is approaching the constant-pool limit · Issue #2866 · JSQLParser/JSqlParser · GitHub
Open Graph Title: JaCoCo instrumentation of CCJSqlParser is approaching the constant-pool limit · Issue #2866 · JSQLParser/JSqlParser
X Title: JaCoCo instrumentation of CCJSqlParser is approaching the constant-pool limit · Issue #2866 · JSQLParser/JSqlParser
Description: Problem On current master (c84ad0ebc), JaCoCo instrumentation of the generated CCJSqlParser.class leaves only 808 entries before the class-file limit of 65,535 constant-pool entries. When the limit is exceeded, JaCoCo fails with ClassToo...
Open Graph Description: Problem On current master (c84ad0ebc), JaCoCo instrumentation of the generated CCJSqlParser.class leaves only 808 entries before the class-file limit of 65,535 constant-pool entries. When the limit...
X Description: Problem On current master (c84ad0ebc), JaCoCo instrumentation of the generated CCJSqlParser.class leaves only 808 entries before the class-file limit of 65,535 constant-pool entries. When the limit...
Opengraph URL: https://github.com/JSQLParser/JSqlParser/issues/2866
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"JaCoCo instrumentation of CCJSqlParser is approaching the constant-pool limit","articleBody":"### Problem\n\nOn current master (`c84ad0ebc`), JaCoCo instrumentation of the generated `CCJSqlParser.class` leaves only **808 entries** before the class-file limit of 65,535 constant-pool entries.\n\nWhen the limit is exceeded, JaCoCo fails with `ClassTooLargeException` and loads the parser without instrumentation. Tests still pass, but JaCoCo counts the parser as uncovered. Then `jacocoTestCoverageVerification` fails, and with it `./gradlew check` and the `gradle_check` CI job:\n\n```\nCaused by: org.jacoco.agent.rt.internal_29a6edd.asm.ClassTooLargeException: Class too large: net/sf/jsqlparser/parser/CCJSqlParser\nRule violated for bundle JSQLParser: instructions covered ratio is 0.21, but expected minimum is 0.50\n```\n\nThis happened on 2026-10-23 while combining grammar changes from #2847–#2849. Moving helpers into nested classes avoided the limit, but the remaining capacity is still small. Current master passes.\n\n### Root cause\n\nThe generated parser contains 5,591 methods, including 3,515 `jj_3*` lookahead routines. JaCoCo adds probes to measure coverage, and [probe IDs of 32,768 or more require an additional constant-pool entry each](https://www.jacoco.org/jacoco/trunk/doc/flow.html).\n\nMeasured on `c84ad0ebc`:\n\n| Metric | Value |\n|---|---:|\n| Constant pool before instrumentation | 46,304 |\n| JaCoCo probes | 51,180 |\n| Constant pool after instrumentation | 64,727 |\n| **Remaining entries** | **808** |\n\nGrammar additions can increase both the generated class size and the probe count.\n- The remaining room went from 8,161 entries on 2026-10-14 to 65 on 2026-10-22.\n- #2829 brought it back to 967, and it is already down to 808.\n- A typical grammar PR uses 10–65 entries.\n\n### Proposed short-term fix\n\nExclude only `CCJSqlParser.class` from:\n\n1. JaCoCo agent instrumentation.\n2. `jacocoTestReport`.\n3. `jacocoTestCoverageVerification`.\n\n```diff\n test {\n jacoco {\n- excludes = ['net/sf/jsqlparser/parser/CCJSqlParserTokenManager']\n+ excludes = ['net/sf/jsqlparser/parser/CCJSqlParserTokenManager',\n+ 'net/sf/jsqlparser/parser/CCJSqlParser']\n }\n }\n\n jacocoTestReport {\n ...\n+ afterEvaluate {\n+ classDirectories.setFrom(files(classDirectories.files.collect {\n+ fileTree(dir: it, exclude: [\n+ \"**/parser/CCJSqlParserTokenManager.class\",\n+ \"**/parser/CCJSqlParser.class\"\n+ ])\n+ }))\n+ }\n }\n\n jacocoTestCoverageVerification {\n // Jacoco can't handle the TokenManager class\n afterEvaluate {\n classDirectories.setFrom(files(classDirectories.files.collect {\n fileTree(dir: it, exclude: [\n- \"**CCJSqlParserTokenManager**\"\n+ \"**/parser/CCJSqlParserTokenManager.class\",\n+ \"**/parser/CCJSqlParser.class\"\n ])\n }))\n }\n```\n\nThe exact class exclusion keeps nested parser helpers, such as `CCJSqlParser$ObjectNames`, instrumented.\n\nI also found that the existing `CCJSqlParserTokenManager` exclusion does not work in coverage verification: its `**CCJSqlParserTokenManager**` pattern does not match the class-file path. The report also currently includes the uninstrumented TokenManager. The proposed change fixes both exclusions.\n\n**Verified on current master with all 12,262 tests:**\n\n| Coverage metric | Current | Proposed |\n|---|---:|---:|\n| Instruction coverage | 75.37% | 82.74% |\n| Missed lines | 14,892 | 7,336 |\n| Tests | Pass | Pass |\n\nThese numbers change because two classes leave the calculation, not because coverage improves:\n- The uninstrumented TokenManager (0%, 815 lines) is no longer counted.\n- The parser (82.19%, 6,741 missed lines) is no longer counted.\n\nBoth configurations pass the existing coverage thresholds.\n\n**Trade-off:** We lose direct coverage measurements for the generated parser, including its grammar branches. However, all parser tests still run, and other classes, including nested helpers, remain covered. If the parser is split later (see below), the exclusion can be reverted.\n\n### Longer-term solution: split the generated parser\n\nExcluding the parser from JaCoCo addresses the immediate issue. The parser itself, however, already uses 46,304 constant-pool entries without instrumentation, and javac fails with \"too many constants\" beyond 65,535. For comparison, it used 12,266 in 5.3 and 34,231 in 5.4.\n\nTwo contributors to its size are:\n\n- **Lookahead routines:** 3,515 `jj_3*` methods generated into one class.\n- **Grammar locations:** since 5.4, `jj_consume_token` and `jj_scan_token` calls pass grammar locations such as `\"18424:7\"`, which are used in parse error messages. There are 7,353 distinct location strings, taking about 14,700 constant-pool entries (32% of the pool).\n\nI tested a small proof of concept that moves the `jj_3*` routines into a non-static inner class while preserving their method bodies.\n\n| Metric | Master | PoC |\n|---|---:|---:|\n| Parser constant pool (uninstrumented) | 46,304 | 37,834 |\n| Remaining entries after JaCoCo | 808 | 23,451 |\n| Tests | 12,262 passed | 12,262 passed |\n\nThe new inner class uses 17,060 entries and has 48,454 left after instrumentation. The parser remains instrumented, and preliminary performance measurements showed no clear difference (not a JMH benchmark).\n\nThis would require a change in the JavaCC 8 generator (`manticore-projects/javacc-8-java`) rather than JSQLParser's build configuration. It would substantially increase headroom, but it does not stop growth: applied to the 2026-10-14 parser, the parser class still used 5,637 entries over the following two weeks. Continued grammar growth and the location strings would still need attention.\n\nIf this direction is interesting, I can open a separate issue in `manticore-projects/javacc-8-java` with the PoC and measurements.\n\n### Additional notes\n\n- **Maven:** `mvn verify` does not enforce JaCoCo coverage thresholds, but its agent can encounter the same instrumentation failure. Consistent exclusions would require updating both `prepare-agent` and `report`.\n- **Verification rules:** The existing rule-level `excludes` have no effect, because the rules use the default `BUNDLE` element and the lists are matched against the bundle name. The proposed `classDirectories` exclusions remove only the two parser classes; the rule-level lists are left unchanged.\n- **Measurement:** The remaining capacity was measured using JaCoCo's `Instrumenter`. JaCoCo 0.8.14 and 0.8.15 produced the same result.\n\n\u003cdetails>\n\u003csummary>Measurement code\u003c/summary>\n\n```java\nimport java.nio.file.Files;\nimport java.nio.file.Path;\nimport org.jacoco.core.instr.Instrumenter;\nimport org.jacoco.core.runtime.OfflineInstrumentationAccessGenerator;\n\npublic class JacocoHeadroom {\n public static void main(String[] args) throws Exception {\n byte[] original = Files.readAllBytes(Path.of(args[0]));\n byte[] instrumented = new Instrumenter(new OfflineInstrumentationAccessGenerator())\n .instrument(original, \"CCJSqlParser\");\n int count = ((instrumented[8] & 0xff) \u003c\u003c 8) | (instrumented[9] & 0xff);\n System.out.println(\"constant_pool_count=\" + count + \" left=\" + (65535 - count));\n }\n}\n```\n\nThe agent's runtime access code differs slightly from the offline one, so treat the number as approximate.\n\n\u003c/details>\n\nI'm happy to prepare a PR for the short-term fix if this approach is acceptable.\n\nAI assistance: prepared with Claude Code.\n","author":{"url":"https://github.com/minleejae","@type":"Person","name":"minleejae"},"datePublished":"2026-10-28T04:59:09Z","url":"https://github.com/JSQLParser/JSqlParser/issues/2866"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7430e8e4-f95d-a808-1488-e70294b2d8a6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DE20:367E0F:4DD23E:690BB3:6B043DD2 |
| html-safe-nonce | 83946a7cb437f855bf689d92231717ff0cef7feef6294748045767c1a8dfb4e9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERTIwOjM2N0UwRjo0REQyM0U6NjkwQkIzOjZCMDQzREQyIiwidmlzaXRvcl9pZCI6IjE1NTg1OTYyMzQyNTQ3NjE0MjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 214ea45e2223f2dc596b3ee6ad462e41a1800aacdd9a271ccef42b834a803367 |
| hovercard-subject-tag | issue:6072913886 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/JSQLParser/JSqlParser/2866/issue_layout |
| twitter:image | https://opengraph.githubassets.com/de610f71cdf29cba444e6eb3ad661275df6d69fd5b0e1f5c16d0b2c0c64a9504/JSQLParser/JSqlParser/issues/2866 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/de610f71cdf29cba444e6eb3ad661275df6d69fd5b0e1f5c16d0b2c0c64a9504/JSQLParser/JSqlParser/issues/2866 |
| og:image:alt | Problem On current master (c84ad0ebc), JaCoCo instrumentation of the generated CCJSqlParser.class leaves only 808 entries before the class-file limit of 65,535 constant-pool entries. When the limit... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | minleejae |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9185ccfefd80c1ff2d9ddcdb0cd2becf46b5a1efbbf30741a895e4bb8de25e64 |
| turbo-cache-control | no-preview |
| go-import | github.com/JSQLParser/JSqlParser git https://github.com/JSQLParser/JSqlParser.git |
| octolytics-dimension-user_id | 4643847 |
| octolytics-dimension-user_login | JSQLParser |
| octolytics-dimension-repository_id | 1944709 |
| octolytics-dimension-repository_nwo | JSQLParser/JSqlParser |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1944709 |
| octolytics-dimension-repository_network_root_nwo | JSQLParser/JSqlParser |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 06dc448a76fe4751ac1db26524aefa3aa3e889a8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width