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:
PubSubTypes.h and PubSubTypes.cxx are not generated
#include's use full paths instead of relative to -I paths
(semi-related) I had some problem with #include's having backslashes
Here's some changes I made to Fast-DDS-Gen v2.4.0 that fixes:
normalize path to remove redundant path separators
m_idlFiles.add(Paths.get(arg).normalize().toString());
}
else if (arg.equals("-example"))
{
And changes to IDL-Parser v1.5.0:
normalize path to remove redundant path separators
replace \ with / for #include dependencies
diff --git a/src/main/java/com/eprosima/idl/context/Context.java b/src/main/java/com/eprosima/idl/context/Context.java
index 3c94012..f382acc 100644
--- a/src/main/java/com/eprosima/idl/context/Context.java
+++ b/src/main/java/com/eprosima/idl/context/Context.java
@@ -45,6 +45,7 @@ import com.eprosima.idl.util.Pair;
import com.eprosima.idl.util.Util;
import java.io.File;
import java.io.StringReader;
+import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -111,7 +112,7 @@ public class Context
// The scope file has to be initialized because could occur the preprocessor
// is not called (using -ppDisable).
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:
If I pass
C:\Windows
then this program printsC:\\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:
With the same jars, my coworker does not experience this problem, but is using OpenJDK:
This causes several issues in Fast-DDS-Gen and IDL-Parser which compare paths only by string comparison:
#include
's use full paths instead of relative to-I
paths#include
's having backslashesHere's some changes I made to Fast-DDS-Gen v2.4.0 that fixes:
normalize path to remove redundant path separators
And changes to IDL-Parser v1.5.0:
replace
\
with/
for#include
dependenciesm_scopeFile = Paths.get(m_file).normalize().toString();
@@ -138,12 +139,7 @@ public class Context { include = include.substring(m_directoryFile.length()); }
m_includePaths.add(Paths.get(include).normalize().toString() + java.io.File.separator); }
@@ -854,7 +850,7 @@ public class Context
String file = Paths.get(scanner.next()).normalize().toString();
@@ -951,7 +947,7 @@ public class Context }