Uncomment and fix JAX-RS default method tests
MODIFY
instrumentation/apache-camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/ApacheCamelInstrumentationModule.java
instrumentation/apache-camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/ApacheCamelInstrumentationModule.java
@@ -8,10 +8,8 @@ package io.opentelemetry.javaagent.instrumentation.apachecamel;
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.implementsInterface;
import static io.opentelemetry.javaagent.extension.matcher.ClassLoaderMatcher.hasClassesNamed;
import static java.util.Collections.singletonList;
-import static net.bytebuddy.matcher.ElementMatchers.isAbstract;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.named;
-import static net.bytebuddy.matcher.ElementMatchers.not;
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
import com.google.auto.service.AutoService;
@@ -51,7 +49,7 @@ public class ApacheCamelInstrumentationModule extends InstrumentationModule {
@Override
public ElementMatcher<TypeDescription> typeMatcher() {
- return not(isAbstract()).and(implementsInterface(named("org.apache.camel.CamelContext")));
+ return implementsInterface(named("org.apache.camel.CamelContext"));
}
@Override

MODIFY
instrumentation/grizzly-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grizzly/HttpHandlerInstrumentation.java
instrumentation/grizzly-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grizzly/HttpHandlerInstrumentation.java
package io.opentelemetry.javaagent.instrumentation.grizzly;
-import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.safeHasSuperType;
+import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.extendsClass;
import static io.opentelemetry.javaagent.extension.matcher.ClassLoaderMatcher.hasClassesNamed;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
@@ -28,7 +28,7 @@ public class HttpHandlerInstrumentation implements TypeInstrumentation {
@Override
public ElementMatcher<TypeDescription> typeMatcher() {
- return safeHasSuperType(named("org.glassfish.grizzly.http.server.HttpHandler"));
+ return extendsClass(named("org.glassfish.grizzly.http.server.HttpHandler"));
}
@Override

MODIFY
instrumentation/grpc-1.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grpc/v1_6/GrpcServerBuilderInstrumentation.java
instrumentation/grpc-1.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grpc/v1_6/GrpcServerBuilderInstrumentation.java
package io.opentelemetry.javaagent.instrumentation.grpc.v1_6;
-import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.safeHasSuperType;
+import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.extendsClass;
import static io.opentelemetry.javaagent.extension.matcher.ClassLoaderMatcher.hasClassesNamed;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
@@ -31,7 +31,7 @@ public class GrpcServerBuilderInstrumentation implements TypeInstrumentation {
@Override
public ElementMatcher<TypeDescription> typeMatcher() {
- return safeHasSuperType(named("io.grpc.ServerBuilder"));
+ return extendsClass(named("io.grpc.ServerBuilder"));
}
@Override

MODIFY
instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/groovy/JaxRsAnnotations1InstrumentationTest.groovy
instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/groovy/JaxRsAnnotations1InstrumentationTest.groovy
@@ -45,7 +45,7 @@ class JaxRsAnnotations1InstrumentationTest extends AgentInstrumentationSpecifica
}
@Unroll
- def "span named '#paramName' from annotations on class when is not root span"() {
+ def "span named '#paramName' from annotations on class '#className' when is not root span"() {
setup:
runUnderServerTrace("test") {
obj.call()
@@ -128,8 +128,7 @@ class JaxRsAnnotations1InstrumentationTest extends AgentInstrumentationSpecifica
}
"/child/call" | new ChildClassWithPath()
"/child/call" | new JavaInterfaces.ChildClassOnInterface()
- // TODO: uncomment when we drop support for Java 7
- // "/child/invoke" | new JavaInterfaces.DefaultChildClassOnInterface()
+ "/child/call" | new JavaInterfaces.DefaultChildClassOnInterface()
className = getClassName(obj.class)
}

MODIFY
instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/java/JavaInterfaces.java
instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/java/JavaInterfaces.java
@@ -23,7 +23,8 @@ public class JavaInterfaces {
}
@Path("abstract")
- abstract class AbstractClassOnInterfaceWithClassPath implements InterfaceWithClassMethodPath {
+ abstract static class AbstractClassOnInterfaceWithClassPath
+ implements InterfaceWithClassMethodPath {
@GET
@Path("call")
@@ -36,7 +37,7 @@ public class JavaInterfaces {
}
@Path("child")
- class ChildClassOnInterface extends AbstractClassOnInterfaceWithClassPath {
+ static class ChildClassOnInterface extends AbstractClassOnInterfaceWithClassPath {
@Override
void actual() {
@@ -44,25 +45,25 @@ public class JavaInterfaces {
}
}
- // TODO: uncomment when we drop support for Java 7
- // @Path("interface")
- // interface DefaultInterfaceWithClassMethodPath extends Jax {
- //
- // @GET
- // @Path("invoke")
- // default void call() {
- // actual();
- // }
- //
- // void actual();
- // }
- //
- // @Path("child")
- // class DefaultChildClassOnInterface implements DefaultInterfaceWithClassMethodPath {
- //
- // @Override
- // public void actual() {
- // // do nothing
- // }
- // }
+ @Path("interface")
+ interface DefaultInterfaceWithClassMethodPath extends Jax {
+
+ @Override
+ @GET
+ @Path("call")
+ default void call() {
+ actual();
+ }
+
+ void actual();
+ }
+
+ @Path("child")
+ static class DefaultChildClassOnInterface implements DefaultInterfaceWithClassMethodPath {
+
+ @Override
+ public void actual() {
+ // do nothing
+ }
+ }
}

MODIFY
instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-testing/src/main/groovy/JaxRsAnnotationsInstrumentationTest.groovy
instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-testing/src/main/groovy/JaxRsAnnotationsInstrumentationTest.groovy
@@ -45,7 +45,7 @@ abstract class JaxRsAnnotationsInstrumentationTest extends AgentInstrumentationS
}
@Unroll
- def "span named '#paramName' from annotations on class when is not root span"() {
+ def "span named '#paramName' from annotations on class '#className' when is not root span"() {
setup:
runUnderServerTrace("test") {
obj.call()
@@ -128,8 +128,7 @@ abstract class JaxRsAnnotationsInstrumentationTest extends AgentInstrumentationS
}
"/child/call" | new ChildClassWithPath()
"/child/call" | new JavaInterfaces.ChildClassOnInterface()
- // TODO: uncomment when we drop support for Java 7
-// "GET /child/invoke" | new JavaInterfaces.DefaultChildClassOnInterface()
+ "/child/call" | new JavaInterfaces.DefaultChildClassOnInterface()
className = getClassName(obj.class)
}

MODIFY
instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-testing/src/main/java/JavaInterfaces.java
instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-testing/src/main/java/JavaInterfaces.java
@@ -23,7 +23,8 @@ public class JavaInterfaces {
}
@Path("abstract")
- abstract class AbstractClassOnInterfaceWithClassPath implements InterfaceWithClassMethodPath {
+ abstract static class AbstractClassOnInterfaceWithClassPath
+ implements InterfaceWithClassMethodPath {
@GET
@Path("call")
@@ -36,7 +37,7 @@ public class JavaInterfaces {
}
@Path("child")
- class ChildClassOnInterface extends AbstractClassOnInterfaceWithClassPath {
+ static class ChildClassOnInterface extends AbstractClassOnInterfaceWithClassPath {
@Override
void actual() {
@@ -44,25 +45,25 @@ public class JavaInterfaces {
}
}
- // TODO: uncomment when we drop support for Java 7
- // @Path("interface")
- // interface DefaultInterfaceWithClassMethodPath extends Jax {
- //
- // @GET
- // @Path("invoke")
- // default void call() {
- // actual();
- // }
- //
- // void actual();
- // }
- //
- // @Path("child")
- // class DefaultChildClassOnInterface implements DefaultInterfaceWithClassMethodPath {
- //
- // @Override
- // public void actual() {
- // // do nothing
- // }
- // }
+ @Path("interface")
+ interface DefaultInterfaceWithClassMethodPath extends Jax {
+
+ @Override
+ @GET
+ @Path("call")
+ default void call() {
+ actual();
+ }
+
+ void actual();
+ }
+
+ @Path("child")
+ static class DefaultChildClassOnInterface implements DefaultInterfaceWithClassMethodPath {
+
+ @Override
+ public void actual() {
+ // do nothing
+ }
+ }
}

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
package io.opentelemetry.javaagent.instrumentation.khttp;
-import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.safeHasSuperType;
+import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.extendsClass;
import static io.opentelemetry.javaagent.extension.matcher.ClassLoaderMatcher.hasClassesNamed;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
@@ -45,7 +45,7 @@ public class KHttpInstrumentationModule extends InstrumentationModule {
@Override
public ElementMatcher<TypeDescription> typeMatcher() {
- return safeHasSuperType(named("khttp.KHttp"));
+ return extendsClass(named("khttp.KHttp"));
}
@Override

MODIFY
instrumentation/vertx-web-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/VertxWebInstrumentationModule.java
instrumentation/vertx-web-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/VertxWebInstrumentationModule.java
package io.opentelemetry.javaagent.instrumentation.vertx;
-import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.safeHasSuperType;
+import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.implementsInterface;
import static io.opentelemetry.javaagent.extension.matcher.ClassLoaderMatcher.hasClassesNamed;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
-import static net.bytebuddy.matcher.ElementMatchers.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.named;
-import static net.bytebuddy.matcher.ElementMatchers.not;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
import com.google.auto.service.AutoService;
@@ -47,7 +45,7 @@ public class VertxWebInstrumentationModule extends InstrumentationModule {
@Override
public ElementMatcher<TypeDescription> typeMatcher() {
- return not(isInterface()).and(safeHasSuperType(named("io.vertx.ext.web.Route")));
+ return implementsInterface(named("io.vertx.ext.web.Route"));
}
@Override

MODIFY
javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/extension/matcher/AgentElementMatchers.java
javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/extension/matcher/AgentElementMatchers.java
@@ -25,8 +25,7 @@ public final class AgentElementMatchers {
public static ElementMatcher.Junction<TypeDescription> implementsInterface(
ElementMatcher<TypeDescription> matcher) {
- return not(isInterface())
- .and(new SafeHasSuperTypeMatcher(new SafeErasureMatcher<>(matcher), true));
+ return new SafeHasSuperTypeMatcher(new SafeErasureMatcher<>(matcher), true);
}
public static ElementMatcher.Junction<TypeDescription> hasInterface(
@@ -36,8 +35,7 @@ public final class AgentElementMatchers {
public static ElementMatcher.Junction<TypeDescription> safeHasSuperType(
ElementMatcher<TypeDescription> matcher) {
- return not(isInterface())
- .and(new SafeHasSuperTypeMatcher(new SafeErasureMatcher<>(matcher), false));
+ return new SafeHasSuperTypeMatcher(new SafeErasureMatcher<>(matcher), false);
}
/**

MODIFY
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/context/FieldBackedProvider.java
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/context/FieldBackedProvider.java
@@ -7,7 +7,9 @@ package io.opentelemetry.javaagent.tooling.context;
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.safeHasSuperType;
import static io.opentelemetry.javaagent.extension.matcher.ClassLoaderMatcher.BOOTSTRAP_CLASSLOADER;
+import static net.bytebuddy.matcher.ElementMatchers.isAbstract;
import static net.bytebuddy.matcher.ElementMatchers.named;
+import static net.bytebuddy.matcher.ElementMatchers.not;
import io.opentelemetry.instrumentation.api.caching.Cache;
import io.opentelemetry.instrumentation.api.config.Config;
@@ -385,7 +387,7 @@ public class FieldBackedProvider implements InstrumentationContextProvider {
*/
builder =
builder
- .type(safeHasSuperType(named(entry.getKey())))
+ .type(not(isAbstract()).and(safeHasSuperType(named(entry.getKey()))))
.and(safeToInjectFieldsMatcher())
.and(ActualInstrumentationExtensionImplementation.NOT_DECORATOR_MATCHER)
.transform(NoOpTransformer.INSTANCE);

MODIFY
javaagent-tooling/src/test/groovy/io/opentelemetry/javaagent/tooling/bytebuddy/matcher/HasInterfaceMatcherTest.groovy
javaagent-tooling/src/test/groovy/io/opentelemetry/javaagent/tooling/bytebuddy/matcher/HasInterfaceMatcherTest.groovy
@@ -10,10 +10,13 @@ import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.
import static net.bytebuddy.matcher.ElementMatchers.named
import io.opentelemetry.javaagent.tooling.AgentTooling
-import io.opentelemetry.javaagent.tooling.bytebuddy.matcher.testclasses.*
+import io.opentelemetry.javaagent.tooling.bytebuddy.matcher.testclasses.A
+import io.opentelemetry.javaagent.tooling.bytebuddy.matcher.testclasses.B
+import io.opentelemetry.javaagent.tooling.bytebuddy.matcher.testclasses.E
+import io.opentelemetry.javaagent.tooling.bytebuddy.matcher.testclasses.F
+import io.opentelemetry.javaagent.tooling.bytebuddy.matcher.testclasses.G
import net.bytebuddy.description.type.TypeDescription
import net.bytebuddy.description.type.TypeList
-import net.bytebuddy.jar.asm.Opcodes
import spock.lang.Shared
import spock.lang.Specification
@@ -57,7 +60,6 @@ class HasInterfaceMatcherTest extends Specification {
then:
!result // default to false
noExceptionThrown()
- 1 * type.getModifiers() >> Opcodes.ACC_ABSTRACT
1 * type.isInterface() >> true
1 * type.asGenericType() >> typeGeneric
1 * typeGeneric.asErasure() >> { throw new Exception("asErasure exception") }

MODIFY
javaagent-tooling/src/test/groovy/io/opentelemetry/javaagent/tooling/bytebuddy/matcher/ImplementsInterfaceMatcherTest.groovy
javaagent-tooling/src/test/groovy/io/opentelemetry/javaagent/tooling/bytebuddy/matcher/ImplementsInterfaceMatcherTest.groovy
@@ -9,10 +9,13 @@ import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.
import static net.bytebuddy.matcher.ElementMatchers.named
import io.opentelemetry.javaagent.tooling.AgentTooling
-import io.opentelemetry.javaagent.tooling.bytebuddy.matcher.testclasses.*
+import io.opentelemetry.javaagent.tooling.bytebuddy.matcher.testclasses.A
+import io.opentelemetry.javaagent.tooling.bytebuddy.matcher.testclasses.B
+import io.opentelemetry.javaagent.tooling.bytebuddy.matcher.testclasses.E
+import io.opentelemetry.javaagent.tooling.bytebuddy.matcher.testclasses.F
+import io.opentelemetry.javaagent.tooling.bytebuddy.matcher.testclasses.G
import net.bytebuddy.description.type.TypeDescription
import net.bytebuddy.description.type.TypeList
-import net.bytebuddy.jar.asm.Opcodes
import spock.lang.Shared
import spock.lang.Specification
@@ -28,10 +31,10 @@ class ImplementsInterfaceMatcherTest extends Specification {
where:
matcherClass | type | result
- A | A | false
- A | B | false
+ A | A | true
+ A | B | true
B | A | false
- A | E | false
+ A | E | true
A | F | true
A | G | true
F | A | false
@@ -54,7 +57,6 @@ class ImplementsInterfaceMatcherTest extends Specification {
then:
!result // default to false
noExceptionThrown()
- 1 * type.getModifiers() >> Opcodes.ACC_ABSTRACT
1 * type.isInterface() >> true
1 * type.asGenericType() >> typeGeneric
1 * typeGeneric.asErasure() >> { throw new Exception("asErasure exception") }
@@ -79,7 +81,6 @@ class ImplementsInterfaceMatcherTest extends Specification {
then:
!result // default to false
noExceptionThrown()
- 1 * type.getModifiers() >> Opcodes.ACC_ABSTRACT
1 * type.isInterface() >> true
1 * type.asGenericType() >> typeGeneric
1 * typeGeneric.asErasure() >> { throw new Exception("asErasure exception") }

MODIFY
javaagent-tooling/src/test/groovy/io/opentelemetry/javaagent/tooling/bytebuddy/matcher/SafeHasSuperTypeMatcherTest.groovy
javaagent-tooling/src/test/groovy/io/opentelemetry/javaagent/tooling/bytebuddy/matcher/SafeHasSuperTypeMatcherTest.groovy
@@ -9,10 +9,13 @@ import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.
import static net.bytebuddy.matcher.ElementMatchers.named
import io.opentelemetry.javaagent.tooling.AgentTooling
-import io.opentelemetry.javaagent.tooling.bytebuddy.matcher.testclasses.*
+import io.opentelemetry.javaagent.tooling.bytebuddy.matcher.testclasses.A
+import io.opentelemetry.javaagent.tooling.bytebuddy.matcher.testclasses.B
+import io.opentelemetry.javaagent.tooling.bytebuddy.matcher.testclasses.E
+import io.opentelemetry.javaagent.tooling.bytebuddy.matcher.testclasses.F
+import io.opentelemetry.javaagent.tooling.bytebuddy.matcher.testclasses.G
import net.bytebuddy.description.type.TypeDescription
import net.bytebuddy.description.type.TypeList
-import net.bytebuddy.jar.asm.Opcodes
import spock.lang.Shared
import spock.lang.Specification
@@ -28,10 +31,10 @@ class SafeHasSuperTypeMatcherTest extends Specification {
where:
matcherClass | type | result
- A | A | false
- A | B | false
+ A | A | true
+ A | B | true
B | A | false
- A | E | false
+ A | E | true
A | F | true
B | G | true
F | A | false
@@ -54,7 +57,6 @@ class SafeHasSuperTypeMatcherTest extends Specification {
then:
!result // default to false
noExceptionThrown()
- 1 * type.getModifiers() >> Opcodes.ACC_ABSTRACT
1 * type.asGenericType() >> typeGeneric
1 * typeGeneric.asErasure() >> { throw new Exception("asErasure exception") }
1 * typeGeneric.getTypeName() >> "typeGeneric-name"
@@ -78,7 +80,6 @@ class SafeHasSuperTypeMatcherTest extends Specification {
then:
!result // default to false
noExceptionThrown()
- 1 * type.getModifiers() >> Opcodes.ACC_ABSTRACT
1 * type.getInterfaces() >> interfaces
1 * interfaces.iterator() >> it
1 * type.asGenericType() >> typeGeneric

Uncomment and fix JAX-RS default method tests (#2930)