[alibaba/easyexcel]高版本jdk报错

2024-05-11 281 views
4

3.0.5版本反射代理有问题 在jdk11上出现警告但还能用

WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by net.sf.cglib.core.ReflectUtils$1 (file:/C:/Users/admin/.m2/repository/cglib/cglib/3.3.0/cglib-3.3.0.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 net.sf.cglib.core.ReflectUtils$1 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

而在jdk17上直接报错无法使用!!!!!!!!!!!!!!!!!!!!

触发Bug的代码

 @GetMapping("download")
    public void download(HttpServletResponse response) throws IOException {
        // 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
        String fileName = URLEncoder.encode("测试", "UTF-8");
        response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
        EasyExcel.write(response.getOutputStream(), DownloadData.class).sheet("模板").doWrite(data());
    }

 报错定位: doWrite(data());

提示的异常或者没有达到的效果

com.alibaba.excel.exception.ExcelGenerateException: java.lang.ExceptionInInitializerError Caused by: java.lang.ExceptionInInitializerError Caused by: net.sf.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 @175c2241 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 @175c2241

回答

6

我也遇到了同样的问题

7

升级jdk17之后,我也遇到了同样的问题,望尽快解决,谢谢

7

好像是高版本 JDK 把之前的告警行为改成了报错。需要加上 java -jar --add-opens java.base/java.lang=ALL-UNNAMED image

5

我也遇到了同样的问题

6

在3.1.0 里面会修复

1

3.1.0预计什么时候发布