Skip to content

feat(Compress::Bzip2): real bzip2 backend via Apache Commons Compress#629

Merged
fglock merged 1 commit intomasterfrom
feature/compress-bzip2-20260429-195829
Apr 29, 2026
Merged

feat(Compress::Bzip2): real bzip2 backend via Apache Commons Compress#629
fglock merged 1 commit intomasterfrom
feature/compress-bzip2-20260429-195829

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Apr 29, 2026

Summary

Fixes ./jcpan -t CPAN::Checksums, which previously failed for two unrelated reasons.

1. Shebang parser rejected emacs mode markers

Makefile.PL started with #!/usr/bin/perl -w -*- mode: cperl -*-. PerlOnJava parsed -*- as a CLI switch and aborted with Unrecognized switch: -*-. Real perl tolerates -*- ... -*- in the shebang line. ArgumentParser now strips the marker before processing switches.

2. Real Compress::Bzip2 backend

CPAN::Checksums.pm does use Compress::Bzip2(); unconditionally. PerlOnJava had no Bzip2 implementation, so the module load died inside XSLoader.

  • Add Apache Commons Compress 1.27.1 to pom.xml, build.gradle, and gradle/libs.versions.toml.
  • New Java backend mirroring the existing CompressZlib / CompressZlibGzFile pattern:
    • CompressBzip2.javamemBzip, memBunzip, bzip2, bzunzip, bzopen, plus all BZ_* status constants.
    • CompressBzip2BzFile.javabzread, bzwrite, bzreadline, bzeof, bzclose, bzerror on the handle returned by bzopen.
  • New lib/Compress/Bzip2.pm calls XSLoader::load('Compress::Bzip2'), which auto-discovers the Java backend (no GlobalContext wiring needed).

Test plan

  • ./jcpan -t CPAN::ChecksumsFiles=4, Tests=31, Result: PASS
  • make (full unit test suite) green on rebased branch
  • In-memory bzip2 round-trip verified (memBzip -> memBunzip)
  • File round-trip verified via bzopen + bzread + bzclose

Generated with Devin

Two issues kept `./jcpan -t CPAN::Checksums` from running:

1. Shebang parser rejected emacs mode markers like
   `#!/usr/bin/perl -w -*- mode: cperl -*-` with
   `Unrecognized switch: -*-`. Real perl tolerates `-*- ... -*-`
   in the shebang line. ArgumentParser now strips the marker
   before processing switches.

2. CPAN::Checksums does `use Compress::Bzip2();` unconditionally,
   but PerlOnJava had no Bzip2 implementation, so module load died
   in XSLoader. Add a real Java-backed Compress::Bzip2:

   - Add commons-compress 1.27.1 dependency (Gradle, Maven, version
     catalog).
   - CompressBzip2 / CompressBzip2BzFile Java modules implementing
     memBzip, memBunzip, bzip2, bzunzip, bzopen, and the OO handle
     methods bzread, bzwrite, bzreadline, bzeof, bzclose, bzerror,
     plus the BZ_* status constants. Mirrors the existing
     CompressZlib / CompressZlibGzFile pattern.
   - lib/Compress/Bzip2.pm calls XSLoader::load('Compress::Bzip2'),
     which auto-discovers the Java backend (no GlobalContext wiring
     needed).

Verified: in-memory and file round-trips work; `jcpan -t
CPAN::Checksums` now passes (Files=4, Tests=31, Result: PASS);
`make` (full unit test suite) is green.

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock fglock merged commit 7126a8c into master Apr 29, 2026
2 checks passed
@fglock fglock deleted the feature/compress-bzip2-20260429-195829 branch April 29, 2026 18:57
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