Skip to content

Commit

Permalink
Use byte-buddy-dep instead of byte-buddy (#4400)
Browse files Browse the repository at this point in the history
* Use byte-buddy-dep instead of byte-buddy

* print stacktrace on examples failure

* try to fix gradle plugins

* try to fix extension build

* try to fix extension build

* try to fix extension build

* try to fix extension build

* try removing mavenLocal

* add mavenLocal plugin repository

* publish gradle-plugins to mavenLocal for examples ci build

* Fix bytebuddy exclusion
  • Loading branch information
laurit committed Oct 19, 2021
1 parent be55b2a commit 17a85bb
Show file tree
Hide file tree
Showing 35 changed files with 108 additions and 99 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ jobs:
# javadoc task fails sporadically fetching https://docs.oracle.com/javase/8/docs/api/
run: ./gradlew publishToMavenLocal -x javadoc

- name: Local publish gradle plugin
run: ../gradlew publishToMavenLocal -x javadoc
working-directory: gradle-plugins

- name: Build distro
run: ./gradlew build --init-script ../../.github/scripts/local.init.gradle.kts
working-directory: examples/distro
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,16 @@ jobs:
# javadoc task fails sporadically fetching https://docs.oracle.com/javase/8/docs/api/
run: ./gradlew publishToMavenLocal -x javadoc

- name: Local publish gradle plugin
run: ../gradlew publishToMavenLocal -x javadoc
working-directory: gradle-plugins

- name: Build distro
run: ./gradlew build --init-script ../../.github/scripts/local.init.gradle.kts
run: ./gradlew build --init-script ../../.github/scripts/local.init.gradle.kts --stacktrace
working-directory: examples/distro

- name: Build extension
run: ./gradlew build --init-script ../../.github/scripts/local.init.gradle.kts
run: ./gradlew build --init-script ../../.github/scripts/local.init.gradle.kts --stacktrace
working-directory: examples/extension

accept-pr:
Expand Down
4 changes: 2 additions & 2 deletions conventions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ dependencies {
implementation("org.ow2.asm:asm-tree:9.1")
implementation("org.apache.httpcomponents:httpclient:4.5.13")
implementation("org.gradle:test-retry-gradle-plugin:1.2.1")
// When updating, also update dependencyManagement/dependencyManagement.gradle.kts
implementation("net.bytebuddy:byte-buddy-gradle-plugin:1.11.18")
// When updating, also update dependencyManagement/build.gradle.kts
implementation("net.bytebuddy:byte-buddy-gradle-plugin:1.11.20")
implementation("gradle.plugin.io.morethan.jmhreport:gradle-jmh-report:0.9.0")
implementation("me.champeau.jmh:jmh-gradle-plugin:0.6.5")
implementation("net.ltgt.gradle:gradle-errorprone-plugin:2.0.1")
Expand Down
6 changes: 3 additions & 3 deletions dependencyManagement/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ val DEPENDENCY_SETS = listOf(
),
DependencySet(
"net.bytebuddy",
// When updating, also update buildSrc/build.gradle.kts
"1.11.18",
listOf("byte-buddy", "byte-buddy-agent", "byte-buddy-gradle-plugin")
// When updating, also update conventions/build.gradle.kts
"1.11.20",
listOf("byte-buddy", "byte-buddy-dep", "byte-buddy-agent", "byte-buddy-gradle-plugin")
),
DependencySet(
"org.openjdk.jmh",
Expand Down
3 changes: 1 addition & 2 deletions examples/distro/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ subprojects {
]

deps = [
bytebuddy : "net.bytebuddy:byte-buddy:${versions.bytebuddy}",
bytebuddyagent : "net.bytebuddy:byte-buddy-agent:${versions.bytebuddy}",
bytebuddy : "net.bytebuddy:byte-buddy-dep:${versions.bytebuddy}",
autoservice : [
"com.google.auto.service:auto-service:1.0-rc7",
"com.google.auto:auto-common:0.8",
Expand Down
1 change: 1 addition & 0 deletions examples/extension/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots")
Expand Down
13 changes: 11 additions & 2 deletions gradle-plugins/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,18 @@ repositories {
mavenCentral()
}

val bbGradlePlugin by configurations.creating
configurations.named("compileOnly") {
extendsFrom(bbGradlePlugin)
}

dependencies {
implementation("com.google.guava:guava:30.1.1-jre")
implementation("net.bytebuddy:byte-buddy-gradle-plugin:1.11.18")
// we need to use byte buddy variant that does not shade asm
implementation("net.bytebuddy:byte-buddy-gradle-plugin:1.11.20") {
exclude(group = "net.bytebuddy", module = "byte-buddy")
}
implementation("net.bytebuddy:byte-buddy-dep:1.11.20")

implementation("org.eclipse.aether:aether-connector-basic:1.1.0")
implementation("org.eclipse.aether:aether-transport-http:1.1.0")
Expand Down Expand Up @@ -72,4 +81,4 @@ tasks {
publishPlugins {
enabled = !version.toString().contains("SNAPSHOT")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ dependencies {
testImplementation(project(":instrumentation-api"))
testImplementation(project(":javaagent-extension-api"))
testImplementation(project(":javaagent-tooling"))
testImplementation("net.bytebuddy:byte-buddy")
testImplementation(project(":instrumentation:external-annotations:javaagent"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
import net.bytebuddy.description.method.MethodList;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.implementation.Implementation;
import net.bytebuddy.jar.asm.ClassVisitor;
import net.bytebuddy.jar.asm.ClassWriter;
import net.bytebuddy.jar.asm.MethodVisitor;
import net.bytebuddy.jar.asm.Opcodes;
import net.bytebuddy.jar.asm.Type;
import net.bytebuddy.matcher.ElementMatcher;
import net.bytebuddy.pool.TypePool;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;

public class InnerClassLambdaMetafactoryInstrumentation implements TypeInstrumentation {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies {

testImplementation("io.opentelemetry:opentelemetry-extension-annotations")
testImplementation(project(":instrumentation-api-annotation-support"))
testImplementation("net.bytebuddy:byte-buddy:${versions["net.bytebuddy"]}")
testImplementation("net.bytebuddy:byte-buddy")
}

tasks {
Expand Down
2 changes: 1 addition & 1 deletion javaagent-extension-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ group = "io.opentelemetry.javaagent"

dependencies {
api("io.opentelemetry:opentelemetry-sdk")
api("net.bytebuddy:byte-buddy")
api("net.bytebuddy:byte-buddy-dep")

implementation(project(":instrumentation-api"))
implementation(project(":javaagent-instrumentation-api"))
Expand Down
2 changes: 1 addition & 1 deletion javaagent-tooling/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies {
// Other exporters are in javaagent-exporters
implementation("io.opentelemetry:opentelemetry-exporter-logging")

api("net.bytebuddy:byte-buddy")
api("net.bytebuddy:byte-buddy-dep")
implementation("org.slf4j:slf4j-api")

annotationProcessor("com.google.auto.service:auto-service")
Expand Down
2 changes: 1 addition & 1 deletion javaagent-tooling/javaagent-tooling-java9/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ group = "io.opentelemetry.javaagent"
dependencies {
implementation(project(":javaagent-bootstrap"))

implementation("net.bytebuddy:byte-buddy")
implementation("net.bytebuddy:byte-buddy-dep")
implementation("org.slf4j:slf4j-api")

testImplementation("net.bytebuddy:byte-buddy-agent")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,23 @@

package io.opentelemetry.javaagent.tooling;

import static net.bytebuddy.jar.asm.Opcodes.ACC_FINAL;
import static net.bytebuddy.jar.asm.Opcodes.ACC_PRIVATE;
import static net.bytebuddy.jar.asm.Opcodes.ACC_PUBLIC;
import static net.bytebuddy.jar.asm.Opcodes.ACC_STATIC;
import static net.bytebuddy.jar.asm.Opcodes.ACC_SUPER;
import static net.bytebuddy.jar.asm.Opcodes.ALOAD;
import static net.bytebuddy.jar.asm.Opcodes.DUP;
import static net.bytebuddy.jar.asm.Opcodes.GETSTATIC;
import static net.bytebuddy.jar.asm.Opcodes.ILOAD;
import static net.bytebuddy.jar.asm.Opcodes.INVOKESPECIAL;
import static net.bytebuddy.jar.asm.Opcodes.INVOKESTATIC;
import static net.bytebuddy.jar.asm.Opcodes.INVOKEVIRTUAL;
import static net.bytebuddy.jar.asm.Opcodes.IRETURN;
import static net.bytebuddy.jar.asm.Opcodes.NEW;
import static net.bytebuddy.jar.asm.Opcodes.PUTSTATIC;
import static net.bytebuddy.jar.asm.Opcodes.RETURN;
import static org.objectweb.asm.Opcodes.ACC_FINAL;
import static org.objectweb.asm.Opcodes.ACC_PRIVATE;
import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
import static org.objectweb.asm.Opcodes.ACC_STATIC;
import static org.objectweb.asm.Opcodes.ACC_SUPER;
import static org.objectweb.asm.Opcodes.ALOAD;
import static org.objectweb.asm.Opcodes.DUP;
import static org.objectweb.asm.Opcodes.GETSTATIC;
import static org.objectweb.asm.Opcodes.ILOAD;
import static org.objectweb.asm.Opcodes.INVOKESPECIAL;
import static org.objectweb.asm.Opcodes.INVOKESTATIC;
import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
import static org.objectweb.asm.Opcodes.IRETURN;
import static org.objectweb.asm.Opcodes.NEW;
import static org.objectweb.asm.Opcodes.PUTSTATIC;
import static org.objectweb.asm.Opcodes.RETURN;
import static org.objectweb.asm.Opcodes.V1_5;

import io.opentelemetry.javaagent.bootstrap.AgentClassLoader;
import java.lang.reflect.Field;
Expand All @@ -31,12 +32,11 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import net.bytebuddy.jar.asm.ClassVisitor;
import net.bytebuddy.jar.asm.ClassWriter;
import net.bytebuddy.jar.asm.FieldVisitor;
import net.bytebuddy.jar.asm.MethodVisitor;
import net.bytebuddy.jar.asm.Opcodes;
import net.bytebuddy.jar.asm.Type;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Type;

/**
* Helper class for generating our own copy of sun.misc.Unsafe that delegates to
Expand Down Expand Up @@ -294,13 +294,7 @@ private static class MethodDescriptor {
private byte[] getBytes() {
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
ClassVisitor cv = cw;
cv.visit(
Opcodes.V1_5,
ACC_PUBLIC | ACC_FINAL | ACC_SUPER,
UNSAFE_NAME,
null,
"java/lang/Object",
null);
cv.visit(V1_5, ACC_PUBLIC | ACC_FINAL | ACC_SUPER, UNSAFE_NAME, null, "java/lang/Object", null);

{
FieldVisitor fv =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import java.security.Permission;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import net.bytebuddy.jar.asm.ClassReader;
import net.bytebuddy.jar.asm.ClassWriter;
import net.bytebuddy.jar.asm.commons.ClassRemapper;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.commons.ClassRemapper;

public class RemappingUrlConnection extends URLConnection {
// We need to prefix the names to prevent the gradle shadowJar relocation rules from touching
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import java.util.Map;
import java.util.TreeMap;
import net.bytebuddy.jar.asm.commons.Remapper;
import org.objectweb.asm.commons.Remapper;

public class ShadingRemapper extends Remapper {
public static class Rule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import net.bytebuddy.asm.Advice.ExceptionHandler;
import net.bytebuddy.implementation.Implementation;
import net.bytebuddy.implementation.bytecode.StackManipulation;
import net.bytebuddy.jar.asm.Label;
import net.bytebuddy.jar.asm.MethodVisitor;
import net.bytebuddy.jar.asm.Opcodes;
import net.bytebuddy.jar.asm.Type;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
import net.bytebuddy.description.method.MethodList;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.implementation.Implementation;
import net.bytebuddy.jar.asm.ClassVisitor;
import net.bytebuddy.jar.asm.ClassWriter;
import net.bytebuddy.jar.asm.FieldVisitor;
import net.bytebuddy.jar.asm.MethodVisitor;
import net.bytebuddy.jar.asm.Opcodes;
import net.bytebuddy.pool.TypePool;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;

final class RealFieldInjector implements AsmVisitorWrapper {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
import net.bytebuddy.description.method.MethodList;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.implementation.Implementation;
import net.bytebuddy.jar.asm.ClassVisitor;
import net.bytebuddy.jar.asm.ClassWriter;
import net.bytebuddy.jar.asm.Label;
import net.bytebuddy.jar.asm.MethodVisitor;
import net.bytebuddy.jar.asm.Opcodes;
import net.bytebuddy.jar.asm.Type;
import net.bytebuddy.pool.TypePool;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;

final class VirtualFieldFindRewriter implements AsmVisitorWrapper {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.dynamic.DynamicType;
import net.bytebuddy.implementation.Implementation;
import net.bytebuddy.jar.asm.ClassVisitor;
import net.bytebuddy.jar.asm.ClassWriter;
import net.bytebuddy.jar.asm.Label;
import net.bytebuddy.jar.asm.MethodVisitor;
import net.bytebuddy.jar.asm.Opcodes;
import net.bytebuddy.pool.TypePool;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;

final class VirtualFieldImplementationsGenerator {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import io.opentelemetry.javaagent.tooling.bytebuddy.matcher.testclasses.F
import io.opentelemetry.javaagent.tooling.bytebuddy.matcher.testclasses.G
import io.opentelemetry.javaagent.tooling.muzzle.AgentTooling
import net.bytebuddy.description.type.TypeDescription
import net.bytebuddy.jar.asm.Opcodes
import org.objectweb.asm.Opcodes
import spock.lang.Shared
import spock.lang.Specification

Expand Down
2 changes: 1 addition & 1 deletion muzzle/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies {
compileOnly("com.google.auto.value:auto-value-annotations")
annotationProcessor("com.google.auto.value:auto-value")

api("net.bytebuddy:byte-buddy")
api("net.bytebuddy:byte-buddy-dep")

implementation(project(":javaagent-bootstrap"))
implementation(project(":instrumentation-api"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.io.StringWriter;
import java.util.Collection;
import java.util.Collections;
import net.bytebuddy.jar.asm.Type;
import org.objectweb.asm.Type;

/**
* A mismatch between a {@link ClassRef} and a runtime class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.bytebuddy.jar.asm.ClassVisitor;
import net.bytebuddy.jar.asm.FieldVisitor;
import net.bytebuddy.jar.asm.Handle;
import net.bytebuddy.jar.asm.Label;
import net.bytebuddy.jar.asm.MethodVisitor;
import net.bytebuddy.jar.asm.Opcodes;
import net.bytebuddy.jar.asm.Type;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Handle;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;

/** Visit a class and collect all references made by the visited class. */
// Additional things we could check
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import java.util.regex.Pattern;
import javax.annotation.Nullable;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.jar.asm.ClassReader;
import org.objectweb.asm.ClassReader;

/**
* {@link LinkedHashMap} is used for reference map to guarantee a deterministic order of iteration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import net.bytebuddy.description.field.FieldDescription;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.jar.asm.Type;
import net.bytebuddy.pool.TypePool;
import org.objectweb.asm.Type;

/** Matches a set of references against a classloader. */
public final class ReferenceMatcher {
Expand Down
Loading

0 comments on commit 17a85bb

Please sign in to comment.