-
Notifications
You must be signed in to change notification settings - Fork 38.2k
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
Support for CGLIB BeanCopier utility on JDK 17 #28530
Comments
Spring includes a custom CGLIB fork which is generally JDK 17 compatible. However, since we are not using the CGLIB beans utilities ourselves, we initially did not patch them accordingly. This got reported for the CGLIB BeanMap already in #27802, I suppose BeanCopier needs similar treatment. We'll try to address this for 5.3.21. |
It seems that BeanGenerator, BulkBean, and ImmutableBean would benefit from a similar patch. It is all about setting a context class for the definition of the newly generated class (via the JDK 9+ Lookup API), and all of those CGLIB bean utilities effectively have a specified target class configured that we could use for those purposes. Hopefully we can sort this out for good in 5.3.21. |
yeah!!!i'm feeling weird. because i cant find spring use cglib,but BeanCopier still keep away. thank for your answer. |
I find this error still happening that is fault way to use? |
still error public static void main(String[] args) {
BeanCopier beanCopier = BeanCopier.create(A.class, B.class, false);
System.out.println(beanCopier);
A a = new A();
}
public static class A {
}
public static class B {
}
|
Affects: <Spring Framework version>
env:jdk17,spring-core:5.3.19,springboot:2.6.7
cglib said it does not support jdk17, but spring is still using cglib, will the new version after spring remove cglib?
org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @3567135c
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @3567135c
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:553)
... 81 more
The text was updated successfully, but these errors were encountered: