Skip to content

Commit 0c22a18

Browse files
OracleLabsAutomationelkorchi
authored andcommitted
[GR-64254] Backport to 24.2: Allow non-file URLs in uriToURL on SVM.
PullRequest: js/3485
2 parents bbe85c1 + 899a38c commit 0c22a18

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

graal-js/mx.graal-js/truffle.tck.permissions/js_excludes.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
}
88
]
99
},
10+
{
11+
"name" : "com.oracle.truffle.js.runtime.objects.DefaultESModuleLoader",
12+
"methods" : [
13+
{ "name" : "uriToURL",
14+
"justification" : "URI to URL conversion without URLStreamHandler. Only privileged call with URLStreamHandler."
15+
}
16+
]
17+
},
1018
{
1119
"name" : "com.oracle.truffle.js.runtime.util.DebugJSAgent",
1220
"methods" : [

graal-js/src/com.oracle.truffle.js.test/src/com/oracle/truffle/js/test/regress/GR32763.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -60,8 +60,8 @@ public void testUnknownImportUrl() throws IOException {
6060
}
6161

6262
@Test
63-
public void testSchemeNotSupported() throws IOException {
64-
assertErrorMessage("foo://bar.mjs", "Error: Unsupported URI scheme foo");
63+
public void testUnknownProtocol() throws IOException {
64+
assertErrorMessage("foo://bar.mjs", "Error: unknown protocol: foo");
6565
}
6666

6767
private static void assertErrorMessage(String importUrl, String expected) throws IOException {

graal-js/src/com.oracle.truffle.js/src/com/oracle/truffle/js/runtime/objects/DefaultESModuleLoader.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -65,7 +65,6 @@
6565
import com.oracle.truffle.api.strings.TruffleString;
6666
import com.oracle.truffle.js.lang.JavaScriptLanguage;
6767
import com.oracle.truffle.js.runtime.Errors;
68-
import com.oracle.truffle.js.runtime.JSConfig;
6968
import com.oracle.truffle.js.runtime.JSContext;
7069
import com.oracle.truffle.js.runtime.JSException;
7170
import com.oracle.truffle.js.runtime.JSRealm;
@@ -261,13 +260,7 @@ protected AbstractModuleRecord loadModuleFromURL(ScriptOrModule referrer, Module
261260
}
262261

263262
private static URL uriToURL(URI moduleURI) throws MalformedURLException {
264-
if (!JSConfig.SubstrateVM) {
265-
try {
266-
return moduleURI.toURL();
267-
} catch (MalformedURLException e) {
268-
}
269-
}
270-
throw new MalformedURLException("Unsupported URI scheme " + moduleURI.getScheme());
263+
return moduleURI.toURL();
271264
}
272265

273266
protected AbstractModuleRecord loadModuleFromFile(ScriptOrModule referrer, ModuleRequest moduleRequest, TruffleFile moduleFile, String maybeCanonicalPath) throws IOException {

0 commit comments

Comments
 (0)