From e62e7aa2815e3895dd5dd0a605c8197c95f57728 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sat, 1 Jul 2023 12:37:07 +0200 Subject: [PATCH] Add description --- .../internal/plugins/SystemModulesPlugin.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModulesPlugin.java b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModulesPlugin.java index 88dd2d5e22b..bbd2448d493 100644 --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModulesPlugin.java +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModulesPlugin.java @@ -697,6 +697,20 @@ private void genModuleDescriptorsMethod(ClassBuilder clb) { return; } + // Instead of adding the module descriptor calls in this method, + // helper methods are created in separate helper methods. + // Let m1, m2, ..., mn be the calls to the module descriptor builder + // Here, n is larger than moduleDescriptorsPerMethod, which will hit the 64kb limit of method length. + // thus, we create f1, f2, ... where + // - f1 calls m1, ... m_{moduleDescriptorsPerMethod-1}, + // - f2 calls m_{moduleDescriptorsPerMethod}, ... m_{2xmoduleDescriptorsPerMethod-1}, + // - etc. + // + // Inside m, the class SystemModulesClassGenerator.DedupSetBuilder is used. + // That class creates sets caching variables. It stores its caches in the local storage. + // Since the local storage is destroyed across each method, but the sets are needed across methods, + // the local variables are passed on to the next helper method using a list of these variables. + List> splitModuleInfos = new ArrayList<>(); List currentModuleInfos = null; for (int index = 0; index < moduleInfos.size(); index++) {