RFR: 8318324: Drop redundant default methods from FFM API
Maurizio Cimadamore
mcimadamore at openjdk.org
Wed Oct 18 12:14:04 UTC 2023
On Wed, 18 Oct 2023 04:06:17 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
>> This PR moves turns default methods in `MemorySegment` and `MemoryLayout` into ordinary abstract methods.
>> These interfaces cannot be subclasses by developers (they are sealed), so there is no reson for having default methods there. Also, default methods can have some detrimental effects, as they cause the interfaces to be initialized more eagerly.
>
> src/java.base/share/classes/jdk/internal/foreign/layout/AbstractLayout.java line 47:
>
>> 45: import java.util.Optional;
>> 46: import java.util.Set;
>> 47: import java.util.function.Function;
>
> There are quite a few new imports here. Is it possible some imports in `MemoryLayout` are now unused?
No unused import here - these are just the imports required for the overrides to compile successfully.
> src/java.base/share/classes/jdk/internal/foreign/layout/AbstractLayout.java line 153:
>
>> 151: }
>> 152:
>> 153: public long scale(long offset, long index) {
>
> Could you add `@Override` to these as well? I think it makes it clearer that these methods might be accessed through a super type.
Would be nice - but note that `AbstractLayoutImpl` does not extend `MemoryLayout`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16224#discussion_r1363753942
PR Review Comment: https://git.openjdk.org/jdk/pull/16224#discussion_r1363755711
More information about the core-libs-dev
mailing list