Skip to content

fix: declare java.xml module dependency for Java 9+ modular usage#7619

Open
JinlongLiao wants to merge 2 commits into
alibaba:mainfrom
JinlongLiao:javaxml
Open

fix: declare java.xml module dependency for Java 9+ modular usage#7619
JinlongLiao wants to merge 2 commits into
alibaba:mainfrom
JinlongLiao:javaxml

Conversation

@JinlongLiao
Copy link
Copy Markdown

What this PR does / why we need it?

This PR fixes the IllegalAccessError that occurs when using fastjson2 (v2.0.61) in Java 9+ modular environments. The error is caused by missing java.xml module declaration in src/main/moditect/module-info.java, while the code internally references org.w3c.dom.Node from java.xml.

Without this fix, users cannot properly use fastjson2 in modularized projects, as the JVM prevents access to java.xml classes.

Summary of your change

  • Updated src/main/moditect/module-info.java to explicitly declare requires java.xml;.
  • Ensured that ObjectWriterProvider and related XML handling code can access org.w3c.dom.Node without IllegalAccessError.
  • Verified compatibility with Java 9+ modular projects.
  • Added regression tests to confirm XML serialization works under modularized environments.

Please indicate you've done the following:

  • Made sure tests are passing and test coverage is added if needed.
  • Made sure commit message follow the rule of Conventional Commits specification.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

JinlongLiao and others added 2 commits April 7, 2026 17:54
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 14, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Member

@wenshao wenshao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found. LGTM! ✅ — gpt-5.5 via Qwen Code /review

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants