eProsima / Fast-DDS-Gen

Fast-DDS IDL code generator tool. Looking for commercial support? Contact info@eprosima.com
Apache License 2.0
76 stars 59 forks source link

Failures with multiple consecutive directory separators #328

Closed mtheall closed 2 months ago

mtheall commented 3 months ago

Fast-DDS-Gen v2.4.0 (also seen with v3.3.0) IDL-Parser v1.5.0

It appears that for some reason arguments passed to java on my Windows machine double all directory separators. For example:

import java.nio.file.Path;
import java.nio.file.Paths;

public class xyz
{
    public static void main(
            String[] args)
    {
        for (int i = 0; i < args.length; ++i)
        {
            System.out.println(args[i]);
        }
    }
}

If I pass C:\Windows then this program prints C:\\Windows. Same problem applies to fastddsgen.bat. The problem happens when I execute fastddsgen.jar directly. It happens if I use cmd.exe. It happens if I use PowerShell. It happens if I execute this from CMake. So I'm pretty sure it's not a command interpreter problem; possibly a quirk of the java runtime.

I'm using Oracle Java:

> java -version
java version "17.0.9" 2023-10-17 LTS
Java(TM) SE Runtime Environment (build 17.0.9+11-LTS-201)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.9+11-LTS-201, mixed mode, sharing)

With the same jars, my coworker does not experience this problem, but is using OpenJDK:

> java -version
OpenJDK version "11.0.22" 2024-01-16 LTS
OpenJDK Runtime Environment (Red_Hat-11.0.22+7-1) (build 11.0.22+7-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.22+7-1) (build 11.0.22+7-LTS, mixed mode)

This causes several issues in Fast-DDS-Gen and IDL-Parser which compare paths only by string comparison:

Here's some changes I made to Fast-DDS-Gen v2.4.0 that fixes:

And changes to IDL-Parser v1.5.0:



Perhaps a deeper investigation will expose more problems.