GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 在jdk17里使用fastjson反序列化Exception时,会抛出下面的异常,IgnoreErrorGetter配置不生效 · Issue #4077 · alibaba/fastjson

This repository was archived by the owner on Jul 29, 2026. It is now read-only.
This repository was archived by the owner on Jul 29, 2026. It is now read-only.

在jdk17里使用fastjson反序列化Exception时,会抛出下面的异常,IgnoreErrorGetter配置不生效 #4077

Copy link
Copy link
Open
Open
在jdk17里使用fastjson反序列化Exception时,会抛出下面的异常,IgnoreErrorGetter配置不生效#4077
Copy link
Assignees
wenshao
Labels
bug
Milestone
1.2.81

Description

@hengyunabc
hengyunabc
opened on Apr 18, 2022
Issue body actions
java.lang.reflect.InaccessibleObjectException: Unable to make field private java.lang.Throwable java.lang.Throwable.cause accessible: module java.base does not "opens java.lang" to unnamed module @2dc96ada
        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.Field.checkCanSetAccessible(Field.java:178)
        at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
        at com.alibaba.fastjson.util.TypeUtils.setAccessible(TypeUtils.java:2510)
        at com.alibaba.fastjson.util.FieldInfo.<init>(FieldInfo.java:196)
        at com.alibaba.fastjson.util.FieldInfo.<init>(FieldInfo.java:115)
        at com.alibaba.fastjson.util.TypeUtils.computeGetters(TypeUtils.java:2093)
        at com.alibaba.fastjson.util.TypeUtils.buildBeanInfo(TypeUtils.java:1819)
        at com.alibaba.fastjson.util.TypeUtils.buildBeanInfo(TypeUtils.java:1759)
        at com.alibaba.fastjson.serializer.SerializeConfig.getObjectWriter(SerializeConfig.java:564)
        at com.alibaba.fastjson.serializer.SerializeConfig.getObjectWriter(SerializeConfig.java:440)
        at com.alibaba.fastjson.serializer.JSONSerializer.getObjectWriter(JSONSerializer.java:448)
        at com.alibaba.fastjson.serializer.JSONSerializer.write(JSONSerializer.java:309)
        at com.alibaba.fastjson.JSON.toJSONString(JSON.java:687)
        at com.alibaba.fastjson.JSON.toJSONString(JSON.java:676)

com.alibaba.fastjson.util.TypeUtils 里的 catch AccessControlException 感觉要改为 Throwable,因为在jdk 17里抛出的异常是 java.lang.reflect.InaccessibleObjectException

    static void setAccessible(AccessibleObject obj){
        if(!setAccessibleEnable){
            return;
        }
        if(obj.isAccessible()){
            return;
        }
        try{
            obj.setAccessible(true);
        } catch(AccessControlException error){
            setAccessibleEnable = false;
        }
    }

Activity

  1. hengyunabc
    added a commit that references this issue on Apr 18, 2022

    fix InaccessibleObjectException in jdk17. alibaba#4077

    c04ceb9
  2. wenshao
    modified the milestone: 1.2.80 on Apr 18, 2022
  3. wenshao
    self-assigned this
    on Apr 18, 2022
  4. wenshao
    added
    bug
    on Apr 18, 2022
  5. wenshao
    added this to the 1.2.81 milestone on Apr 18, 2022
  6. wenshao
    added 3 commits that reference this issue on Apr 20, 2022

    Merge pull request #4078 from hengyunabc/master

    ab82d0b

    Revert "fix InaccessibleObjectException in jdk17. #4077"

    0814909

    Merge pull request #4084 from alibaba/revert-4078-master

    a234f9a
  7. hengyunabc
    added a commit that references this issue on Apr 20, 2022

    fix InaccessibleObjectException in jdk17. alibaba#4077

    dd3de5f
  8. wenshao
    added a commit that references this issue on Apr 20, 2022

    Merge pull request #4085 from hengyunabc/fix_setAccessible

    3f009e1
  9. fyeeme commented on Nov 14, 2023

    @fyeeme
    fyeeme
    on Nov 14, 2023
    More actions

    项目升级JDK 17,未修复 fastjson,碰到了同样的问题

  10. zhangshuhua commented on Mar 1, 2024

    @zhangshuhua
    zhangshuhua
    on Mar 1, 2024
    More actions

    项目升级JDK 17,未修复 fastjson,碰到了同样的问题

    请教一下,这个问题怎么处理,我升级到最新的1.2.83还是有一样的问题

  11. fyeeme commented on Mar 4, 2024

    @fyeeme
    fyeeme
    on Mar 4, 2024
    More actions

    @zhangshuhua 最新的版本已经修复了该问题,如果你升级了,还是碰到了同样的问题,看看是不是有其他的依赖低版本fastjson

    Reacted by Zhongzheng
  12. chenzz commented on Jun 4, 2024

    @chenzz
    chenzz
    on Jun 4, 2024
    More actions

    @zhangshuhua 最新的版本已经修复了该问题,如果你升级了,还是碰到了同样的问题,看看是不是有其他的依赖低版本fastjson

    1.2.83还是有同样的问题。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @wenshao
    wenshao

Labels

bug

Type

No type

Projects

No projects

    Milestone

    • 1.2.81No due date

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402520 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.