From 68640618d61c340f32cece82e741478eb6ff7b05 Mon Sep 17 00:00:00 2001 From: Fergal Whyte Date: Mon, 2 Sep 2024 12:27:40 +0200 Subject: [PATCH 1/2] Update aggregate-javadoc plugin --- build.gradle | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 0ff7fef09..c5130ab12 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ plugins { id "org.jetbrains.kotlin.jvm" version "$kotlinVersion" apply false id 'com.adarshr.test-logger' version '3.0.0' apply false id "org.sonarqube" version "3.4.0.2513" - id "io.freefair.aggregate-javadoc" version "6.5.0.3" + id "io.freefair.aggregate-javadoc" version "8.10" id "com.diffplug.spotless" version "6.13.0" apply false } @@ -75,14 +75,22 @@ allprojects { } } -aggregateJavadoc { +dependencies { + rootProject.subprojects { subproject -> + subproject.plugins.withId("java") { + javadoc subproject + } + } +} + +javadoc { title = 'ProGuardCORE' destinationDir = file('docs/md/api') options.addStringOption('Xdoclint:none', '-quiet') } task buildDocumentation(type: Exec) { - dependsOn aggregateJavadoc + dependsOn javadoc inputs.dir 'docs/md' inputs.file 'docs/mkdocs.yml' outputs.dir 'docs/html' @@ -91,7 +99,7 @@ task buildDocumentation(type: Exec) { } clean { - delete aggregateJavadoc.outputs + delete javadoc.outputs //delete buildDocumentation.outputs } @@ -122,11 +130,11 @@ distributions { distTar { compression = Compression.GZIP archiveExtension.set('tar.gz') - dependsOn('aggregateJavadoc') + dependsOn('javadoc') } distZip { - dependsOn('aggregateJavadoc') + dependsOn('javadoc') } nexusPublishing { From 60ee99a9c8475c4d5934b264ad6ace01f23ba52a Mon Sep 17 00:00:00 2001 From: Fergal Whyte Date: Mon, 7 Oct 2024 11:20:23 +0200 Subject: [PATCH 2/2] Allow indeterminate code fragment length in CodeAttributeComposer --- .../editor/CodeAttributeComposer.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/base/src/main/java/proguard/classfile/editor/CodeAttributeComposer.java b/base/src/main/java/proguard/classfile/editor/CodeAttributeComposer.java index 80256550d..ec5ed05d6 100644 --- a/base/src/main/java/proguard/classfile/editor/CodeAttributeComposer.java +++ b/base/src/main/java/proguard/classfile/editor/CodeAttributeComposer.java @@ -291,6 +291,7 @@ public void appendInstruction(int oldInstructionOffset, Instruction instruction) int newCodeLength = codeLength + instruction.length(codeLength); ensureCodeLength(newCodeLength); + ensureFragmentLength(oldInstructionOffset + 1); // Remember the old offset of the appended instruction. oldInstructionOffsets[codeLength] = oldInstructionOffset; @@ -325,6 +326,7 @@ public void appendLabel(int oldInstructionOffset) { // Make sure the code and offset arrays are large enough. ensureCodeLength(codeLength + 1); + ensureFragmentLength(oldInstructionOffset + 1); // Remember the old offset of the following instruction. oldInstructionOffsets[codeLength] = oldInstructionOffset; @@ -1067,6 +1069,22 @@ private void ensureCodeLength(int newCodeLength) { } } + /** Make sure the code fragment offset array have at least the given size. */ + private void ensureFragmentLength(int newFragmentLength) { + if (codeFragmentLengths[level] < newFragmentLength) { + codeFragmentLengths[level] = newFragmentLength; + + int oldFragmentLength = instructionOffsetMap[level].length; + if (newFragmentLength > oldFragmentLength) { + // Add 20% to avoid extending the arrays too often. + newFragmentLength = newFragmentLength * 6 / 5; + instructionOffsetMap[level] = + ArrayUtil.extendArray(instructionOffsetMap[level], newFragmentLength); + Arrays.fill(instructionOffsetMap[level], oldFragmentLength, newFragmentLength, INVALID); + } + } + } + /** Adjusts the given jump offsets for the instruction at the given offset. */ private void updateJumpOffsets(int offset, int[] jumpOffsets) { for (int index = 0; index < jumpOffsets.length; index++) {