Skip to content

MethodHandles.Lookup.defineClass for CGLIB class definition purposes [SPR-15859] #20414

Closed
@spring-projects-issues

Description

@spring-projects-issues

Juergen Hoeller opened SPR-15859 and commented

As discussed in cglib/cglib@d6fe1d8 and in #20245 comments, there is currently a defineClass warning triggered by CGLIB when running on JDK 9 in classpath mode. While there are workarounds for it ("illegal-access=deny" or "add-opens java.base/java.lang=ALL-UNNAMED"), suppressing that warning at runtime, it'd be nice to avoid the warning completely when running on JDK 9, possibly through a specific check for JDK 9 which skips the ClassLoader.defineClass access attempt completely, always going with the Unsafe.defineClass fallback right away in such a scenario. We have yet to see whether this can be patched in CGLIB itself or just in Spring's CGLIB fork.

UPDATE: Since JDK 11 won't have Unsafe.defineClass at all anymore, we need to use MethodHandles.Lookup.defineClass as our primary mechanism, avoiding a ClassLoader.defineClass warning on the classpath and providing compatibility with the module path on JDK 11.


Affects: 5.0 RC3

Reference URL: cglib/cglib@d6fe1d8

Issue Links:

Referenced from: commits 6a34ca2, 61c3db0

17 votes, 40 watchers

Metadata

Metadata

Assignees

Labels

has: votes-jiraIssues migrated from JIRA with more than 10 votes at the time of importin: 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