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 — 修复 Gson 在 Java 9+ 环境下反射访问 java.io.File#path 字段失败的问题 by Copilot · Pull Request #3773 · binarywang/WxJava

Conversation

Copilot AI commented Nov 28, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Gson 在 Java 9+ 模块化系统下无法反射访问 java.io.File#path 私有字段,导致包含 File 或 ApacheHttpClientBuilder 字段的配置类序列化失败。

Failed making field 'java.io.File#path' accessible; 
either increase its visibility or write a custom TypeAdapter for its declaring type.

修改内容

参照 WxMpGsonBuilder 已有的修复方案,为其他模块的 GsonBuilder 添加 ExclusionStrategy:

  • WxMaGsonBuilder (miniapp)
  • WxCpGsonBuilder (cp)
  • WxOpenGsonBuilder (open)
  • WxQidianGsonBuilder (qidian)
  • WxGsonBuilder (common)
INSTANCE.setExclusionStrategies(new ExclusionStrategy() {
  @Override
  public boolean shouldSkipField(FieldAttributes fieldAttributes) {
    return false;
  }

  @Override
  public boolean shouldSkipClass(Class<?> aClass) {
    return aClass == File.class || aClass == ApacheHttpClientBuilder.class;
  }
});
Original prompt

This section details on the original issue you should resolve

<issue_title>Gson问题</issue_title>
<issue_description>Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [cn.binarywang.wx.miniapp.api.WxMaService]: Factory method 'wxMaService' threw exception with message: Failed making field 'java.io.File#path' accessible; either increase its visibility or write a custom TypeAdapter for its declaring type.
See https://github.com/google/gson/blob/main/Troubleshooting.md#reflection-inaccessible</issue_description>

Comments on the Issue (you are @copilot in this section)

Custom agent used: 自定义的
需要用中文

  • Fixes Gson问题 #3752

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Copilot AI self-assigned this Nov 28, 2025
Initial plan
ed09960
Copilot AI assigned binarywang Nov 28, 2025
Copilot started work on behalf of binarywang November 28, 2025 02:00
View session
Copilot AI and others added 2 commits November 28, 2025 02:06
@binarywang
修复 Gson 在 Java 9+ 环境下无法反射访问 java.io.File#path 字段的问题
70e3251
Co-authored-by: binarywang <[email protected]>
@binarywang
移除 WxQidianGsonBuilder 中不必要的单例模式优化
77b1714
Co-authored-by: binarywang <[email protected]>
Copilot AI changed the title [WIP] Fix Gson accessibility issue in WxMaService instantiation 修复 Gson 在 Java 9+ 环境下反射访问 java.io.File#path 字段失败的问题 Nov 28, 2025
Copilot AI requested a review from binarywang November 28, 2025 02:12
Copilot finished work on behalf of binarywang November 28, 2025 02:12
@binarywang
binarywang marked this pull request as ready for review November 28, 2025 03:17
@binarywang
binarywang merged commit e655a33 into develop Nov 28, 2025
1 check passed

Uh oh!

There was an error while loading. Please reload this page.

@binarywang
binarywang deleted the copilot/fix-gson-accessibility-issue branch November 28, 2025 03:18
@binarywang binarywang added this to the 4.7.9 milestone Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@binarywang binarywang Awaiting requested review from binarywang

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@binarywang binarywang

Copilot code review Copilot

Labels

None yet

Projects

None yet

Milestone

4.7.9

Development

Successfully merging this pull request may close these issues.

Gson问题

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@binarywang
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — 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.