From 1bc4f79950b05922c0a7a071626e58c898c895b7 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sat, 1 Jul 2023 13:21:43 +0200 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Mandy Chung --- .../jlink/internal/plugins/SystemModulesPlugin.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 bbd2448d493..7f65e78af6d 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 @@ -721,7 +721,7 @@ private void genModuleDescriptorsMethod(ClassBuilder clb) { currentModuleInfos.add(moduleInfos.get(index)); } - final String helperMethodNamePrefix = "moduleDescriptorsSub"; + String helperMethodNamePrefix = "sub"; final ClassDesc arrayListClassDesc = ClassDesc.ofInternalName("java/util/ArrayList"); final int firstVariableForDedup = nextLocalVar; @@ -750,14 +750,15 @@ private void genModuleDescriptorsMethod(ClassBuilder clb) { .areturn(); }); - final int[] globalCount = {0}; - for (final int[] index = {0}; index[0] < splitModuleInfos.size(); index[0]++) { + for (int n = 0, count = 0; n < splitModuleInfos.size(); count += splitModuleInfos.get(n).size(), n++) { + int index = n; // the index of which ModuleInfo being processed in the current batch + int start = count; // the start index to the return ModuleDescriptor array for the current batch clb.withMethodBody( helperMethodNamePrefix + index[0], MethodTypeDesc.of(CD_void, CD_MODULE_DESCRIPTOR.arrayType(), arrayListClassDesc), ACC_PUBLIC, cob -> { - List moduleInfosPackage = splitModuleInfos.get(index[0]); + List currentBatch = splitModuleInfos.get(index[0]); if (nextLocalVar > firstVariableForDedup) { for (int i = nextLocalVar-1; i >= firstVariableForDedup; i--) {