-
Notifications
You must be signed in to change notification settings - Fork 37.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spring 5.2 with cglib proxies: An illegal reflective access operation has occurred #26919
Comments
There are certain operations that simply do not work without opening the module or generally allowing "illegal" access on JDK 9+. With CGLIB proxies, it's very dependent on the specific class that we need to create a proxy for: Depending on the original class loader of that class and the target class loader to create the proxy in, we may have to enforce So it's not a regression, just a case where we have no other way of solving the specified problem. Asking the framework to create a proxy for |
Thank you for the detailed response, Juergen. The real-world application we face the issue in is a standard-structure Spring Boot application. To my understanding, the framework and application classes are loaded by the same application classloader, so theoretically we should not face the issue where multiple classloaders are involved. We were able to trace the problem to a particular bean in the third-party library. It is defined as following: @Bean("application")
@ConditionalOnMissingBean(name = "application")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.TARGET_CLASS)
public Object application() {
return FacesContext.getCurrentInstance().getExternalContext().getContext();
} Note the return type of the factory method - @Bean("application")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.TARGET_CLASS)
public ServletContext application() {
return (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
} the problem for this particular bean gets resolved. We also discovered another interesting case where an import javax.faces.context.FacesContext;
@Bean("facesContext")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.TARGET_CLASS)
@ConditionalOnMissingBean
public FacesContext facesContext() {
return FacesContext.getCurrentInstance();
} which also throws this warning. When debugging the If this is something Spring Team is interested to take a deeper look at, I could prepare a reproducer with this particular library involved. |
The library maintainers claim this to be resolved in the newer versions: joinfaces/joinfaces#1326. I will close this issue. |
To reproduce, create a minimal Spring-based application (Spring Framework 5.2) with cglib proxies enabled and run it with Java 9+, for instance:
The following warning appears:
Debugging illegal access provides the following stacktrace:
It looks like a regression of #22674 (as far as I understand, Spring Framework 5.1+ should be fully Java 9 compatible).
The text was updated successfully, but these errors were encountered: