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

Illegal reflective access by org.springframework.cglib.core.ReflectUtils #24857

Closed
LifeIsStrange opened this issue Jan 16, 2021 · 5 comments
Closed
Assignees
Milestone

Comments

@LifeIsStrange
Copy link

@LifeIsStrange LifeIsStrange commented Jan 16, 2021

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils (file:/home/stephane/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/5.3.2/152489ed8223a6ad19065a3cd1ee6b9e20c0b82f/spring-core-5.3.2.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

note: I also upgraded to gradle 6.8
I get this warning on server launch after having updated spring dependencies.

@LifeIsStrange
Copy link
Author

@LifeIsStrange LifeIsStrange commented Jan 16, 2021

The warning disappear if I comment // developmentOnly("org.springframework.boot:spring-boot-devtools")
why ?

@LifeIsStrange
Copy link
Author

@LifeIsStrange LifeIsStrange commented Jan 16, 2021

The doc https://docs.spring.io/spring-boot/docs/1.5.16.RELEASE/reference/html/using-boot-devtools.html#using-boot-devtools
says using compileOnly is best practice but I believe (?) it is obscolete and should be developmentOnly() ?
Anyway, both trigger the warning.
Can this trigger bugs ?
This should be fixed as it must affect a huge number of projects

@wilkinsona
Copy link
Member

@wilkinsona wilkinsona commented Jan 18, 2021

You've described the problem as a regression and that it is occurring after upgrading some Spring dependencies. What version were you using before and what version have you upgraded to?

The doc says using compileOnly is best practice but I believe (?) it is obscolete and should be developmentOnly() ?

That documentation is for Spring Boot 1.5.16 which predates the developmentOnly configuration. More recent documentation recommends the use of developmentOnly.

The warning disappear if I comment // developmentOnly("org.springframework.boot:spring-boot-devtools")
why ?

Using Devtools changes the class loaders that are involved. I can't say exactly why it is triggering the warning, but that is a likely cause. To be more precise, we'll need some more information about the problem. To that end, can you please provide a minimal sample that reproduces it? You can share it with us by zipping it up and attaching it to this issue or by pushing it to a separate repository on GitHub.

@snicoll snicoll changed the title Regression: Illegal reflective access by org.springframework.cglib.core.ReflectUtils Illegal reflective access by org.springframework.cglib.core.ReflectUtils Jan 18, 2021
@LifeIsStrange
Copy link
Author

@LifeIsStrange LifeIsStrange commented Jan 18, 2021

Many thanks for the quick and correct answer, unfortunately I can't work on that until a few days, I'll ping you when I'll submit a reproducer.

@snicoll
Copy link
Member

@snicoll snicoll commented Jan 19, 2021

@jhoeller has added a new method in Spring Framework 5.3.4 (see spring-projects/spring-framework#26403) so we'll have to wait for that to be able to benefit from the fix.

I was able to easily reproduce the warning with instructions from Juergen but, unfortunately, I didn't manage to assert on the presence or absence of the warning as it seems to be logged outside of the test boundary. I've created a branch that switches to the snapshot (see #24884) and apply the fix. With that in place the warning is gone.

For those interested the branch is: https://github.com/snicoll/spring-boot/tree/gh-24857

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants