@@ -2023,14 +2023,15 @@ final MMapHandle mmap(long length, int prot, int flags, int fd, long offset,
2023
2023
// we create a new channel, the file may be closed but the mmap object should still work
2024
2024
SeekableByteChannel fileChannel ;
2025
2025
try {
2026
- fileChannel = file . newByteChannel (options );
2026
+ fileChannel = newByteChannel (file , options );
2027
2027
position (fileChannel , offset );
2028
2028
return new MMapHandle (fileChannel , offset );
2029
2029
} catch (IOException e ) {
2030
2030
throw posixException (OSErrorEnum .fromException (e ));
2031
2031
}
2032
2032
}
2033
2033
2034
+ @ TruffleBoundary
2034
2035
private static Set <StandardOpenOption > mmapProtToOptions (int prot ) {
2035
2036
HashSet <StandardOpenOption > options = new HashSet <>();
2036
2037
if ((prot & PROT_READ ) != 0 ) {
@@ -2045,6 +2046,11 @@ private static Set<StandardOpenOption> mmapProtToOptions(int prot) {
2045
2046
return options ;
2046
2047
}
2047
2048
2049
+ @ TruffleBoundary
2050
+ private static SeekableByteChannel newByteChannel (TruffleFile file , Set <StandardOpenOption > options ) throws IOException {
2051
+ return file .newByteChannel (options );
2052
+ }
2053
+
2048
2054
@ ExportMessage
2049
2055
@ SuppressWarnings ("static-method" )
2050
2056
public byte mmapReadByte (Object mmap , long index ,
@@ -2137,14 +2143,19 @@ public void mmapUnmap(Object mmap, @SuppressWarnings("unused") long length) thro
2137
2143
MMapHandle handle = (MMapHandle ) mmap ;
2138
2144
if (handle .channel != null ) {
2139
2145
try {
2140
- handle .channel . close ( );
2146
+ closeChannel ( handle .channel );
2141
2147
} catch (IOException e ) {
2142
2148
throw posixException (OSErrorEnum .fromException (e ));
2143
2149
}
2144
2150
handle .channel = null ;
2145
2151
}
2146
2152
}
2147
2153
2154
+ @ TruffleBoundary
2155
+ private static void closeChannel (Channel ch ) throws IOException {
2156
+ ch .close ();
2157
+ }
2158
+
2148
2159
@ TruffleBoundary
2149
2160
private static void position (SeekableByteChannel ch , long offset ) throws IOException {
2150
2161
ch .position (offset );
0 commit comments