Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 38 additions & 52 deletions dev/design/cpan_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ cpan> install Module::Name

---

## Phase 11: DateTime Dependency Investigation (2026-03-19)
## Phase 11: DateTime Dependency Investigation (2026-03-19, UPDATED)

### Problem Statement

Expand All @@ -540,60 +540,57 @@ When running `jcpan install DateTime`, CPAN reports "DateTime is up to date (1.6

However, when actually using DateTime, the CPAN-installed `DateTime.pm` fails to load due to missing dependencies.

### Dependency Chain Analysis
### Current Status (Updated 2026-03-19)

**Symbol table dereference bug: FIXED**

```perl
# Now works correctly
./jperl -e 'package Foo; our $VERSION = "1.0"; print ${ $Foo::{VERSION} }, "\n"'
# Output: 1.0
```

**New blocker discovered**: Package::Stash::PP doesn't return a true value.

```
Could not find a suitable Package::Stash implementation:
Can't locate Package/Stash/XS.pm
Package/Stash/PP.pm did not return a true value
```

### Dependency Chain Analysis (Updated)

```
DateTime.pm
├── namespace::autoclean 0.19
│ └── B::Hooks::EndOfScope (XS - MISSING)
│ └── namespace::clean
│ └── Package::Stash
│ └── Module::Implementation
│ ├── ${ $stash{NAME} } - FIXED
│ └── Package::Stash::PP - BROKEN (doesn't return true)
├── Params::ValidationCompiler 0.26 ✓
├── Specio::Subs
│ └── Specio
│ └── Module::Implementation
│ └── BUG: ${ $Package::{NAME} } returns empty
├── Specio::Subs ✓ (after Package::Stash fix)
├── Try::Tiny ✓
├── DateTime::Locale 1.06
├── DateTime::TimeZone 2.44
└── POSIX (built-in) ✓
```

### Root Cause: Symbol Table Dereference Bug

**Bug discovered**: `${ $Package::{NAME} }` returns empty instead of the variable value.

```perl
# PerlOnJava - BROKEN
package Foo;
our $VERSION = "1.0";
my $glob = $Foo::{VERSION};
print ${$glob}; # prints empty string (should print "1.0")

# Perl5 - WORKS
package Foo;
our $VERSION = "1.0";
my $glob = $Foo::{VERSION};
print ${$glob}; # prints "1.0"
```

This bug blocks `Module::Implementation` which is used by `Specio` which is used by `DateTime`.

### Blocking Issues Summary

| Issue | Module Affected | Status |
|-------|-----------------|--------|
| `${ $stash{NAME} }` dereference | Module::Implementation | **BUG - needs fix** |
| B::Hooks::EndOfScope (XS) | namespace::autoclean | XS module - needs stub or Java impl |
| ~~`${ $stash{NAME} }` dereference~~ | ~~Module::Implementation~~ | **FIXED** |
| Package::Stash::PP doesn't return true | Package::Stash | **BUG - needs investigation** |

### Proposed Solutions

#### Option A: Fix Symbol Table Dereference (Recommended)
#### Option A: Fix Package::Stash::PP (Recommended)

Fix the bug where `${ $glob_from_stash }` doesn't properly dereference to the scalar value.
Investigate why Package::Stash::PP.pm doesn't return a true value.

**Files to investigate:**
- `RuntimeScalar.java` - scalar dereference
- `RuntimeGlob.java` - glob handling
- `GlobalContext.java` - symbol table access
- `~/.perlonjava/lib/Package/Stash/PP.pm` - Check for compilation errors

#### Option B: Create Bundled DateTime.pm

Expand All @@ -602,31 +599,20 @@ Create a simplified `DateTime.pm` in `src/main/perl/lib/` that:
2. Uses our Java XS implementation or DateTime::PP
3. Provides core DateTime functionality

This is a fallback if Option A is too complex.

#### Option C: Document DateTime as Requiring Manual Setup

Document that DateTime requires additional setup and can't be installed via jcpan directly.

### Investigation Commands

```bash
# Test symbol table dereference
# Test symbol table dereference (NOW FIXED)
./jperl -e 'package Foo; our $VERSION = "1.0"; print ${ $Foo::{VERSION} }, "\n"'
# Output: 1.0 (correct)

# Compare with Perl5
perl -e 'package Foo; our $VERSION = "1.0"; print ${ $Foo::{VERSION} }, "\n"'

# Test Module::Implementation
./jperl -e 'use Module::Implementation; print "OK\n"'

# Test DateTime after fix
# Test DateTime - still blocked by namespace::autoclean
./jperl -MDateTime -e 'print DateTime->now->ymd, "\n"'
# Error: Can't locate namespace/autoclean.pm
```

### Next Steps

1. **Investigate** `RuntimeScalar.java` and `RuntimeGlob.java` for scalar dereference from stash glob
2. **Fix** the `${ $glob }` pattern when glob comes from `%Package::` stash
3. **Test** Module::Implementation, Specio, DateTime in sequence
4. **Alternative**: If fix is complex, create bundled DateTime.pm wrapper
1. **Install namespace::autoclean dependencies** via jcpan to test further
2. **If blocked by Package::Stash::PP**, investigate why modules ending with `sub foo { }` return undef
3. **Alternative**: Create bundled DateTime.pm wrapper that skips heavy dependencies
26 changes: 15 additions & 11 deletions dev/design/log4perl-compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,22 +223,24 @@ BEGIN failed--compilation aborted at -e line 1, near ""
**Affected Tests:**
- t/016Export.t (1 failure)

### Issue 4: File Permissions (stat/chmod)
### Issue 4: Multiple File Appenders (Pre-existing)

**Status:** Unchanged - needs investigation.
**Status:** Pre-existing bug - NOT a regression.

**Symptom:** t/026FileApp.t tests 6-7 fail comparing expected vs actual file permissions.
**Symptom:** t/026FileApp.t tests 6-7 fail - when using two file appenders, both messages go to the second file and the first file is empty.

**Example:**
**Test:**
```perl
# Expected: '488' (octal 0750)
# Got: '511' (octal 0777)
# Two appenders configured: FileAppndr1 -> file1, FileAppndr2 -> file2
$log->info("Shu-wa-chi!");
# Expected: Each file gets "INFO - Shu-wa-chi!"
# Got: file1 is empty, file2 gets the message twice
```

**Root Cause:** Likely issue with `umask` handling or `chmod` implementation.
**Root Cause:** Unknown - possibly related to how multiple file handles are managed when opening different files with similar configurations.

**Affected Tests:**
- t/026FileApp.t (tests 6-7, 25)
- t/026FileApp.t (tests 6-7)

### Issue 5: Safe.pm Compartment Restrictions

Expand Down Expand Up @@ -414,16 +416,18 @@ For chmod/umask:
- [x] caller() line number fix (2026-03-19) - Fixed 7/8 failures
- [x] eval block "(eval)" name in caller() (2026-03-19) - Fixed test 62
- [x] local $OurVariable fix (2026-03-19) - Fixed %T stack trace format
- [x] mkdir umask handling (2026-03-19, PR #338) - Fixed t/026FileApp.t test 25
- [x] local *GLOB semantics (2026-03-19, PR #338) - Correct file handle capture

### Active Issues
- [ ] DESTROY during global destruction (1 test)
- [ ] chmod/file permissions (3 tests)
- [ ] Multiple file appenders - pre-existing (2 tests) - tests 6-7 in t/026FileApp.t
- [ ] Safe.pm restrictions (3 tests)
- [ ] Source filters (1 test)

### Next Steps
1. Investigate DESTROY during global destruction
2. Investigate chmod/file permissions issue
1. Investigate multiple file appenders bug
2. Investigate DESTROY during global destruction

---

Expand Down
Loading