Skip to content

feat(modules): bundle common::sense#564

Merged
fglock merged 2 commits intomasterfrom
feature/common-sense-support
Apr 26, 2026
Merged

feat(modules): bundle common::sense#564
fglock merged 2 commits intomasterfrom
feature/common-sense-support

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Apr 26, 2026

Summary

Bundles a full implementation of common::sense so use common::sense; works out of the box in PerlOnJava.

Per the CPAN compatibility report (refreshed in this PR), common::sense is a direct dependency of ~19 modules (CBOR::XS, AnyEvent::HTTP, Types::Serialiser, JSON::XS::VersionOneAndTwo, several Catalyst plugins, etc.) and many more transitively. Previously its install failed because upstream's sense.pm is generated at build time from sense.pm.PL, which PerlOnJava's installer doesn't run — so every dependent failed at Can't locate common/sense.pm.

What it does

src/main/perl/lib/common/sense.pm reproduces all the behaviours of upstream common-sense 3.75:

  • use strict (vars/refs/subs)
  • use utf8
  • use warnings FATAL => qw(closed threads internal debugging pack malloc prototype inplace io pipe unpack glob digit printf layer reserved taint closure semicolon)
  • no warnings qw(exec newline unopened)
  • use feature qw(say state switch fc evalbytes current_sub unicode_strings)

Why high-level pragmas instead of ${^WARNING_BITS} / $^H mutation

Upstream sense.pm mutates ${^WARNING_BITS} and $^H directly via byte-level masks. PerlOnJava's parser honors that for inline -E scripts but not reliably when mutated mid-compile from a .pm loaded via use from a script file. Using the high-level pragmas (strict->import, feature->import, etc.) propagates the lexical state into the caller's scope on both code paths.

Verification

  • ./jcpan -t common::senseResult: PASS (both upstream tests pass: t/00_load.t, t/01_arch.t).
  • Verified caller-scope propagation: strict vars / strict refs / say / fc / state are all active in the caller's package after use common::sense; (tested in both main and other packages).
  • Warning behaviour matches system Perl exactly — only the FATAL categories common::sense enables; uninitialized is not warned (matches upstream).
  • ./jcpan -t Types::Serialiser (a downstream dependent) successfully resolves the common::sense prereq and proceeds to its own tests.
  • make passes.

Note on stale installs

@INC lists ~/.perlonjava/lib before the bundled JAR. If a user previously had a partially-installed ~/.perlonjava/lib/common/sense.pm from before this change, it would shadow the bundled version. The fix is rm -f ~/.perlonjava/lib/common/sense.pm. New installs / clean machines are unaffected — jcpan's MakeMaker shim auto-detects the JAR-bundled module and skips installing the .pm (it still installs sense.pod).

Test plan

  • make (build + unit tests) passes
  • ./jcpan -t common::sense PASS
  • Caller-scope pragma propagation verified
  • Downstream Types::Serialiser resolves the dep

Files

  • src/main/perl/lib/common/sense.pm — new
  • dev/cpan-reports/cpan-compatibility{.md,-pass.dat,-fail.dat} — refreshed report

Generated with Devin

fglock and others added 2 commits April 26, 2026 17:43
Adds src/main/perl/lib/common/sense.pm so `use common::sense` works
out of the box. Implements all the behaviours of the upstream module:
strict, utf8, the FATAL warning categories common::sense enables,
the lenient warnings it suppresses (exec/newline/unopened), and the
features it turns on (say, state, switch, fc, evalbytes, current_sub,
unicode_strings).

Upstream's sense.pm is generated at install time from sense.pm.PL and
mutates ${^WARNING_BITS} and $^H directly. PerlOnJava's parser doesn't
fully honor mid-script %^H feature mutations from a bundled .pm loaded
via `use`, so we use the high-level pragmas (strict/warnings/feature/
utf8) instead. End result is identical from the user's perspective.

Verified:
- ./jcpan -t common::sense -> Result: PASS (both upstream tests).
- make passes.

Per the CPAN compatibility report, common::sense is a direct dependency
of ~19 modules (CBOR::XS, AnyEvent::HTTP, Types::Serialiser, etc.) and
many more transitively, so this unblocks a meaningful chunk of CPAN.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock fglock force-pushed the feature/common-sense-support branch from 0ff5901 to 33badb0 Compare April 26, 2026 15:43
@fglock fglock merged commit 250d1df into master Apr 26, 2026
2 checks passed
@fglock fglock deleted the feature/common-sense-support branch April 26, 2026 18:38
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.

1 participant