Commit 1523041
Fix utf8::valid() for CPAN::Meta parsing (#346)
* Fix utf8::valid() to properly check string validity
The previous implementation used CharsetDetector which was incorrect:
- It converted the string to bytes using default charset
- Then tried to detect if those bytes were UTF-8
- This always failed for properly decoded strings
The new implementation correctly checks:
- For character strings (UTF-8 flag on): validates surrogate pairs
- For byte strings (UTF-8 flag off): decodes bytes as UTF-8
This fixes CPAN::Meta::YAML parsing which was failing with:
"Read an invalid UTF-8 string (maybe mixed UTF-8 and 8-bit character set)"
The error occurred because CPAN::Meta::YAML checks:
if (utf8::is_utf8($string) && !utf8::valid($string))
and utf8::valid() was always returning false.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* Document utf8::valid() fix in cpan_client.md (Phase 16)
Added documentation for the fix that resolved CPAN::Meta::YAML parsing
errors that were preventing proper test dependency detection.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* Fix MYMETA.yml format and create jcpan DateTime fix plan
1. ExtUtils/MakeMaker.pm: Generate meta-spec v2 format MYMETA.yml
- Test dependencies now properly detected by CPAN.pm
- Uses nested prereqs structure instead of flat v1.4 format
2. dev/design/JCPAN_DATETIME_FIXES.md: Comprehensive fix plan
- Documents all errors from clean cache DateTime install
- Prioritized implementation plan
- Critical: File::stat.pm needed for DateTime::Locale
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* Add Class::Struct and File::stat via import system; document JVM VerifyError
Phase 17 DateTime fixes:
- Import Class::Struct.pm from perl5/lib (required by File::stat)
- Import File::stat.pm from perl5/lib (required by File::ShareDir::Install)
- Document JVM VerifyError with minimal reproducer
File::stat triggers a JVM bytecode verification error due to a bug when
compiling: no strict 'refs' + for loop + defined eval { &{symbolic_ref} }
Minimal reproducer:
no strict 'refs';
for (qw(X Y Z)) { defined eval { &{"Fcntl::S_IF$_"} } }
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* Update JVM VerifyError analysis with simpler reproducer and root cause
The minimal reproducer doesn't require a for loop:
no strict 'refs';
my $result = defined eval { &{"Fcntl::S_IFX"} };
Root cause: The block dispatcher stores ordinal in controlFlowActionSlot,
but different code paths merge at a label with inconsistent types for
that slot (integer vs TOP).
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* Fix VerifyError in eval block control flow handling
When a subroutine call inside an eval block returns a control flow marker
(LAST/NEXT/REDO), the control flow dispatch code for unlabeled LAST/NEXT
was jumping to target labels with an empty operand stack, but the merge
point expected a RuntimeList on the stack.
This caused a JVM VerifyError ("Inconsistent stackmap frames") when
loading File::stat.pm or other modules that use the pattern:
eval { &{"Fcntl::S_IFX"} }
The fix pushes the control flow marker onto the stack before jumping to
the merge point, ensuring consistent stack state at all paths.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* Update design doc: JVM VerifyError fix completed
Document the root cause analysis and fix for Issue #11 (VerifyError
when loading File::stat.pm.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
EOF
)
* Add missing S_* mode constants to Fcntl.pm
File::stat.pm requires S_IRUSR, S_IWUSR, S_IXUSR and other mode constants
from Fcntl. These were listed in @EXPORT_OK but never actually defined.
Added:
- File type masks: S_IFMT, S_IFREG, S_IFDIR, S_IFLNK, etc.
- Special mode bits: S_ISUID, S_ISGID, S_ISVTX
- User permissions: S_IRUSR, S_IWUSR, S_IXUSR, S_IRWXU
- Group permissions: S_IRGRP, S_IWGRP, S_IXGRP, S_IRWXG
- Other permissions: S_IROTH, S_IWOTH, S_IXOTH, S_IRWXO
- File type test functions: S_ISREG, S_ISDIR, S_ISLNK, etc.
- Permission extraction: S_IMODE
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* Update design doc: File::stat.pm now loads successfully
Both the JVM VerifyError and the missing Fcntl constants have been fixed.
File::stat.pm now loads and works correctly.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* Fix require bareword handling with CORE::GLOBAL::require override
When CORE::GLOBAL::require is overridden and a module uses 'require Bareword;'
under strict subs, the bareword was incorrectly flagged as a strict subs violation.
Root cause: When the parser detected a CORE::GLOBAL::require override, it rewrote
the require call to a subroutine call, but the bareword argument (e.g., 'Exporter')
was parsed as an expression instead of using require's special bareword-to-filename
conversion.
Fix: Added special handling in ParsePrimary.java for 'require' when
CORE::GLOBAL::require is overridden:
1. Parse the argument using standard require handling (converts bareword to filename)
2. Build a subroutine call node with the &CORE::GLOBAL::require code ref
Also added Exporter::require_version() method which delegates to UNIVERSAL::VERSION
for historical compatibility with older Exporter usage.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* Update JCPAN_DATETIME_FIXES.md with completed fixes
- Marked Exporter::require_version as FIXED
- Marked CORE::GLOBAL::require bareword handling as FIXED
- Updated progress tracking section
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* Fix Exporter version check in import arguments
When calling Module->import('0.03', 'symbol'), Perl's Exporter treats
arguments starting with a digit as version checks, not symbols to export.
Added this logic to the Java Exporter:
1. If symbol starts with digit, call $pkg->VERSION($version)
2. If version was only argument, import from @export
3. If version + empty string ('use Foo 1.23, ""'), import nothing
4. Otherwise skip version and continue with other imports
This fixes: 'Symbol 0.03 not allowed for export in package File::ShareDir::Install'
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* Fix MakeMaker $(INST_LIB) variable expansion
When Makefile.PL scripts provide an explicit PM hash with Make-style
variables like $(INST_LIB)/Module.pm, expand them to actual paths.
Without this fix, modules would be installed to a literal '$(INST_LIB)'
directory instead of the actual install base.
This fixes Class::Inspector and similar modules using explicit PM hashes.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* Update design doc: jcpan DateTime installation complete
All blocking issues have been fixed:
- Exporter version check in import arguments
- MakeMaker $(INST_LIB) variable expansion
jcpan install DateTime now works successfully.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* Add File::ShareDir::Install support to MakeMaker
When Makefile.PL uses File::ShareDir::Install to register share directories
(via install_share()), our MakeMaker now processes @file::ShareDir::Install::DIRS
and copies those files to the proper location under auto/share/dist/<DistName>/.
This enables DateTime::Locale to work correctly, as it uses share files for
locale data (1070 .pl files for different locales).
Test: jcpan install DateTime::Locale now installs all locale data files.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* Fix IPC::Open3 redirection directive handling
When open3() is called with redirection directives like '>&STDERR', they are
read-only strings that cannot be modified. This fix:
1. In IPCOpen3.java:
- Added isOutputRedirection() and isInputRedirection() to detect >&/&< directives
- Added handleOutputRedirection() to pipe process output to named handles
- Added isUsableHandle() to properly detect undef handles (not just reference-to-undef)
- Added getStringValue() to properly dereference scalar references
2. In Open3.pm:
- Check for redirection directives before trying to update caller's variables
- Skip assignment to $_[N] when it's a redirection directive (read-only)
This fixes: 'open3: Modification of a read-only value attempted' errors in
tests like t/00-compile.t that use open3($stdin, '>&STDERR', $stderr, ...).
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
---------
Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>1 parent ff238cc commit 1523041
14 files changed
Lines changed: 1808 additions & 32 deletions
File tree
- dev
- design
- import-perl5
- src/main
- java/org/perlonjava
- backend/jvm
- core
- frontend/parser
- runtime/perlmodule
- perl/lib
- Class
- ExtUtils
- File
- IPC
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
355 | 355 | | |
356 | 356 | | |
357 | 357 | | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
358 | 410 | | |
359 | 411 | | |
360 | 412 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
175 | 179 | | |
176 | 180 | | |
177 | 181 | | |
| |||
620 | 624 | | |
621 | 625 | | |
622 | 626 | | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
623 | 632 | | |
624 | 633 | | |
625 | 634 | | |
| |||
0 commit comments