Improve diagnostics for CGLIB ClassLoader issues on Java 9+ #28747
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Inspired by the discussion in spring-projects/spring-hateoas#1806, we should improve the diagnostics for CGLIB
ClassLoader
issues on Java 9+.For example, in certain circumstances the JDK will hint that the user needs to provide
--add-opens=java.base/java.util.concurrent=ALL-UNNAMED
as a command-line argument -- for example, when trying to dynamically subclass a type from thejava.util.concurrent
package.However, due to the nature of Spring's CGLIB fork (specifically the changes in
org.springframework.cglib.core.ReflectUtils.defineClass(...)
) the proper fix would be to use--add-opens=java.base/java.lang=ALL-UNNAMED
to open up the protectedClassLoader.defineClass(...)
method used by Spring's CGLIB fork.ReflectUtils
could be updated to add this additional diagnostic information to the exception thrown byReflectUtils.defineClass(...)
.The text was updated successfully, but these errors were encountered: