Skip to content

Commit b7e0708

Browse files
[GR-69551] Create fallback for FileChannel in espresso
1 parent 4fd24a6 commit b7e0708

File tree

1 file changed

+11
-2
lines changed
  • espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/jimage

1 file changed

+11
-2
lines changed

espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/jimage/BasicImageReader.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -59,7 +59,16 @@ protected BasicImageReader(Path path, ByteOrder byteOrder) throws IOException {
5959

6060
channel = FileChannel.open(imagePath, StandardOpenOption.READ);
6161

62-
ByteBuffer map = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
62+
ByteBuffer map;
63+
try {
64+
map = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
65+
} catch (UnsupportedOperationException e) {
66+
long lastRead;
67+
map = ByteBuffer.allocateDirect(Math.toIntExact(channel.size()));
68+
do {
69+
lastRead = channel.read(map);
70+
} while (lastRead >= 0 && map.hasRemaining());
71+
}
6372

6473
int headerSize = ImageHeader.getHeaderSize();
6574
if (map.capacity() < headerSize) {

0 commit comments

Comments
 (0)