Skip to content

Commit 970a111

Browse files
author
Elia Trachsel
committed
[GR-64319] Substitutions for basic file operations
PullRequest: graal/20932
2 parents 73a8a26 + fbaac52 commit 970a111

File tree

54 files changed

+1996
-483
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1996
-483
lines changed

ci/common.jsonnet

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,14 @@ local common_json = import "../common.json";
262262
] else []),
263263
},
264264

265+
espresso:: {
266+
downloads+: {
267+
EXTRA_JAVA_HOMES+: {
268+
pathlist+: [jdks_data["oraclejdk21"], jdks_data["oraclejdk25"]],
269+
}
270+
}
271+
},
272+
265273
sulong:: self.cmake + {
266274
packages+: if self.os == "windows" then {
267275
msvc_source: "==14.0",

common.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Jsonnet files should not include this file directly but use ci/common.jsonnet instead."
55
],
66

7-
"mx_version": "7.58.9",
7+
"mx_version": "7.59.0",
88

99
"COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet",
1010
"jdks": {

espresso-shared/src/com.oracle.truffle.espresso.classfile/src/com/oracle/truffle/espresso/classfile/JavaVersion.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ public static JavaVersion forVersion(String version) {
112112
}
113113
}
114114

115+
public Runtime.Version toRunTimeVersion() {
116+
return Runtime.Version.parse(toString());
117+
}
118+
115119
private static JavaVersion forVersion(Runtime.Version version) {
116120
return forVersion(version.feature());
117121
}
@@ -184,6 +188,10 @@ public boolean java20OrEarlier() {
184188
return version <= 20;
185189
}
186190

191+
public boolean java21Or25() {
192+
return version == 21 || version == 25;
193+
}
194+
187195
public boolean java21OrLater() {
188196
return version >= 21;
189197
}

espresso/ci/ci_common/common.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ local benchmark_suites = ['dacapo', 'renaissance', 'scala-dacapo'];
1515
local that = self,
1616

1717
// platform-specific snippets
18-
common: graal_common.deps.sulong + {
18+
common: graal_common.deps.sulong + graal_common.deps.espresso + {
1919
python_version: '3',
2020
environment+: {
2121
GRAALVM_CHECK_EXPERIMENTAL_OPTIONS: "true",

espresso/mx.espresso/suite.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,42 @@
101101
"sourceDirs": ["src"],
102102
# Contains classes in sun.nio.* that only compile with javac.
103103
"forceJavac": "true",
104-
"javaCompliance": "8+",
104+
"javaCompliance": "21+",
105+
"patchModule": "java.base",
106+
"checkPackagePrefix": False, # Contains classes in java.io and sun.nio.
107+
"checkstyle": "com.oracle.truffle.espresso",
108+
},
109+
110+
"com.oracle.truffle.espresso.io.jdk21": {
111+
"subDir": "src",
112+
"sourceDirs": ["src"],
113+
"dependencies": [
114+
"com.oracle.truffle.espresso.io",
115+
],
116+
"overlayTarget": "com.oracle.truffle.espresso.io",
117+
# Contains classes in sun.nio.* that only compile with javac.
118+
"forceJavac": "true",
119+
"multiReleaseJarVersion": "21",
120+
"patchModule": "java.base",
121+
"javaCompliance": "21",
122+
"checkPackagePrefix": False, # Contains classes in java.io and sun.nio.
123+
"checkstyle": "com.oracle.truffle.espresso",
124+
},
125+
126+
"com.oracle.truffle.espresso.io.jdk25": {
127+
"subDir": "src",
128+
"sourceDirs": ["src"],
129+
"dependencies": [
130+
"com.oracle.truffle.espresso.io",
131+
],
132+
# GR-47124 spotbugs does not support jdk25
133+
"spotbugs": "false",
134+
"overlayTarget": "com.oracle.truffle.espresso.io",
135+
# Contains classes in sun.nio.* that only compile with javac.
136+
"forceJavac": "true",
137+
"multiReleaseJarVersion": "25",
138+
"patchModule": "java.base",
139+
"javaCompliance": "25",
105140
"checkPackagePrefix": False, # Contains classes in java.io and sun.nio.
106141
"checkstyle": "com.oracle.truffle.espresso",
107142
},
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
package sun.nio.fs;
24+
25+
import java.io.Closeable;
26+
import java.io.FileDescriptor;
27+
import java.nio.channels.FileChannel;
28+
29+
import sun.nio.ch.FileChannelImpl;
30+
31+
public class NewFileChannelHelper {
32+
public static FileChannel open(FileDescriptor fd, String path,
33+
boolean readable, boolean writable,
34+
boolean sync, boolean direct, Closeable parent) {
35+
return FileChannelImpl.open(fd, path, readable, writable, direct, parent);
36+
}
37+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
package sun.nio.fs;
24+
25+
import java.io.Closeable;
26+
import java.io.FileDescriptor;
27+
import java.nio.channels.FileChannel;
28+
29+
import sun.nio.ch.FileChannelImpl;
30+
31+
public class NewFileChannelHelper {
32+
public static FileChannel open(FileDescriptor fd, String path,
33+
boolean readable, boolean writable,
34+
boolean sync, boolean direct, Closeable parent) {
35+
return FileChannelImpl.open(fd, path, readable, writable, sync, direct, parent);
36+
}
37+
}

espresso/src/com.oracle.truffle.espresso.io/src/java/io/TruffleFileSystem.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
* <p>
2828
* Its native methods are provided by Espresso's custom {@code libjava} implementation.
2929
* <p>
30-
* This file must be compatible with all Java versions supported by Espresso, strict Java 8
31-
* compatibility is required.
32-
*
30+
* This file must be compatible with 21+.
3331
*/
3432
final class TruffleFileSystem extends FileSystem {
3533

@@ -73,7 +71,13 @@ public String getDefaultParent() {
7371

7472
@Override
7573
public String fromURIPath(String path) {
76-
return fromURIPath0(path);
74+
// copy pasted from UnixFileSystem
75+
String p = path;
76+
if (p.endsWith("/") && (p.length() > 1)) {
77+
// "/foo/" --> "/foo", but "/" --> "/"
78+
p = p.substring(0, p.length() - 1);
79+
}
80+
return p;
7781
}
7882

7983
@Override

espresso/src/com.oracle.truffle.espresso.io/src/sun/nio/ch/FileDispatcherImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
* descriptors used this class are purely virtual and should not be passed down to native code.
3535
*
3636
* <p>
37-
* This file must be compatible with all Java versions supported by Espresso, strict Java 8
38-
* compatibility is required.
37+
* This file must be compatible with 21+
3938
*/
4039
final class FileDispatcherImpl extends sun.nio.ch.FileDispatcher {
4140

espresso/src/com.oracle.truffle.espresso.io/src/sun/nio/fs/DefaultFileSystemProvider.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
* Replaces JDK's own {@link DefaultFileSystemProvider} to link to a Truffle-based
2929
* {@code FileSystem}.
3030
* <p>
31-
* This file must be compatible with all Java versions supported by Espresso, strict Java 8
32-
* compatibility is required.
31+
* This file must be compatible with 21+.
3332
*/
3433
public final class DefaultFileSystemProvider {
3534
private static final TruffleFileSystemProvider INSTANCE = new TruffleFileSystemProvider();

0 commit comments

Comments
 (0)