Catch InaccessibleObjectException next to IllegalAccessException

Closes gh-35190
This commit is contained in:
Juergen Hoeller
2025-07-11 22:44:11 +02:00
parent ba6166a02d
commit 4277682a5c
10 changed files with 21 additions and 13 deletions
@@ -16,6 +16,7 @@
package org.springframework.aop.aspectj;
import java.lang.reflect.InaccessibleObjectException;
import java.lang.reflect.InvocationTargetException;
import org.springframework.aop.framework.AopConfigException;
@@ -66,7 +67,7 @@ public class SimpleAspectInstanceFactory implements AspectInstanceFactory {
throw new AopConfigException(
"Unable to instantiate aspect class: " + this.aspectClass.getName(), ex);
}
catch (IllegalAccessException ex) {
catch (IllegalAccessException | InaccessibleObjectException ex) {
throw new AopConfigException(
"Could not access aspect constructor: " + this.aspectClass.getName(), ex);
}
@@ -16,6 +16,7 @@
package org.springframework.aop.support;
import java.lang.reflect.InaccessibleObjectException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
@@ -367,7 +368,7 @@ public abstract class AopUtils {
throw new AopInvocationException("AOP configuration seems to be invalid: tried calling method [" +
method + "] on target [" + target + "]", ex);
}
catch (IllegalAccessException ex) {
catch (IllegalAccessException | InaccessibleObjectException ex) {
throw new AopInvocationException("Could not access method [" + method + "]", ex);
}
}