From 126b9a35079e5efbd5970eec53eeca97fada7d68 Mon Sep 17 00:00:00 2001 From: Tomas Zezula Date: Tue, 21 May 2019 10:05:07 +0200 Subject: [PATCH 1/2] [GR-14598] Language environment and Truffle FileSystem does not expose the path separator. --- sdk/CHANGELOG.md | 3 +++ .../src/org/graalvm/polyglot/io/FileSystem.java | 12 ++++++++++++ truffle/CHANGELOG.md | 1 + .../polyglot/VirtualizedFileSystemTest.java | 9 +++++++++ .../com/oracle/truffle/api/TruffleLanguage.java | 17 +++++++++++++++++ 5 files changed, 42 insertions(+) diff --git a/sdk/CHANGELOG.md b/sdk/CHANGELOG.md index abd09574d48a..bed2b70ace45 100644 --- a/sdk/CHANGELOG.md +++ b/sdk/CHANGELOG.md @@ -6,6 +6,9 @@ This changelog summarizes major changes between GraalVM SDK versions. The main f * Removed deprecated `OptionCategory.DEBUG` (use `OptionCategory.INTERNAL` instead). ## Version 19.0.0 +* The path separator is provided by [FileSystem](http://www.graalvm.org/sdk/javadoc/org/graalvm/polyglot/io/FileSystem.html#getPathSeparator--). + +## Version 1.0.0 RC17 * `Value.as(Interface.class)` now requires interface classes to be annotated with `HostAccess.Implementable` in `EXPLICIT` host access mode. Added new APIs to configure implementable behavior in HostAccess. ## Version 1.0.0 RC16 diff --git a/sdk/src/org.graalvm.polyglot/src/org/graalvm/polyglot/io/FileSystem.java b/sdk/src/org.graalvm.polyglot/src/org/graalvm/polyglot/io/FileSystem.java index ddd3ae2733fa..2ea513cdeb08 100644 --- a/sdk/src/org.graalvm.polyglot/src/org/graalvm/polyglot/io/FileSystem.java +++ b/sdk/src/org.graalvm.polyglot/src/org/graalvm/polyglot/io/FileSystem.java @@ -40,6 +40,7 @@ */ package org.graalvm.polyglot.io; +import java.io.File; import java.io.IOException; import java.net.URI; import java.nio.channels.SeekableByteChannel; @@ -349,6 +350,17 @@ default String getSeparator() { return parsePath("").getFileSystem().getSeparator(); } + /** + * Returns the path separator used to separate filenames in a path list. On UNIX the path + * separator is {@code ':'}. On Windows it's {@code ';'}. + * + * @return the path separator + * @since 20.0.0 beta 1 + */ + default String getPathSeparator() { + return File.pathSeparator; + } + /** * Returns a MIME type for given path. An optional operation for {@link FileSystem filesystem} * implementations which can provide MIME types in an efficient way. diff --git a/truffle/CHANGELOG.md b/truffle/CHANGELOG.md index 2f612278e381..25f6f4b2283f 100644 --- a/truffle/CHANGELOG.md +++ b/truffle/CHANGELOG.md @@ -10,6 +10,7 @@ This changelog summarizes major changes between Truffle versions relevant to lan ## Version 19.0.0 * Renamed version 1.0.0 to 19.0.0 +* Added a getter for [path separator](https://www.graalvm.org/truffle/javadoc/com/oracle/truffle/api/TruffleLanguage.Env.html#getPathSeparator--) used to separate filenames in a path list. ## Version 1.0.0 RC15 * This version includes a major revision of the Truffle Interoperability APIs. Most existing APIs for Truffle Interoperability were deprecated. The compatiblity layer may cause significant performance reduction for interoperability calls. diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/VirtualizedFileSystemTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/VirtualizedFileSystemTest.java index c5a8a6471f28..aba8baf60ccc 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/VirtualizedFileSystemTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/VirtualizedFileSystemTest.java @@ -1320,6 +1320,15 @@ public void testGetFileNameSeparator() { ctx.eval(LANGUAGE_ID, ""); } + @Test + public void testGetPathSeparator() { + final Context ctx = cfg.getContext(); + languageAction = (Env env) -> { + Assert.assertEquals(cfg.fileSystem.getSeparator(), env.getFileNameSeparator()); + }; + ctx.eval(LANGUAGE_ID, ""); + } + @Test public void testGetAttribute() { Context ctx = cfg.getContext(); diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleLanguage.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleLanguage.java index 5cf58de74f32..6e3db79a39f3 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleLanguage.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleLanguage.java @@ -2084,6 +2084,23 @@ public String getFileNameSeparator() { } } + /** + * Returns the path separator used to separate filenames in a path list. On UNIX the path + * separator is {@code ':'}. On Windows it's {@code ';'}. + * + * @return the path separator + * @since 20.0.0 beta 1 + */ + @TruffleBoundary + public String getPathSeparator() { + checkDisposed(); + try { + return fileSystemContext.fileSystem.getPathSeparator(); + } catch (Throwable t) { + throw TruffleFile.wrapHostException(t, fileSystemContext.fileSystem); + } + } + /** * Registers additional services provided by the language. The registered services are made * available to users via From ec4a43e26e39fbade8e24b2a8d3b14fb1e3ea60d Mon Sep 17 00:00:00 2001 From: Tomas Zezula Date: Tue, 21 May 2019 17:54:07 +0200 Subject: [PATCH 2/2] [GR-14598] Javadoc fixes. --- sdk/CHANGELOG.md | 6 ++---- .../src/org/graalvm/polyglot/tck/LanguageProvider.java | 2 +- .../src/org/graalvm/polyglot/tck/ResultVerifier.java | 2 +- truffle/CHANGELOG.md | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/sdk/CHANGELOG.md b/sdk/CHANGELOG.md index bed2b70ace45..8fa65f64e526 100644 --- a/sdk/CHANGELOG.md +++ b/sdk/CHANGELOG.md @@ -4,11 +4,9 @@ This changelog summarizes major changes between GraalVM SDK versions. The main f ## Version 20.0.0 Beta 1 * Removed deprecated `OptionCategory.DEBUG` (use `OptionCategory.INTERNAL` instead). +* The path separator can now be configured by [FileSystem](http://www.graalvm.org/sdk/javadoc/org/graalvm/polyglot/io/FileSystem.html#getPathSeparator--). -## Version 19.0.0 -* The path separator is provided by [FileSystem](http://www.graalvm.org/sdk/javadoc/org/graalvm/polyglot/io/FileSystem.html#getPathSeparator--). - -## Version 1.0.0 RC17 +## Version 19.0.0 * `Value.as(Interface.class)` now requires interface classes to be annotated with `HostAccess.Implementable` in `EXPLICIT` host access mode. Added new APIs to configure implementable behavior in HostAccess. ## Version 1.0.0 RC16 diff --git a/sdk/src/org.graalvm.polyglot.tck/src/org/graalvm/polyglot/tck/LanguageProvider.java b/sdk/src/org.graalvm.polyglot.tck/src/org/graalvm/polyglot/tck/LanguageProvider.java index 3faaafa69073..b11586e14228 100644 --- a/sdk/src/org.graalvm.polyglot.tck/src/org/graalvm/polyglot/tck/LanguageProvider.java +++ b/sdk/src/org.graalvm.polyglot.tck/src/org/graalvm/polyglot/tck/LanguageProvider.java @@ -96,7 +96,7 @@ public interface LanguageProvider { * * @param context the context for a guest language code literal evaluation * @return the {@link Snippet} representing the identity function - * @since 1.0 + * @since 20.0.0 beta 1 */ default Snippet createIdentityFunctionSnippet(Context context) { Value value = createIdentityFunction(context); diff --git a/sdk/src/org.graalvm.polyglot.tck/src/org/graalvm/polyglot/tck/ResultVerifier.java b/sdk/src/org.graalvm.polyglot.tck/src/org/graalvm/polyglot/tck/ResultVerifier.java index a16afd3f49c8..e277572a09c1 100644 --- a/sdk/src/org.graalvm.polyglot.tck/src/org/graalvm/polyglot/tck/ResultVerifier.java +++ b/sdk/src/org.graalvm.polyglot.tck/src/org/graalvm/polyglot/tck/ResultVerifier.java @@ -179,7 +179,7 @@ static ResultVerifier getDefaultResultVerifier() { * {@link ResultVerifier} tests that the identity function does not change the parameter type. * * @return the default {@link ResultVerifier} for {@code IdentityFunctionTest}. - * @since 1.0 + * @since 20.0.0 beta 1 */ static ResultVerifier getIdentityFunctionDefaultResultVerifier() { return IdentityFunctionResultVerifier.INSTANCE; diff --git a/truffle/CHANGELOG.md b/truffle/CHANGELOG.md index 25f6f4b2283f..7b90913884d8 100644 --- a/truffle/CHANGELOG.md +++ b/truffle/CHANGELOG.md @@ -7,10 +7,10 @@ This changelog summarizes major changes between Truffle versions relevant to lan * Removed deprecated and misspelled method `TruffleStackTrace#getStacktrace`. * Removed deprecated methods`TruffleStackTraceElement#getStackTrace` and `TruffleStackTraceElement#fillIn` (use methods of `TruffleStackTrace` instead). * `SlowPathException#fillInStackTrace` is now `final`. +* Added an ability to read a [path separator](https://www.graalvm.org/truffle/javadoc/com/oracle/truffle/api/TruffleLanguage.Env.html#getPathSeparator--) used to separate filenames in a path list. ## Version 19.0.0 * Renamed version 1.0.0 to 19.0.0 -* Added a getter for [path separator](https://www.graalvm.org/truffle/javadoc/com/oracle/truffle/api/TruffleLanguage.Env.html#getPathSeparator--) used to separate filenames in a path list. ## Version 1.0.0 RC15 * This version includes a major revision of the Truffle Interoperability APIs. Most existing APIs for Truffle Interoperability were deprecated. The compatiblity layer may cause significant performance reduction for interoperability calls.