Skip to content
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

Improve diagnostics for CGLIB ClassLoader issues on Java 9+ #28747

Closed
sbrannen opened this issue Jul 2, 2022 · 0 comments
Closed

Improve diagnostics for CGLIB ClassLoader issues on Java 9+ #28747

sbrannen opened this issue Jul 2, 2022 · 0 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@sbrannen
Copy link
Member

sbrannen commented Jul 2, 2022

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 the java.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 protected ClassLoader.defineClass(...) method used by Spring's CGLIB fork.

ReflectUtils could be updated to add this additional diagnostic information to the exception thrown by ReflectUtils.defineClass(...).

@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement labels Jul 2, 2022
@sbrannen sbrannen added this to the 5.3.22 milestone Jul 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants