[foreign-memaccess+abi] RFR: Add an internal MemoryInspection class [v2]

Athijegannathan Sundararajan sundar at openjdk.org
Mon Sep 19 11:21:02 UTC 2022


On Mon, 19 Sep 2022 09:02:27 GMT, Per Minborg <duke at openjdk.org> wrote:

>> This PR adds a way of inspecting a `MemoryLayout` through a `MemoryLayout`.
>> 
>> 
>>     /**
>>      * Returns a human-readable view of the provided {@linkplain MemorySegment memory} viewed
>>      * through the provided {@linkplain MemoryLayout layout} using the provided {@linkplain ValueLayoutRenderer renderer}.
>>      * <p>
>>      * The exact format of the returned view is unspecified and should not
>>      * be acted upon programmatically.
>>      * <p>
>>      * As an example, a MemorySegment viewed though the following memory layout
>>      * {@snippet lang = java:
>>      * var layout = MemoryLayout.structLayout(
>>      *         ValueLayout.JAVA_INT.withName("x"),
>>      *         ValueLayout.JAVA_INT.withName("y")
>>      * ).withName("Point");
>>      *
>>      * MemoryInspection.inspect(segment, layout, ValueLayoutRenderer.standard())
>>      *     .forEach(System.out::println);
>>      *
>>      *}
>>      * might be rendered to something like this:
>>      * {@snippet lang = text:
>>      * Point {
>>      *   x=1,
>>      *   y=2
>>      * }
>>      *}
>>      * <p>
>>      * This method is intended to view memory segments through small and medium-sized memory layouts.
>>      *
>>      * @param segment  to be viewed
>>      * @param layout   to use as a layout when viewing the memory segment
>>      * @param renderer to apply when rendering value layouts
>>      * @return a view of the memory abstraction viewed through the memory layout
>>      */
>>     public static Stream<String> inspect(MemorySegment segment,
>>                                          MemoryLayout layout,
>>                                          ValueLayoutRenderer renderer) {
>
> Per Minborg has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Update after review

src/java.base/share/classes/jdk/internal/foreign/MemoryInspection.java line 2:

> 1: /*
> 2:  *  Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved.

Could be just 2022 once?

src/java.base/share/classes/jdk/internal/foreign/MemoryInspection.java line 22:

> 20:  *  or visit www.oracle.com if you need additional information or have any
> 21:  *  questions.
> 22:  *

This copyright misses "Classpath exception" clause. This appears to be test copyright text (which should not have Classpath exception clause)

src/java.base/share/classes/jdk/internal/foreign/MemoryInspection.java line 42:

> 40:  * such as {@link MemorySegment#ofArray(byte[])} and {@link MemorySegment#ofBuffer(Buffer)}.
> 41:  *
> 42:  * @author Per Minborg

Do we use @author still?

src/java.base/share/classes/jdk/internal/foreign/MemoryInspectionUtil.java line 2:

> 1: /*
> 2:  *  Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved.

Same. 2022, 2022.

-------------

PR: https://git.openjdk.org/panama-foreign/pull/715


More information about the panama-dev mailing list