On Fri, 3 Apr 2026 01:32:00 GMT, Yasumasa Suenaga <[email protected]> wrote:
>> @YaSuenag Thanks for letting me know about the WSL issue and for diving
>> into the details. And thanks also to @erikj79 for pointing out that not all
>> references to C: occur with the intent of reading/writing files or
>> directories. Indeed, the zeal to get rid of all hardcoded references wasn't
>> helpful. :)
>>
>> I've added a commit that gets rid of the `SYSTEMROOT` environment variable,
>> whose absence on WSL2 was the root of the issue. Here's the full commit
>> message that explains the details.
>>
>>> The key reason that the previous patch broke the build on WSL but not
>>> Cygwin and MSys2 was that on WSL, `SYSTEMROOT` (and related environment
>>> variables like `SYSTEMDRIVE`) are not set, whereas the previous patch
>>> was heavily reliant on these environment variables to find the drive
>>> letter. With `SYSTEMROOT` absent on WSL, fixpath.sh received invalid
>>> paths as arguments, causing it to output invalid paths like ":", thus
>>> ultimately breaking the build in strange ways.
>>>
>>> As Erik Joelsson pointed out, the build discovers the path to cmd.exe
>>> early in the process using the `PATH` env var alone (Cygwin, MSys2, and
>>> WSL all inherit the full Windows PATH). With the location of cmd.exe
>>> reliably discovered no matter the environment, we can now infer the
>>> drive letter and other Windows paths from the path to cmd.exe instead of
>>> using environment-specific variables.
>>>
>>> This patch effectively rewrites the previous commit using the path to
>>> cmd.exe alone. Of course, if we aren't able to detect the path to
>>> cmd.exe, everything in this patch will fail, but in that case, the build
>>> fails early, clearly indicating that there are bigger problems:
>>>
>>> ```
>>> configure: error: Incorrect Windows/wsl2 setup. Could not locate cmd.exe
>>> configure exiting with result code 1
>>> ```
>>>
>>> Thanks to Yasumasa Suenaga for discovering the problem. Validated that
>>> this build works on Cygwin, WSL2, Linux, and macOS.
>>
>> I'll update the PR description to reflect the change.
>
> @raneashay
> The latest commit works fine on my WSL 1. Thank you for fixing!
>
> BTW is it ok not to fix test/jdk/java/awt/Dialog/FileDialogUIUpdate.java ?
> Your first commit has a change for it, but it has gone now...
@YaSuenag I realized that the change to that test isn't strictly necessary,
since the FileDialog will default to the current directory if the specified
directory doesn't exist.
import java.awt.Frame;
import java.awt.FileDialog;
public class test {
private Frame frame;
public static void main(String[] args){ new test(); }
private test(){
final FileDialog fileDialog = new FileDialog(frame, "Select file");
fileDialog.setDirectory("n:");
fileDialog.setVisible(true);
System.exit(0);
}
}
-------------
PR Comment: https://git.openjdk.org/jdk/pull/30523#issuecomment-4183777626