Use class literals where possible
MODIFY
instrumentation/classloaders/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/javaclassloader/ClassLoaderInstrumentation.java
instrumentation/classloaders/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/javaclassloader/ClassLoaderInstrumentation.java
@@ -62,11 +62,11 @@ public class ClassLoaderInstrumentation implements TypeInstrumentation {
.and(named("loadClass"))
.and(
takesArguments(1)
- .and(takesArgument(0, named("java.lang.String")))
+ .and(takesArgument(0, String.class))
.or(
takesArguments(2)
- .and(takesArgument(0, named("java.lang.String")))
- .and(takesArgument(1, named("boolean")))))
+ .and(takesArgument(0, String.class))
+ .and(takesArgument(1, boolean.class))))
.and(isPublic().or(isProtected()))
.and(not(isStatic())),
ClassLoaderInstrumentation.class.getName() + "$LoadClassAdvice");

MODIFY
instrumentation/couchbase/couchbase-2.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_6/CouchbaseNetworkInstrumentation.java
instrumentation/couchbase/couchbase-2.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_6/CouchbaseNetworkInstrumentation.java
@@ -21,6 +21,7 @@ import io.opentelemetry.javaagent.instrumentation.api.ContextStore;
import io.opentelemetry.javaagent.instrumentation.api.InstrumentationContext;
import io.opentelemetry.javaagent.tooling.TypeInstrumentation;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
+import java.util.List;
import java.util.Map;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
@@ -52,7 +53,7 @@ public class CouchbaseNetworkInstrumentation implements TypeInstrumentation {
.and(
takesArgument(
0, named("com.couchbase.client.deps.io.netty.channel.ChannelHandlerContext")))
- .and(takesArgument(2, named("java.util.List"))),
+ .and(takesArgument(2, List.class)),
CouchbaseNetworkInstrumentation.class.getName() + "$CouchbaseNetworkAdvice");
}

MODIFY
instrumentation/elasticsearch/elasticsearch-rest-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/v5_0/Elasticsearch5RestClientInstrumentationModule.java
instrumentation/elasticsearch/elasticsearch-rest-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/v5_0/Elasticsearch5RestClientInstrumentationModule.java
@@ -52,8 +52,8 @@ public class Elasticsearch5RestClientInstrumentationModule extends Instrumentati
isMethod()
.and(namedOneOf("performRequestAsync", "performRequestAsyncNoCatch"))
.and(takesArguments(7))
- .and(takesArgument(0, named("java.lang.String"))) // method
- .and(takesArgument(1, named("java.lang.String"))) // endpoint
+ .and(takesArgument(0, String.class)) // method
+ .and(takesArgument(1, String.class)) // endpoint
.and(takesArgument(5, named("org.elasticsearch.client.ResponseListener"))),
Elasticsearch5RestClientInstrumentationModule.class.getName()
+ "$ElasticsearchRestClientAdvice");

MODIFY
instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeInstrumentationModule.java
instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeInstrumentationModule.java
@@ -74,7 +74,7 @@ public class GeodeInstrumentationModule extends InstrumentationModule {
map.put(
isMethod()
.and(named("existsValue").or(named("query")).or(named("selectValue")))
- .and(takesArgument(0, named("java.lang.String"))),
+ .and(takesArgument(0, String.class)),
GeodeInstrumentationModule.class.getName() + "$QueryAdvice");
return map;
}

MODIFY
instrumentation/google-http-client-1.19/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/googlehttpclient/GoogleHttpClientInstrumentationModule.java
instrumentation/google-http-client-1.19/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/googlehttpclient/GoogleHttpClientInstrumentationModule.java
@@ -26,6 +26,7 @@ import io.opentelemetry.javaagent.tooling.TypeInstrumentation;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.Executor;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
@@ -68,7 +69,7 @@ public class GoogleHttpClientInstrumentationModule extends InstrumentationModule
.and(isPublic())
.and(named("executeAsync"))
.and(takesArguments(1))
- .and(takesArgument(0, (named("java.util.concurrent.Executor")))),
+ .and(takesArgument(0, Executor.class)),
GoogleHttpClientInstrumentationModule.class.getName() + "$GoogleHttpClientAsyncAdvice");
return transformers;

MODIFY
instrumentation/grizzly-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grizzly/DefaultFilterChainInstrumentation.java
instrumentation/grizzly-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grizzly/DefaultFilterChainInstrumentation.java
@@ -31,7 +31,7 @@ public class DefaultFilterChainInstrumentation implements TypeInstrumentation {
.and(isPrivate())
.and(named("notifyFailure"))
.and(takesArgument(0, named("org.glassfish.grizzly.filterchain.FilterChainContext")))
- .and(takesArgument(1, named("java.lang.Throwable"))),
+ .and(takesArgument(1, Throwable.class)),
DefaultFilterChainAdvice.class.getName());
}
}

MODIFY
instrumentation/hibernate/hibernate-3.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/hibernate/v3_3/SessionInstrumentation.java
instrumentation/hibernate/hibernate-3.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/hibernate/v3_3/SessionInstrumentation.java
@@ -79,10 +79,7 @@ public class SessionInstrumentation implements TypeInstrumentation {
// Handle the non-generic 'get' separately.
transformers.put(
- isMethod()
- .and(named("get"))
- .and(returns(named("java.lang.Object")))
- .and(takesArgument(0, named("java.lang.String"))),
+ isMethod().and(named("get")).and(returns(Object.class)).and(takesArgument(0, String.class)),
SessionInstrumentation.class.getName() + "$SessionMethodAdvice");
// These methods return some object that we want to instrument, and so the Advice will pin the

MODIFY
instrumentation/hibernate/hibernate-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/hibernate/v4_0/SessionInstrumentation.java
instrumentation/hibernate/hibernate-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/hibernate/v4_0/SessionInstrumentation.java
@@ -76,10 +76,7 @@ public class SessionInstrumentation implements TypeInstrumentation {
SessionInstrumentation.class.getName() + "$SessionMethodAdvice");
// Handle the non-generic 'get' separately.
transformers.put(
- isMethod()
- .and(named("get"))
- .and(returns(named("java.lang.Object")))
- .and(takesArgument(0, named("java.lang.String"))),
+ isMethod().and(named("get")).and(returns(Object.class)).and(takesArgument(0, String.class)),
SessionInstrumentation.class.getName() + "$SessionMethodAdvice");
// These methods return some object that we want to instrument, and so the Advice will pin the

MODIFY
instrumentation/jetty-8.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jetty/JettyInstrumentationModule.java
instrumentation/jetty-8.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jetty/JettyInstrumentationModule.java
@@ -63,7 +63,7 @@ public class JettyInstrumentationModule extends InstrumentationModule {
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
named("handle")
- .and(takesArgument(0, named("java.lang.String")))
+ .and(takesArgument(0, String.class))
.and(takesArgument(1, named("org.eclipse.jetty.server.Request")))
.and(takesArgument(2, named("javax.servlet.http.HttpServletRequest")))
.and(takesArgument(3, named("javax.servlet.http.HttpServletResponse")))

MODIFY
instrumentation/khttp-0.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/khttp/KHttpInstrumentationModule.java
instrumentation/khttp-0.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/khttp/KHttpInstrumentationModule.java
@@ -54,9 +54,9 @@ public class KHttpInstrumentationModule extends InstrumentationModule {
isMethod()
.and(not(isAbstract()))
.and(named("request"))
- .and(takesArgument(0, named("java.lang.String")))
- .and(takesArgument(1, named("java.lang.String")))
- .and(takesArgument(2, named("java.util.Map")))
+ .and(takesArgument(0, String.class))
+ .and(takesArgument(1, String.class))
+ .and(takesArgument(2, Map.class))
.and(returns(named("khttp.responses.Response"))),
KHttpAdvice.class.getName());
}

MODIFY
instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceReactiveCommandsInstrumentation.java
instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceReactiveCommandsInstrumentation.java
@@ -18,6 +18,7 @@ import io.opentelemetry.javaagent.instrumentation.lettuce.v5_0.rx.LettuceMonoCre
import io.opentelemetry.javaagent.tooling.TypeInstrumentation;
import java.util.HashMap;
import java.util.Map;
+import java.util.function.Supplier;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@@ -35,7 +36,7 @@ public class LettuceReactiveCommandsInstrumentation implements TypeInstrumentati
transformers.put(
isMethod()
.and(named("createMono"))
- .and(takesArgument(0, named("java.util.function.Supplier")))
+ .and(takesArgument(0, Supplier.class))
.and(returns(named("reactor.core.publisher.Mono"))),
LettuceMonoCreationAdvice.class.getName());
transformers.put(
@@ -43,7 +44,7 @@ public class LettuceReactiveCommandsInstrumentation implements TypeInstrumentati
.and(nameStartsWith("create"))
.and(nameEndsWith("Flux"))
.and(isPublic())
- .and(takesArgument(0, named("java.util.function.Supplier")))
+ .and(takesArgument(0, Supplier.class))
.and(returns(named("reactor.core.publisher.Flux"))),
LettuceFluxCreationAdvice.class.getName());

MODIFY
instrumentation/rmi/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rmi/client/RmiClientInstrumentationModule.java
instrumentation/rmi/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rmi/client/RmiClientInstrumentationModule.java
@@ -51,7 +51,7 @@ public class RmiClientInstrumentationModule extends InstrumentationModule {
isMethod()
.and(named("invoke"))
.and(takesArgument(0, named("java.rmi.Remote")))
- .and(takesArgument(1, named("java.lang.reflect.Method"))),
+ .and(takesArgument(1, Method.class)),
RmiClientInstrumentationModule.class.getName() + "$RmiClientAdvice");
}
}

MODIFY
instrumentation/spring/spring-webflux-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/server/HandlerAdapterInstrumentation.java
instrumentation/spring/spring-webflux-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/server/HandlerAdapterInstrumentation.java
@@ -42,7 +42,7 @@ public class HandlerAdapterInstrumentation implements TypeInstrumentation {
.and(isPublic())
.and(named("handle"))
.and(takesArgument(0, named("org.springframework.web.server.ServerWebExchange")))
- .and(takesArgument(1, named("java.lang.Object")))
+ .and(takesArgument(1, Object.class))
.and(takesArguments(2)),
HandlerAdapterAdvice.class.getName());
}

MODIFY
instrumentation/vertx-reactive-3.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/reactive/VertxRxInstrumentationModule.java
instrumentation/vertx-reactive-3.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/reactive/VertxRxInstrumentationModule.java
@@ -60,7 +60,7 @@ public class VertxRxInstrumentationModule extends InstrumentationModule {
isConstructor().and(takesArgument(0, named("io.vertx.core.Handler"))),
VertxRxInstrumentationModule.class.getName() + "$AsyncResultSingleHandlerAdvice");
result.put(
- isConstructor().and(takesArgument(0, named("java.util.function.Consumer"))),
+ isConstructor().and(takesArgument(0, Consumer.class)),
VertxRxInstrumentationModule.class.getName() + "$AsyncResultSingleConsumerAdvice");
return result;
}

Use class literals where possible (#2669)