Conversation
…ng shim
Two fixes uncovered by `jcpan -t User::Identity`:
1. `values %h` returned the LAST value (instead of the element count)
when used as the final expression of a sub called in scalar context.
`RuntimeHash.keys()` already set `scalarContextSize` on the result
so `getList()` wrapped (rather than copied) it; `values()` did not,
so the resulting list scalarized to its last element. Mirror keys()
by setting `scalarContextSize` in both the plain and TIED_HASH paths
of `RuntimeHash.values()`. Fixes both JVM and interpreter backends.
2. The pure-Perl `Unicode::GCString` shim used by Text::vCard et al was
defined as a second package inside `lib/Unicode/LineBreak.pm`. Two
consequences:
* `use Unicode::GCString` (without first loading LineBreak) could
not find a .pm file. String::Print does exactly that.
* MakeMaker's "skip files bundled in the PerlOnJava JAR" logic
only matched `Unicode/LineBreak.pm`, so installing CPAN's
Unicode-LineBreak distribution would shadow the shim with the
broken XS-needing version.
Move the shim into its own file `src/main/perl/lib/Unicode/GCString.pm`
and have LineBreak.pm `require` it. Now both files are visible under
jar:PERL5LIB and the SKIP logic preserves both.
Together these unblock the full User::Identity dependency chain
(Log::Report -> Log::Report::Util -> String::Print -> Unicode::GCString)
so `jcpan -t User::Identity` now passes all 114 subtests.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two fixes uncovered while investigating
jcpan -t User::Identity. The full dependency chain isUser::Identity→Log::Report→Log::Report::Util→String::Print→Unicode::GCString, and it was failing at every step.1.
values %hin scalar context as a sub's last expressionRuntimeHash.keys()setscalarContextSizeon the resultingRuntimeArraysogetList()wrapped (rather than copied) it;values()did not, so the resulting list scalarized to its last element instead of the count. Affected both JVM and interpreter backends.Fix: mirror
keys()and setlist.scalarContextSize = list.elements.size()in both the plain andTIED_HASHpaths ofRuntimeHash.values().This was the root cause of
t/30col.tfailures inUser::Identity, whereUser::Identity::Collection::rolesis defined assub roles() { values %{ $_[0]->{UIC_roles}} }and called viacmp_ok($col->roles, '==', 1, ...).2.
Unicode::GCStringshim wasn't a discrete fileThe pure-Perl shim of
Unicode::GCStringlived as a second package insidelib/Unicode/LineBreak.pm. Two problems followed:use Unicode::GCString(without first loadingLineBreak) couldn't find a.pmfile, so it failed with "Can't locate Unicode/GCString.pm".String::Printdoes exactly this.Unicode/LineBreak.pm. Installing CPAN'sUnicode-LineBreakdistribution would therefore install/shadow the shim with the XS-needingUnicode/GCString.pmfrom blib, which then died with "Can't locate object method_new".Fix: move the shim into its own file
src/main/perl/lib/Unicode/GCString.pmand haveLineBreak.pmrequireit. Now both files are visible underjar:PERL5LIBand the SKIP logic preserves both:Result
jcpan -t User::Identitynow passes all 114 subtests across 3 test files (was 4/4 subtests failing becauseuse User::Identityblew up immediately).String::Printtest pass rate jumps from 1/19 test files to 15/19; remaining failures are wide-character column-width formatting in the shim, unrelated to this PR.Test plan
make(full unit test suite) — passes./jperl -e '...'and./jperl --interpreter -e '...'— both yield count 3 forvalues %hin sub-scalar context./jcpan -t User::Identity—Result: PASS, all 114 subtests successfulGenerated with Devin