|
4 | 4 | import java.lang.annotation.Annotation;
|
5 | 5 | import java.lang.reflect.AccessibleObject;
|
6 | 6 | import java.lang.reflect.Field;
|
| 7 | +import java.lang.reflect.InvocationTargetException; |
7 | 8 | import java.lang.reflect.Method;
|
8 | 9 | import java.util.Collection;
|
9 | 10 | import java.util.Collections;
|
|
16 | 17 | import org.jetbrains.annotations.NotNull;
|
17 | 18 | import org.jetbrains.annotations.Nullable;
|
18 | 19 | import org.jetbrains.annotations.VisibleForTesting;
|
| 20 | +import org.objenesis.ObjenesisException; |
19 | 21 | import org.objenesis.ObjenesisHelper;
|
20 | 22 |
|
21 | 23 | public final class PropertyUtils {
|
@@ -333,6 +335,13 @@ private static <T> T createProxy(Class<T> beanClass, MethodCaptor methodCaptor)
|
333 | 335 | T proxyInstance = ObjenesisHelper.newInstance(proxyClass);
|
334 | 336 | writeDirectly(proxyInstance, MethodCaptor.FIELD_NAME, methodCaptor);
|
335 | 337 | return proxyInstance;
|
| 338 | + } catch (ObjenesisException e) { |
| 339 | + if (e.getCause() instanceof InvocationTargetException invocationTargetException) { |
| 340 | + if (invocationTargetException.getTargetException() instanceof IllegalAccessError illegalAccessError) { |
| 341 | + throw new ReflectionRuntimeException("Failed to create proxy on " + beanClass, illegalAccessError); |
| 342 | + } |
| 343 | + } |
| 344 | + throw e; |
336 | 345 | } catch (IllegalAccessError e) {
|
337 | 346 | throw new ReflectionRuntimeException("Failed to create proxy on " + beanClass, e);
|
338 | 347 | }
|
|
0 commit comments