Windows PowerShell scripts: parity polish after #8
Following the merge of #8 (huge thanks to @philjn for adding native Windows support — much appreciated, the structure is solid and the security review came back clean), I did a deeper side-by-side comparison of the four new PowerShell scripts against their bash counterparts on master.
That comparison surfaced a handful of items where the *.ps1 scripts could use a small follow-up to bring them to full feature parity — mostly behaviors that landed in *.sh via #10 (partial-success handling, fernflower timeout) and a couple of small refinements specific to the PowerShell implementation.
These are not blockers — the PS1 scripts work end-to-end on Windows — but bringing them to full parity will make the Windows experience match the Linux/macOS one.
Status
Remaining items
decompile.ps1 — feature parity with decompile.sh post-#10
1. Surface jadx exit code in Invoke-Jadx (~line 178)
The function currently returns $true regardless of jadx's exit code. The bash equivalent returns 0 (success), 2 (partial success — exit non-zero but Java files produced), or 1 (hard failure). Aligning the PS1 to the same trichotomy would let Invoke-DecompileSingle route the "both" engine flow correctly when jadx warnings occur.
2. Surface fernflower exit code in Invoke-Fernflower (~line 241)
Same pattern as #1 — capture $LASTEXITCODE and return 0/1/2 so the caller knows whether to continue or to fall back to the other engine.
3. Warning grep in the both engine summary (~line 302)
Select-String -Pattern '...|...' -SimpleMatch treats the | characters literally, so the "files with warnings/errors" count currently always reports 0. Removing -SimpleMatch (the pattern is already a valid regex) restores the intended behavior.
4. Show-Structure ordering (~lines 250-253)
The pipeline currently does Select-Object -First 20 | Sort-Object, which sorts only whichever 20 results came first from the filesystem enumeration. Swapping the order to Sort-Object | Select-Object -First 20 makes the top-level package list deterministic and aligned with the bash version. Also -Depth 2 could become -Depth 3 to match the bash -maxdepth 3.
5. Optional fernflower timeout (FERNFLOWER_TIMEOUT_SECONDS)
The bash version added a default 900s timeout in #10 to prevent indefinite hangs on Compose-heavy APKs. PowerShell doesn't have a native timeout(1); one option is Start-Job + Wait-Job -Timeout, another is System.Diagnostics.Process + WaitForExit($ms). Either approach would be welcome.
6. Intermediate dex2jar artifact directory
The bash version writes the converted jar into an intermediate/ subdirectory and only cleans it up on success (preserved on failure for debugging). Currently the PS1 writes it directly into the output dir alongside the sources.
7. Fallback for "Vineflower writes sources directly"
When Vineflower (rather than classic Fernflower) is the engine, output may land directly in the destination folder rather than as a result jar. The bash version handles both cases at lines ~296-312; the PS1 only handles the result-jar case.
install-dep.ps1 — minor refinement
8. Add-ToUserPath substring match is too permissive (line 76)
$currentPath -notlike "*$Dir*" returns false if PATH already contains a directory whose name is a superstring of $Dir (e.g. asking to add C:\foo when PATH already contains C:\foo\bar). Splitting on ; and doing an exact -notcontains check would be more correct.
How to take this forward
No pressure either way, @philjn — if any of these look interesting and you'd like to take a stab at one or more, you'd be very welcome. Otherwise I'm happy to get to them whenever I have a Windows VM available for proper testing, no rush at all.
Items 1-4 are the most user-visible (warning detection, exit code propagation, deterministic listing); 5-7 are nice-to-have parity with the recent bash improvements; 8 is a tiny edge case.
Feel free to drop a comment here, open a PR, or just leave it for me — whatever fits your schedule.
IMPORTANT
Since there is a large change I've been working on then the original .sh scripts will see some substantial changes. Before working on this issue it makes sense to wait after I merge the big changes.
Windows PowerShell scripts: parity polish after #8
Following the merge of #8 (huge thanks to @philjn for adding native Windows support — much appreciated, the structure is solid and the security review came back clean), I did a deeper side-by-side comparison of the four new PowerShell scripts against their bash counterparts on master.
That comparison surfaced a handful of items where the
*.ps1scripts could use a small follow-up to bring them to full feature parity — mostly behaviors that landed in*.shvia #10 (partial-success handling, fernflower timeout) and a couple of small refinements specific to the PowerShell implementation.These are not blockers — the PS1 scripts work end-to-end on Windows — but bringing them to full parity will make the Windows experience match the Linux/macOS one.
Status
f3fb1e9on master: alignedinstall-dep.ps1to theThexXTURBOXx/dex2jarfork (mirroring fix: use maintained dex2jar fork #12).Remaining items
decompile.ps1— feature parity withdecompile.shpost-#101. Surface jadx exit code in
Invoke-Jadx(~line 178)The function currently returns
$trueregardless of jadx's exit code. The bash equivalent returns0(success),2(partial success — exit non-zero but Java files produced), or1(hard failure). Aligning the PS1 to the same trichotomy would letInvoke-DecompileSingleroute the "both" engine flow correctly when jadx warnings occur.2. Surface fernflower exit code in
Invoke-Fernflower(~line 241)Same pattern as #1 — capture
$LASTEXITCODEand return0/1/2so the caller knows whether to continue or to fall back to the other engine.3. Warning grep in the
bothengine summary (~line 302)Select-String -Pattern '...|...' -SimpleMatchtreats the|characters literally, so the "files with warnings/errors" count currently always reports0. Removing-SimpleMatch(the pattern is already a valid regex) restores the intended behavior.4.
Show-Structureordering (~lines 250-253)The pipeline currently does
Select-Object -First 20 | Sort-Object, which sorts only whichever 20 results came first from the filesystem enumeration. Swapping the order toSort-Object | Select-Object -First 20makes the top-level package list deterministic and aligned with the bash version. Also-Depth 2could become-Depth 3to match the bash-maxdepth 3.5. Optional fernflower timeout (
FERNFLOWER_TIMEOUT_SECONDS)The bash version added a default 900s timeout in #10 to prevent indefinite hangs on Compose-heavy APKs. PowerShell doesn't have a native
timeout(1); one option isStart-Job+Wait-Job -Timeout, another isSystem.Diagnostics.Process+WaitForExit($ms). Either approach would be welcome.6. Intermediate dex2jar artifact directory
The bash version writes the converted jar into an
intermediate/subdirectory and only cleans it up on success (preserved on failure for debugging). Currently the PS1 writes it directly into the output dir alongside the sources.7. Fallback for "Vineflower writes sources directly"
When Vineflower (rather than classic Fernflower) is the engine, output may land directly in the destination folder rather than as a result jar. The bash version handles both cases at lines ~296-312; the PS1 only handles the result-jar case.
install-dep.ps1— minor refinement8.
Add-ToUserPathsubstring match is too permissive (line 76)$currentPath -notlike "*$Dir*"returns false if PATH already contains a directory whose name is a superstring of$Dir(e.g. asking to addC:\foowhen PATH already containsC:\foo\bar). Splitting on;and doing an exact-notcontainscheck would be more correct.How to take this forward
No pressure either way, @philjn — if any of these look interesting and you'd like to take a stab at one or more, you'd be very welcome. Otherwise I'm happy to get to them whenever I have a Windows VM available for proper testing, no rush at all.
Items 1-4 are the most user-visible (warning detection, exit code propagation, deterministic listing); 5-7 are nice-to-have parity with the recent bash improvements; 8 is a tiny edge case.
Feel free to drop a comment here, open a PR, or just leave it for me — whatever fits your schedule.
IMPORTANT
Since there is a large change I've been working on then the original .sh scripts will see some substantial changes. Before working on this issue it makes sense to wait after I merge the big changes.