Reuse byteBuddy instance instead of recreating it for each proxy.
@@ -65,6 +65,8 @@ class SoftProxies {
.or(named("withTypeComparators"))
.or(named("withThreadDumpOnError"));
+ private static ByteBuddy byteBuddy = new ByteBuddy().with(TypeValidation.DISABLED);
+
private final ErrorCollector collector = new ErrorCollector();
private final TypeCache<TypeCache.SimpleKey> cache = new TypeCache.WithInlineExpunction<>(Sort.SOFT);
@@ -98,8 +100,7 @@ class SoftProxies {
private <V> Class<?> createProxy(Class<V> assertClass, ErrorCollector collector) {
- return new ByteBuddy().with(TypeValidation.DISABLED)
- .subclass(assertClass)
+ return byteBuddy.subclass(assertClass)
.method(METHODS_CHANGING_THE_OBJECT_UNDER_TEST)
.intercept(MethodDelegation.to(new ProxifyMethodChangingTheObjectUnderTest(this)))
.method(any().and(not(METHODS_CHANGING_THE_OBJECT_UNDER_TEST))
