Interface TypeInstrumentation
-
public interface TypeInstrumentationInterface representing a single type instrumentation. Part of anInstrumentationModule.Classes implementing
TypeInstrumentationshould be public and non-final so that it's possible to extend and reuse them in vendor distributions.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default net.bytebuddy.matcher.ElementMatcher<ClassLoader>classLoaderOptimization()An optimization to short circuit matching in the case where the instrumented library is not even present on the class path.Map<? extends net.bytebuddy.matcher.ElementMatcher<? super net.bytebuddy.description.method.MethodDescription>,String>transformers()Keys of the returned map are method matchers, values are full names of advice classes that will be applied onto methods that satisfy matcher (key).net.bytebuddy.matcher.ElementMatcher<net.bytebuddy.description.type.TypeDescription>typeMatcher()Returns a type matcher defining which classes should undergo transformations defined by advices returned bytransformers().
-
-
-
Method Detail
-
classLoaderOptimization
default net.bytebuddy.matcher.ElementMatcher<ClassLoader> classLoaderOptimization()
An optimization to short circuit matching in the case where the instrumented library is not even present on the class path.Most applications have only a small subset of libraries on their class path, so this ends up being a very useful optimization.
Some background on type matcher performance:
Type matchers that only match against the type name are fast, e.g.
ElementMatchers.named(String).All other type matchers require some level of bytecode inspection, e.g.
ElementMatchers.isAnnotatedWith(ElementMatcher).Type matchers that need to inspect the super class hierarchy are even more expensive, e.g.
AgentElementMatchers.implementsInterface(ElementMatcher). This is because they require inspecting multiple super classes/interfaces as well (which may not even be loaded yet in which case their bytecode has to be read and inspected).- Returns:
- A type matcher that rejects classloaders that do not contain desired interfaces or base classes.
-
typeMatcher
net.bytebuddy.matcher.ElementMatcher<net.bytebuddy.description.type.TypeDescription> typeMatcher()
Returns a type matcher defining which classes should undergo transformations defined by advices returned bytransformers().
-
-