private static PathOrException normalizePathInJavaSystemProperty(
            final String propertyName, final Properties javaSystemProperties, final Logger logger) {
        final String property = javaSystemProperties.getProperty(propertyName);

        if (property == null || property.isEmpty()) {
            final String message = "Java system property \"" + propertyName + "\" is unexpectedly unset.";
            final IllegalArgumentException ex = new IllegalArgumentException(message);
            logger.error(message, ex);
            return new PathOrException(ex);
        }

        final Path path;
        try {
            path = Paths.get(property);
        } catch (final InvalidPathException ex) {
            logger.error("Java system property \"" + propertyName + "\" is unexpectedly invalid: \"" + property + "\"", ex);
            return new PathOrException(ex);
        }

        if (!path.isAbsolute()) {
            final String message = "Java system property \"" + propertyName + "\" is unexpectedly not absolute.";
            final IllegalArgumentException ex = new IllegalArgumentException(message);
            logger.error(message, ex);
            return new PathOrException(ex);
        }

        final Path normalized = path.normalize();
        if (!normalized.equals(path)) {
            logger.warn("Java system property \"" + propertyName + "\" is unexpectedly not normalized: \"" + property + "\", "
                                + "then resolved to: \"" + normalized.toString() + "\"");
        }

        // Symbolic links are intentionally NOT resolved with Path#toRealPath.
        return new PathOrException(normalized);
    }
Returns a normalized path in a specified Java system property "user.home" or "user.dir".

<p>Note that a path in a Java system property should be an absolute path.
embulk-core/src/main/java/org/embulk/cli/EmbulkSystemPropertiesBuilder.java