Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update byte buddy to 1.14.5 #151

Merged
merged 4 commits into from
Sep 23, 2023
Merged

Conversation

nvollmar
Copy link
Contributor

@nvollmar nvollmar commented Aug 7, 2023

Refs #150

@ivantopo
Copy link
Contributor

ivantopo commented Aug 9, 2023

Hey @nvollmar, thanks for the attempt but I think this is not something we can get in as-is. My understanding is that @dpsoft has a few minor modifications in bytebuddy that he always applies on top of the official version and that's why we have to do some manual intervention all the time to upgrade the bytebuddy dependency.

@dpsoft could you maybe drop here the changes you apply to make this happen?

@nvollmar
Copy link
Contributor Author

nvollmar commented Aug 9, 2023

Yes, I saw that when I tried to find the issue. At least the pom in the jar was modified - now one of the asm dependencies is missing.

@dpsoft
Copy link
Contributor

dpsoft commented Aug 9, 2023

@nvollmar the changes to apply to bytebuddy in order to avoid some issues when instrumenting scala stuff are:

diff --git a/byte-buddy-dep/pom.xml b/byte-buddy-dep/pom.xml
index 376c2b9c2a..51c63c3575 100644
--- a/byte-buddy-dep/pom.xml
+++ b/byte-buddy-dep/pom.xml
@@ -48,10 +48,6 @@
                     <groupId>org.ow2.asm</groupId>
                     <artifactId>asm-analysis</artifactId>
                 </exclusion>
-                <exclusion>
-                    <groupId>org.ow2.asm</groupId>
-                    <artifactId>asm-tree</artifactId>
-                </exclusion>
             </exclusions>
         </dependency>
         <dependency>
diff --git a/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/scaffold/InstrumentedType.java b/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/scaffold/InstrumentedType.java
index 22b400395a..3c63ecb153 100644
--- a/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/scaffold/InstrumentedType.java
+++ b/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/scaffold/InstrumentedType.java
@@ -43,7 +43,8 @@ import static net.bytebuddy.matcher.ElementMatchers.is;
 import static net.bytebuddy.matcher.ElementMatchers.not;
 
 /**
- * Implementations of this interface represent an instrumented type that is subject to change. Implementations
+ * Implementations of this 
+  represent an instrumented type that is subject to change. Implementations
  * should however be immutable and return new instance when its builder methods are invoked.
  */
 public interface InstrumentedType extends TypeDescription {
@@ -508,10 +509,10 @@ public interface InstrumentedType extends TypeDescription {
          * A set containing all keywords of the Java programming language.
          */
         private static final Set<String> KEYWORDS = new HashSet<String>(Arrays.asList(
-                "abstract", "continue", "for", "new", "switch", "assert", "default", "goto", "package", "synchronized", "boolean",
+                "abstract", "continue", "for", "new", "switch", "assert", "goto", "package", "synchronized", "boolean",
                 "do", "if", "private", "this", "break", "double", "implements", "protected", "throw", "byte", "else", "import",
                 "public", "throws", "case", "enum", "instanceof", "return", "transient", "catch", "extends", "int", "short",
-                "try", "char", "final", "interface", "static", "void", "class", "finally", "long", "strictfp", "volatile",
+                "try", "char", "final", "static", "void", "class", "finally", "long", "strictfp", "volatile",
                 "const", "float", "native", "super", "while"
         ));
 
diff --git a/byte-buddy/pom.xml b/byte-buddy/pom.xml
index 5ccc8bab99..63a5e513a7 100644
--- a/byte-buddy/pom.xml
+++ b/byte-buddy/pom.xml
@@ -105,6 +105,82 @@
             </resource>
         </resources>
         <plugins>
+
+            <!-- Shade the ASM dependency. 
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-shade-plugin</artifactId>
+                <version>${version.plugin.shade}</version>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>shade</goal>
+                        </goals>
+                        <configuration>
+                            <shadedArtifactAttached>false</shadedArtifactAttached>
+                            <createDependencyReducedPom>true</createDependencyReducedPom>
+                            <createSourcesJar>${bytebuddy.extras}</createSourcesJar>
+                            <shadeSourcesContent>true</shadeSourcesContent>
+                            <relocations>
+                                <relocation>
+                                    <pattern>${shade.source}</pattern>
+                                    <shadedPattern>${shade.target}</shadedPattern>
+                                </relocation>
+                            </relocations>
+                             <filters>
+                                <filter>
+                                    <artifact>net.bytebuddy:byte-buddy-dep:*</artifact>
+                                    <excludes>
+                                        <exclude>META-INF/MANIFEST.MF</exclude>
+                                    </excludes>
+                                </filter>
+                                <filter>
+                                    <artifact>org.ow2.asm:*</artifact>
+                                    <excludes>
+                                        <exclude>META-INF/MANIFEST.MF</exclude>
+                                        <exclude>**/module-info.class</exclude>
+                                        <exclude>**/LICENSE</exclude>
+                                        <exclude>**/NOTICE</exclude>
+                                    </excludes>
+                                </filter>
+                                <filter>
+                                    <artifact>org.ow2.asm:asm-commons</artifact>
+                                </filter>
+                                <filter>
+                                    <artifact>org.ow2.asm:asm-tree</artifact>
+                                </filter>
+                            </filters>
+                            <transformers>
+                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+                                    <mainClass>net.bytebuddy.build.Plugin$Engine$Default</mainClass>
+                                </transformer>
+                                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+                                    <resource>META-INF/LICENSE</resource>
+                                </transformer>
+                            </transformers>
+                        </configuration>
+                    </execution>
+                </executions>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.ow2.asm</groupId>
+                        <artifactId>asm</artifactId>
+                        <version>${version.asm}</version>
+                    </dependency>
+                    <dependency>
+                        <groupId>org.ow2.asm</groupId>
+                        <artifactId>asm-commons</artifactId>
+                        <version>${version.asm}</version>
+                    </dependency>
+                    <dependency>
+                        <groupId>org.ow2.asm</groupId>
+                        <artifactId>asm-tree</artifactId>
+                        <version>${version.asm}</version>
+                    </dependency>
+                </dependencies>
+            </plugin>
+-->
             <!-- Disable pitest as it fails for empty modules -->
             <plugin>
                 <groupId>org.pitest</groupId>
@@ -276,6 +352,7 @@
                                                 <exclude>**/NOTICE</exclude>
                                             </excludes>
                                         </filter>
+                                         <!-- 
                                         <filter>
                                             <artifact>org.ow2.asm:asm-commons</artifact>
                                             <includes>
@@ -291,6 +368,7 @@
                                                 <include>org/objectweb/asm/commons/SimpleRemapper.**</include>
                                             </includes>
                                         </filter>
+                                        -->
                                     </filters>
                                     <transformers>
                                         <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">

Then just run(java 8):

mvn clean package -Pextras -Dskiptests

Enjoy!

@nvollmar
Copy link
Contributor Author

nvollmar commented Aug 9, 2023

Thanks for the hints. I'll see if I can get that working.

@nvollmar
Copy link
Contributor Author

@ivantopo I patched byte-buddy as advised and the tests are locally running now.

@nvollmar
Copy link
Contributor Author

Looks like com.github.maiflai.scalatest is not maintained anymore and the last version is incompatible with Gradle 8.0+:

Could not find method isEnabled() for arguments [] on Report junitXml of type org.gradle.api.internal.tasks.testing.DefaultJUnitXmlReport.

@nvollmar
Copy link
Contributor Author

@ivantopo / @dpsoft How should we proceed? It should be building now with latest bytebuddy on JDK <20.

@danischroeter
Copy link
Contributor

@ivantopo / @dpsoft Is there some additional work needed here or could this pr be merged? Could you do it pls?
Side question: why is this project built using gradle and not sbt? The issue with gradle's scalatest plugin would seems to be a blocker for the future 🤔

@dpsoft dpsoft merged commit 9853321 into kamon-io:master Sep 23, 2023
@danischroeter
Copy link
Contributor

thx @dpsoft !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants