You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by ad...@apache.org on 2026/09/07 14:21:41 UTC
(wicket) branch WICKET-7204 created (now 4d47a713f3)
This is an automated email from the ASF dual-hosted git repository.
bitstorm pushed a change to branch WICKET-7204
in repository https://gitbox.apache.org/repos/asf/wicket.git
at 4d47a713f3 WICKET-7204 Don't use INJECTION for ByteBuddy proxy creation
This branch includes the following new commits:
new 4d47a713f3 WICKET-7204 Don't use INJECTION for ByteBuddy proxy creation
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(wicket) 01/01: WICKET-7204 Don't use INJECTION for ByteBuddy proxy creation
Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bitstorm pushed a commit to branch WICKET-7204
in repository https://gitbox.apache.org/repos/asf/wicket.git
commit 4d47a713f34a802a088630c7ec9ca9284e2a18ad
Author: Andrea Del Bene <an...@host.it>
AuthorDate: Mon Sep 7 16:21:03 2026 +0200
WICKET-7204 Don't use INJECTION for ByteBuddy proxy creation
---
pom.xml | 2 +-
.../proxy/bytebuddy/ByteBuddyProxyFactory.java | 26 ++++++++++++++++++++--
2 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index af4192f148..31572c154a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -159,7 +159,7 @@
<aspectj.version>1.9.25.1</aspectj.version>
<assertj-core.version>3.27.7</assertj-core.version>
<bouncycastle.version>1.85.2</bouncycastle.version>
- <byte-buddy.version>1.18.8</byte-buddy.version>
+ <byte-buddy.version>1.18.13</byte-buddy.version>
<cdi-unit.version>5.0.0-EA7</cdi-unit.version>
<commons-collections4.version>4.6.0</commons-collections4.version>
<commons-fileupload.version>2.0.0-M5</commons-fileupload.version>
diff --git a/wicket-ioc/src/main/java/org/apache/wicket/proxy/bytebuddy/ByteBuddyProxyFactory.java b/wicket-ioc/src/main/java/org/apache/wicket/proxy/bytebuddy/ByteBuddyProxyFactory.java
index 307786d9d4..d75f6815e7 100644
--- a/wicket-ioc/src/main/java/org/apache/wicket/proxy/bytebuddy/ByteBuddyProxyFactory.java
+++ b/wicket-ioc/src/main/java/org/apache/wicket/proxy/bytebuddy/ByteBuddyProxyFactory.java
@@ -17,8 +17,10 @@
package org.apache.wicket.proxy.bytebuddy;
import java.io.Serializable;
+import java.lang.invoke.MethodHandles;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Modifier;
import java.util.function.Function;
import org.apache.wicket.Application;
@@ -100,8 +102,10 @@ public class ByteBuddyProxyFactory implements IProxyFactory
@SuppressWarnings("unchecked")
public static <T> Class<T> createOrGetProxyClass(Class<T> type)
- {
+ {
+ ClassLoadingStrategy<ClassLoader> loadingStrategy = resolveLoadingStrategy(type);
ClassLoader classLoader = resolveClassLoader();
+
return (Class<T>) DYNAMIC_CLASS_CACHE.findOrInsert(classLoader,
new TypeCache.SimpleKey(type),
() -> BYTE_BUDDY
@@ -116,10 +120,26 @@ public class ByteBuddyProxyFactory implements IProxyFactory
.implement(InterceptorMutator.class).intercept(FieldAccessor.ofBeanProperty())
.implement(Serializable.class, IWriteReplace.class, ILazyInitProxy.class).intercept(MethodDelegation.toField(INTERCEPTOR_FIELD_NAME))
.make()
- .load(classLoader, ClassLoadingStrategy.Default.INJECTION.allowExistingTypes())
+ .load(classLoader, loadingStrategy)
.getLoaded());
}
+ private static ClassLoadingStrategy<ClassLoader> resolveLoadingStrategy(Class<?> type)
+ {
+ try
+ {
+ int modifiers = type.getModifiers();
+
+ return !Modifier.isPublic(modifiers)
+ ? ClassLoadingStrategy.UsingLookup.of(MethodHandles.privateLookupIn(type, MethodHandles.lookup()))
+ : ClassLoadingStrategy.Default.WRAPPER.allowExistingTypes();
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new WicketRuntimeException(e);
+ }
+ }
+
private static ClassLoader resolveClassLoader()
{
ClassLoader classLoader = null;
@@ -205,7 +225,9 @@ public class ByteBuddyProxyFactory implements IProxyFactory
for (Constructor<?> constructor : type.getDeclaredConstructors())
{
if (constructor.getParameterTypes().length == 0)
+ {
return true;
+ }
}
return false;