-
Notifications
You must be signed in to change notification settings - Fork 38.4k
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
ReflectUtils.defineClass() ignores the ClassLoader argument in Java 11 #22416
Comments
Are there specific cases where your target In any case, all we can do is to choose |
We also face this issue in our application. We deploy multiple web application that share common libraries. In shared libraries we have a class with @Cacheable annotation. Class generated via cglib by a web app ends up in the shared ClassLoader. When next web app tries to generate a class with the same name, it falls back to I have created an example project that demonstrates this behaviour: |
After a bit of back and forth, I went with a revised standard algorithm in We only prefer the JDK 9+ This should cover custom class loader architectures like OSGi or shared Servlet container setups now, without the need for special CGLIB setup. There may be new JVM illegal access warnings in certain scenarios now which can be worked around through streamlining the ClassLoader layout or through setting |
This will be available in the upcoming |
I've checked 5.1.6.BUILD-SNAPSHOT and it works fine. Thank you! |
Affects: 5.1.5
In Java 11
ReflectUtils.defineClass()
uses the newMethodHandles.Lookup.defineClass()
, this method uses thecontextClass
's classloader, instead of theloader
argument.This difference in behaviour in Java 8 and Java 11 sometimes produces unexpected errors (eg. java.lang.LinkageError: attempted duplicate class definition)
Related issue #22310
The text was updated successfully, but these errors were encountered: