Skip to content

Commit d4e5ec2

Browse files
committed
8346610: Make all imports consistent in the FFM API
Reviewed-by: mcimadamore
1 parent c36200b commit d4e5ec2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+235
-225
lines changed

src/java.base/share/classes/java/lang/foreign/FunctionDescriptor.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 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
@@ -25,13 +25,13 @@
2525

2626
package java.lang.foreign;
2727

28+
import jdk.internal.foreign.FunctionDescriptorImpl;
29+
2830
import java.lang.invoke.MethodHandle;
2931
import java.lang.invoke.MethodType;
32+
import java.util.List;
3033
import java.util.Objects;
3134
import java.util.Optional;
32-
import java.util.List;
33-
34-
import jdk.internal.foreign.FunctionDescriptorImpl;
3535

3636
/**
3737
* A function descriptor models the signature of a foreign function. A function

src/java.base/share/classes/java/lang/foreign/Linker.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 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
@@ -26,8 +26,8 @@
2626
package java.lang.foreign;
2727

2828
import jdk.internal.foreign.abi.AbstractLinker;
29-
import jdk.internal.foreign.abi.LinkerOptions;
3029
import jdk.internal.foreign.abi.CapturableState;
30+
import jdk.internal.foreign.abi.LinkerOptions;
3131
import jdk.internal.foreign.abi.SharedUtils;
3232
import jdk.internal.javac.Restricted;
3333
import jdk.internal.reflect.CallerSensitive;

src/java.base/share/classes/java/lang/foreign/MemoryLayout.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 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
@@ -25,12 +25,6 @@
2525

2626
package java.lang.foreign;
2727

28-
import java.lang.invoke.MethodHandle;
29-
import java.lang.invoke.VarHandle;
30-
import java.util.Objects;
31-
import java.util.Optional;
32-
import java.util.stream.Stream;
33-
3428
import jdk.internal.foreign.LayoutPath;
3529
import jdk.internal.foreign.Utils;
3630
import jdk.internal.foreign.layout.MemoryLayoutUtil;
@@ -39,6 +33,12 @@
3933
import jdk.internal.foreign.layout.StructLayoutImpl;
4034
import jdk.internal.foreign.layout.UnionLayoutImpl;
4135

36+
import java.lang.invoke.MethodHandle;
37+
import java.lang.invoke.VarHandle;
38+
import java.util.Objects;
39+
import java.util.Optional;
40+
import java.util.stream.Stream;
41+
4242
/**
4343
* A memory layout describes the contents of a memory segment.
4444
* <p>

src/java.base/share/classes/java/lang/foreign/MemorySegment.java

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 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
@@ -25,6 +25,14 @@
2525

2626
package java.lang.foreign;
2727

28+
import jdk.internal.foreign.AbstractMemorySegmentImpl;
29+
import jdk.internal.foreign.MemorySessionImpl;
30+
import jdk.internal.foreign.SegmentBulkOperations;
31+
import jdk.internal.foreign.SegmentFactories;
32+
import jdk.internal.javac.Restricted;
33+
import jdk.internal.reflect.CallerSensitive;
34+
import jdk.internal.vm.annotation.ForceInline;
35+
2836
import java.io.UncheckedIOException;
2937
import java.lang.foreign.ValueLayout.OfInt;
3038
import java.nio.Buffer;
@@ -41,13 +49,6 @@
4149
import java.util.Spliterator;
4250
import java.util.function.Consumer;
4351
import java.util.stream.Stream;
44-
import jdk.internal.foreign.AbstractMemorySegmentImpl;
45-
import jdk.internal.foreign.MemorySessionImpl;
46-
import jdk.internal.foreign.SegmentBulkOperations;
47-
import jdk.internal.foreign.SegmentFactories;
48-
import jdk.internal.javac.Restricted;
49-
import jdk.internal.reflect.CallerSensitive;
50-
import jdk.internal.vm.annotation.ForceInline;
5152

5253
/**
5354
* A memory segment provides access to a contiguous region of memory.

src/java.base/share/classes/java/lang/foreign/SegmentAllocator.java

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 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
@@ -25,17 +25,16 @@
2525

2626
package java.lang.foreign;
2727

28-
import java.nio.charset.Charset;
29-
import java.nio.charset.StandardCharsets;
30-
import java.util.Objects;
31-
3228
import jdk.internal.foreign.AbstractMemorySegmentImpl;
3329
import jdk.internal.foreign.ArenaImpl;
3430
import jdk.internal.foreign.SlicingAllocator;
3531
import jdk.internal.foreign.StringSupport;
36-
import jdk.internal.foreign.Utils;
3732
import jdk.internal.vm.annotation.ForceInline;
3833

34+
import java.nio.charset.Charset;
35+
import java.nio.charset.StandardCharsets;
36+
import java.util.Objects;
37+
3938
/**
4039
* An object that may be used to allocate {@linkplain MemorySegment memory segments}.
4140
* Clients implementing this interface must implement the {@link #allocate(long, long)}

src/java.base/share/classes/java/lang/foreign/ValueLayout.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 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
@@ -25,9 +25,10 @@
2525

2626
package java.lang.foreign;
2727

28+
import jdk.internal.foreign.layout.ValueLayouts;
29+
2830
import java.lang.invoke.VarHandle;
2931
import java.nio.ByteOrder;
30-
import jdk.internal.foreign.layout.ValueLayouts;
3132

3233
/**
3334
* A layout that models values of basic data types. Examples of values modeled by

src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java

+21-13
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,39 @@
2525

2626
package jdk.internal.foreign;
2727

28-
import java.lang.foreign.*;
28+
import jdk.internal.access.JavaNioAccess;
29+
import jdk.internal.access.SharedSecrets;
30+
import jdk.internal.access.foreign.UnmapperProxy;
31+
import jdk.internal.misc.ScopedMemoryAccess;
32+
import jdk.internal.reflect.CallerSensitive;
33+
import jdk.internal.reflect.Reflection;
34+
import jdk.internal.util.ArraysSupport;
35+
import jdk.internal.util.Preconditions;
36+
import jdk.internal.vm.annotation.ForceInline;
37+
import sun.nio.ch.DirectBuffer;
38+
39+
import java.lang.foreign.AddressLayout;
40+
import java.lang.foreign.Arena;
41+
import java.lang.foreign.MemoryLayout;
42+
import java.lang.foreign.MemorySegment;
43+
import java.lang.foreign.SegmentAllocator;
44+
import java.lang.foreign.ValueLayout;
2945
import java.lang.reflect.Array;
3046
import java.nio.Buffer;
3147
import java.nio.ByteBuffer;
3248
import java.nio.ByteOrder;
3349
import java.nio.charset.Charset;
34-
import java.util.*;
50+
import java.util.List;
51+
import java.util.Objects;
52+
import java.util.Optional;
53+
import java.util.Spliterator;
3554
import java.util.function.BiFunction;
3655
import java.util.function.Consumer;
3756
import java.util.function.Function;
3857
import java.util.function.IntFunction;
3958
import java.util.stream.Stream;
4059
import java.util.stream.StreamSupport;
4160

42-
import jdk.internal.access.JavaNioAccess;
43-
import jdk.internal.access.SharedSecrets;
44-
import jdk.internal.access.foreign.UnmapperProxy;
45-
import jdk.internal.misc.ScopedMemoryAccess;
46-
import jdk.internal.reflect.CallerSensitive;
47-
import jdk.internal.reflect.Reflection;
48-
import jdk.internal.util.ArraysSupport;
49-
import jdk.internal.util.Preconditions;
50-
import jdk.internal.vm.annotation.ForceInline;
51-
import sun.nio.ch.DirectBuffer;
52-
5361
/**
5462
* This abstract class provides an immutable implementation for the {@code MemorySegment} interface. This class contains information
5563
* about the segment's spatial and temporal bounds; each memory segment implementation is associated with an owner thread which is set at creation time.

src/java.base/share/classes/jdk/internal/foreign/ArenaImpl.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2023, 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
@@ -26,10 +26,7 @@
2626
package jdk.internal.foreign;
2727

2828
import java.lang.foreign.Arena;
29-
import java.lang.foreign.MemoryLayout;
30-
import java.lang.foreign.MemorySegment;
3129
import java.lang.foreign.MemorySegment.Scope;
32-
import java.util.Objects;
3330

3431
public final class ArenaImpl implements Arena {
3532

src/java.base/share/classes/jdk/internal/foreign/CABI.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 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
@@ -27,9 +27,9 @@
2727
package jdk.internal.foreign;
2828

2929
import jdk.internal.foreign.abi.fallback.FallbackLinker;
30-
import jdk.internal.vm.ForeignLinkerSupport;
3130
import jdk.internal.util.OperatingSystem;
3231
import jdk.internal.util.StaticProperty;
32+
import jdk.internal.vm.ForeignLinkerSupport;
3333

3434
import static java.lang.foreign.ValueLayout.ADDRESS;
3535

src/java.base/share/classes/jdk/internal/foreign/ConfinedSession.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 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
@@ -25,12 +25,12 @@
2525

2626
package jdk.internal.foreign;
2727

28-
import java.lang.invoke.MethodHandles;
29-
import java.lang.invoke.VarHandle;
30-
3128
import jdk.internal.invoke.MhUtil;
3229
import jdk.internal.vm.annotation.ForceInline;
3330

31+
import java.lang.invoke.MethodHandles;
32+
import java.lang.invoke.VarHandle;
33+
3434
/**
3535
* A confined session, which features an owner thread. The liveness check features an additional
3636
* confinement check - that is, calling any operation on this session from a thread other than the

src/java.base/share/classes/jdk/internal/foreign/GlobalSession.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 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
@@ -25,12 +25,8 @@
2525

2626
package jdk.internal.foreign;
2727

28-
import jdk.internal.access.JavaNioAccess;
29-
import jdk.internal.access.SharedSecrets;
3028
import jdk.internal.vm.annotation.ForceInline;
31-
import sun.nio.ch.DirectBuffer;
3229

33-
import java.nio.Buffer;
3430
import java.util.Objects;
3531

3632
/**

src/java.base/share/classes/jdk/internal/foreign/HeapMemorySegmentImpl.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 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
@@ -26,15 +26,15 @@
2626

2727
package jdk.internal.foreign;
2828

29+
import jdk.internal.access.JavaNioAccess;
30+
import jdk.internal.access.SharedSecrets;
31+
import jdk.internal.vm.annotation.ForceInline;
32+
2933
import java.lang.foreign.ValueLayout;
3034
import java.nio.ByteBuffer;
3135
import java.util.Objects;
3236
import java.util.Optional;
3337

34-
import jdk.internal.access.JavaNioAccess;
35-
import jdk.internal.access.SharedSecrets;
36-
import jdk.internal.vm.annotation.ForceInline;
37-
3838
/**
3939
* Implementation for heap memory segments. A heap memory segment is composed by an offset and
4040
* a base object (typically an array). To enhance performances, the access to the base object needs to feature

src/java.base/share/classes/jdk/internal/foreign/LayoutPath.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 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
@@ -39,7 +39,6 @@
3939
import java.lang.invoke.MethodType;
4040
import java.lang.invoke.VarHandle;
4141
import java.util.Arrays;
42-
import java.util.List;
4342
import java.util.Objects;
4443
import java.util.function.UnaryOperator;
4544
import java.util.stream.IntStream;

src/java.base/share/classes/jdk/internal/foreign/MappedMemorySegmentImpl.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 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
@@ -25,10 +25,11 @@
2525

2626
package jdk.internal.foreign;
2727

28-
import java.nio.ByteBuffer;
2928
import jdk.internal.access.foreign.UnmapperProxy;
3029
import jdk.internal.misc.ScopedMemoryAccess;
3130

31+
import java.nio.ByteBuffer;
32+
3233
/**
3334
* Implementation for a mapped memory segments. A mapped memory segment is a native memory segment, which
3435
* additionally features an {@link UnmapperProxy} object. This object provides detailed information about the

src/java.base/share/classes/jdk/internal/foreign/MemorySessionImpl.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 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
@@ -26,20 +26,20 @@
2626

2727
package jdk.internal.foreign;
2828

29-
import java.lang.foreign.MemorySegment;
29+
import jdk.internal.foreign.GlobalSession.HeapSession;
30+
import jdk.internal.invoke.MhUtil;
31+
import jdk.internal.misc.ScopedMemoryAccess;
32+
import jdk.internal.vm.annotation.ForceInline;
33+
import jdk.internal.vm.annotation.Stable;
34+
3035
import java.lang.foreign.Arena;
36+
import java.lang.foreign.MemorySegment;
3137
import java.lang.foreign.MemorySegment.Scope;
3238
import java.lang.invoke.MethodHandles;
3339
import java.lang.invoke.VarHandle;
3440
import java.lang.ref.Cleaner;
3541
import java.util.Objects;
3642

37-
import jdk.internal.foreign.GlobalSession.HeapSession;
38-
import jdk.internal.misc.ScopedMemoryAccess;
39-
import jdk.internal.invoke.MhUtil;
40-
import jdk.internal.vm.annotation.ForceInline;
41-
import jdk.internal.vm.annotation.Stable;
42-
4343
/**
4444
* This class manages the temporal bounds associated with a memory segment as well
4545
* as thread confinement. A session has a liveness bit, which is updated when the session is closed

0 commit comments

Comments
 (0)