From 795890bc15220d242651c6c3bb2b54b9a15e557f Mon Sep 17 00:00:00 2001 From: Kamil Janecek Date: Wed, 22 Dec 2021 00:44:55 +0100 Subject: [PATCH 1/2] Update Byte Buddy to 1.12.6 + exclude net.bytebuddy.utility.Invoker from r8 process --- build.gradle | 2 +- r8-rules.txt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index f3f5d2a..ecebe8d 100644 --- a/build.gradle +++ b/build.gradle @@ -29,7 +29,7 @@ configurations { } dependencies { - implementation group: 'net.bytebuddy', name: 'byte-buddy-dep', version: '1.11.2' + implementation group: 'net.bytebuddy', name: 'byte-buddy-dep', version: '1.12.6' // byte buddy contains references to jna classes and without them the r8Jar step fails compileOnly group: 'net.java.dev.jna', name: 'jna', version: '5.8.0' diff --git a/r8-rules.txt b/r8-rules.txt index c1af55e..9c6fd8c 100644 --- a/r8-rules.txt +++ b/r8-rules.txt @@ -2,5 +2,7 @@ -allowaccessmodification -keepattributes SourceFile, LineNumberTable, *Annotation* +-keep class tech.httptoolkit.relocated.net.bytebuddy.utility.Invoker { *; } + -keep class tech.httptoolkit.javaagent.** { *; } -keep class tech.httptoolkit.relocated.net.bytebuddy.asm.** { *; } \ No newline at end of file From 682fa0c53f46b1dc0ab8913780d69f4737d2ac09 Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Tue, 4 Jan 2022 11:14:06 +0100 Subject: [PATCH 2/2] Fix minification of ByteBuddy 1.12.6 by disabling optimizations This allows us to limit the extra entry points to just the agent code. It does increase the JAR size by about 0.1MB (now 2.3MB in total) but it should be significantly less fragile and it's still much smaller than the raw JAR (4.8MB). 30% size increase, but at least half due to a real increase in size of ByteBuddy itself. --- build.gradle | 2 ++ r8-rules.txt | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ecebe8d..83ddfdd 100644 --- a/build.gradle +++ b/build.gradle @@ -143,11 +143,13 @@ task distJar(type: Jar) { // Pull raw advice classes from the shadow JAR, unminified: from (zipTree(shadowJar.getArchiveFile())) { include "tech/httptoolkit/javaagent/advice/**/*" + include "tech/httptoolkit/relocated/net/bytebuddy/agent/builder/**/*" } // Pull other source & bundled dependencies in their minified form, from R8: from (zipTree(r8Jar.outputs.files[0])) { exclude "tech/httptoolkit/javaagent/advice/**/*" + exclude "tech/httptoolkit/relocated/net/bytebuddy/agent/builder/**/*" } } diff --git a/r8-rules.txt b/r8-rules.txt index 9c6fd8c..d99a5c2 100644 --- a/r8-rules.txt +++ b/r8-rules.txt @@ -1,8 +1,9 @@ -dontobfuscate +-dontoptimize -allowaccessmodification -keepattributes SourceFile, LineNumberTable, *Annotation* --keep class tech.httptoolkit.relocated.net.bytebuddy.utility.Invoker { *; } +-keep class tech.httptoolkit.relocated.net.bytebuddy.agent.builder.** { *; } -keep class tech.httptoolkit.javaagent.** { *; } -keep class tech.httptoolkit.relocated.net.bytebuddy.asm.** { *; } \ No newline at end of file