Skip to content

Commit

Permalink
fixed samples for API change MemorySegment.slice -> asSlice and to re…
Browse files Browse the repository at this point in the history
…-extract libjimage binding

Reviewed-by: jvernee
  • Loading branch information
sundararajana committed Feb 17, 2023
1 parent 1d2f931 commit 8f41279
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion samples/libffmpeg/LibffmpegMain.java
Expand Up @@ -290,7 +290,7 @@ private static void saveFrame(MemorySegment frameRGB, Arena arena,
// Write pixel data
for (int y = 0; y < height; y++) {
// frameRGB.data[0] + y*frameRGB.linesize[0] is the pointer. And 3*width size of data
var pixelArray = pdata.slice(y * linesize)
var pixelArray = pdata.asSlice(y * linesize)
.reinterpret(3*width, arena.scope(), null);
// dump the pixel byte buffer to file
os.write(pixelArray.toArray(C_CHAR));
Expand Down
3 changes: 1 addition & 2 deletions samples/libjimage/org/openjdk/RuntimeHelper.java
Expand Up @@ -46,7 +46,6 @@ final class RuntimeHelper {
libPath = "/lib/libjimage.so"; // some Unix
}
SymbolLookup loaderLookup = SymbolLookup.libraryLookup(libPath, Arena.global());

SYMBOL_LOOKUP = name -> loaderLookup.find(name).or(() -> LINKER.defaultLookup().find(name));
}

Expand All @@ -62,7 +61,7 @@ static <T> T requireNonNull(T obj, String symbolName) {

static MemorySegment lookupGlobalVariable(String name, MemoryLayout layout) {
return SYMBOL_LOOKUP.find(name)
.map(s -> s.asUnbounded().asSlice(0, layout))
.map(s -> s.reinterpret(layout.byteSize()))
.orElse(null);
}

Expand Down

0 comments on commit 8f41279

Please sign in to comment.