Skip to content

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

Closed
@sbrannen

Description

@sbrannen

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(...).

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions