Honor PERL_JSON_BACKEND=JSON::XS through the bundled compatibility shim
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start with src/main/perl/lib/JSON.pm and the existing adapter in src/main/perl/lib/JSON/XS.pm; compare how the dispatcher handles PERL_JSON_BACKEND with how the adapter reports its backend and native XS status. Add the project owned regression described in the acceptance criteria, first checking its expected behavior with system Perl. Run it on both JVM and interpreter backends, then verify the default and JSON::backportPP selections and the CPAN distribution test.
由索引模型根据 Issue 内容生成。
描述
Summary
The bundled JSON dispatcher ignores PERL_JSON_BACKEND=JSON::XS. It always loads JSON::PP unless the value is exactly JSON::backportPP, and JSON->backend consequently reports JSON::PP. This makes CPAN distributions that explicitly request the XS-compatible backend fail even though PerlOnJava already ships a JSON::XS compatibility module backed by the bundled pure-Perl JSON implementation.
Reproduction
With PERL_JSON_BACKEND=JSON::XS, run:
./jperl -e 'require JSON; print JSON->backend, "\n"'
./jperl --interpreter -e 'require JSON; print JSON->backend, "\n"'
Both currently print JSON::PP. The same selection occurs when the variable is set inside a test's BEGIN block before use JSON.
This was observed in CPAN random run 20261118-104825-43075 for Data-Compare-Plugins-JSON 1.04. t/05-compare-json-uses-xs.t sets PERL_JSON_BACKEND=JSON::XS, loads JSON::XS and JSON, then expects JSON->backend to be an isa JSON::XS. The PerlOnJava run reports JSON::PP and fails that assertion (1 of 75 tests; 1 of 11 test programs). The run used JSON 4.11, JSON::XS 4.04 and JSON::PP 4.18. The complete unmodified distribution suite passed under system Perl (11 files, 75 tests); the focused test also passed with the distribution and dependency library paths active.
Root cause and existing support
src/main/perl/lib/JSON.pm loads JSON::PP for every backend value other than JSON::backportPP, initializes $Backend / $BackendModule to JSON::PP, and leaves $BackendModuleXS undefined. Separately, src/main/perl/lib/JSON/XS.pm already exposes a JSON::XS-compatible API by delegating to Cpanel::JSON::XS, which uses the JSON::PP stack. The compatibility adapter is therefore present, but JSON never selects it when the caller requests JSON::XS.
The fix should connect the dispatcher to this existing adapter (or a small JSON::Backend::XS wrapper over it) when PERL_JSON_BACKEND=JSON::XS. It should preserve the distinction between selecting an XS-compatible API and actually running native XS: do not claim a native XS implementation is loaded. Keep the default PP selection and the JSON::backportPP behavior intact.
Acceptance criteria
- Add a project-owned regression for setting
PERL_JSON_BACKEND=JSON::XSbefore loadingJSON; validate the test's expected behavior with system Perl first. - On both JVM and interpreter backends, the requested
JSON::XSadapter is selected andJSON->backendsatisfiesisa JSON::XS. - The selected adapter continues to encode/decode through the bundled PP implementation and retains the existing
JSON::XSAPI behavior; native XS status is reported accurately. - Default backend selection and
PERL_JSON_BACKEND=JSON::backportPPremain unchanged. Data-Compare-Plugins-JSON1.04's unmodifiedt/05-compare-json-uses-xs.tand full suite pass through the normal PerlOnJava CPAN dependency overlay.
Related work
The existing JSON::XS shim is documented in docs/reference/xs-compatibility.md and implemented in src/main/perl/lib/JSON/XS.pm. Issue #1148 covers JSON::Parse loading without XS and is a separate problem. Issue #2097 concerns adding JSON::SL support; it may share JSON infrastructure, but does not cover backend selection.
- 主要语言
- Perl
- 星标
- 67
- 派生
- 8
- 平均合并
- 5 小时 12 分钟
- 30 天内合并 PR
- 131
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
fglock/PerlOnJava 的其他 Issue
-
area:cpan-port bug
难度 2/5 1-3 小时 新手友好度 70/100
fglock/PerlOnJava#2153 ·
维护者通常 1 天内回复
-
area:cpan-port area:parser bug
难度 2/5 1-3 小时 新手友好度 68/100
fglock/PerlOnJava#2137 ·
维护者通常 1 天内回复
-
area:backend area:cpan-port area:runtime bug
难度 2/5 1-3 小时 新手友好度 76/100
fglock/PerlOnJava#2071 ·
维护者通常 1 天内回复
-
area:runtime documentation enhancement
难度 2/5 1-3 小时 新手友好度 72/100
fglock/PerlOnJava#1579 ·
维护者通常 1 天内回复
-
area:cpan-port bug
难度 3/5 1-2 天 新手友好度 62/100
fglock/PerlOnJava#2157 ·
维护者通常 1 天内回复
查看 fglock/PerlOnJava 的全部 Issue
相似的 Issue
-
Dev-output directory preparation accepts file-valued lib/include paths and fails on dangling links未关闭team-cli
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
-
难度 1/5 1 小时以内 新手友好度 93/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 73/100
inverse-inc/packetfence#9728 ·
维护者通常 1 天内回复
-
fix(char-create): show the real reason a character is refused可能已有人在做 @baphomello 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复