+{"files":[{"patch":"@@ -889,1 +889,1 @@\n- return NativeMemorySegmentImpl.makeNativeSegmentUnchecked(address, bytesSize, session);\n+ return NativeMemorySegmentImpl.makeNativeSegmentUnchecked(address, bytesSize, null, session);\n","filename":"src\/java.base\/share\/classes\/java\/lang\/foreign\/MemorySegment.java","additions":1,"deletions":1,"binary":false,"changes":2,"status":"modified"},{"patch":"@@ -31,0 +31,1 @@\n+import jdk.internal.foreign.NativeMemorySegmentImpl;\n@@ -141,4 +142,6 @@\n- * <a href=\"..\/..\/..\/java\/lang\/ref\/package.html#reachability\">unreachable<\/a>. The symbol lookup\n- * returned by this method is backed by a {@linkplain MemorySession#asNonCloseable() non-closeable}, shared memory\n- * session which keeps the caller's class loader reachable. Therefore, libraries associated with the caller's class\n- * loader are kept loaded (and their symbols available) as long as a loader lookup for that class loader is reachable.\n+ * <a href=\"..\/..\/..\/java\/lang\/ref\/package.html#reachability\">unreachable<\/a>. The returned loader lookup\n+ * keeps the caller's class loader reachable. Therefore, libraries associated with the caller's class\n+ * loader are kept loaded (and their symbols available) as long as a loader lookup for that class loader\n+ * (or any of the symbols originated from it) is reachable.\n+ * <p>\n+ * The symbols obtained from the returned loader lookup are backed by the {@linkplain MemorySession#global() global session}.\n@@ -161,3 +164,1 @@\n- MemorySession loaderSession = (loader == null || loader instanceof BuiltinClassLoader) ?\n- MemorySession.global() : \/\/ builtin loaders never go away\n- MemorySessionImpl.heapSession(loader);\n+ MemorySession loaderSession = MemorySession.global();\n@@ -171,1 +172,1 @@\n- Optional.of(MemorySegment.ofAddress(addr, 0L, loaderSession));\n+ Optional.of(NativeMemorySegmentImpl.makeNativeSegmentUnchecked(addr, 0L, loader, loaderSession));\n","filename":"src\/java.base\/share\/classes\/java\/lang\/foreign\/SymbolLookup.java","additions":9,"deletions":8,"binary":false,"changes":17,"status":"modified"},{"patch":"@@ -530,1 +530,1 @@\n- bufferSession = MemorySessionImpl.heapSession(bb);\n+ bufferSession = MemorySessionImpl.GLOBAL;\n@@ -553,1 +553,1 @@\n- return new NativeMemorySegmentImpl(bbAddress + (pos << scaleFactor), size << scaleFactor, readOnly, bufferSession);\n+ return new NativeMemorySegmentImpl(bbAddress + (pos << scaleFactor), size << scaleFactor, readOnly, bb, bufferSession);\n@@ -556,1 +556,1 @@\n- return new MappedMemorySegmentImpl(bbAddress + pos, unmapper, size, readOnly, bufferSession);\n+ return new MappedMemorySegmentImpl(bbAddress + pos, unmapper, size, readOnly, bb, bufferSession);\n","filename":"src\/java.base\/share\/classes\/jdk\/internal\/foreign\/AbstractMemorySegmentImpl.java","additions":3,"deletions":3,"binary":false,"changes":6,"status":"modified"},{"patch":"@@ -45,2 +45,2 @@\n- public MappedMemorySegmentImpl(long min, UnmapperProxy unmapper, long length, boolean readOnly, MemorySessionImpl session) {\n- super(min, length, readOnly, session);\n+ public MappedMemorySegmentImpl(long min, UnmapperProxy unmapper, long length, boolean readOnly, Object ref, MemorySessionImpl session) {\n+ super(min, length, readOnly, ref, session);\n@@ -52,1 +52,1 @@\n- return nioAccess.newMappedByteBuffer(unmapper, min, (int)length, null,\n+ return nioAccess.newMappedByteBuffer(unmapper, min, (int)length, ref,\n@@ -58,1 +58,1 @@\n- return new MappedMemorySegmentImpl(min + offset, unmapper, size, readOnly, session);\n+ return new MappedMemorySegmentImpl(min + offset, unmapper, size, readOnly, ref, session);\n@@ -98,1 +98,1 @@\n- super(0, null, 0, readOnly, session);\n+ super(0, null, 0, readOnly, null, session);\n","filename":"src\/java.base\/share\/classes\/jdk\/internal\/foreign\/MappedMemorySegmentImpl.java","additions":5,"deletions":5,"binary":false,"changes":10,"status":"modified"},{"patch":"@@ -90,1 +90,1 @@\n- return NativeMemorySegmentImpl.makeNativeSegmentUnchecked(MemoryAddress.ofLong(value), byteSize, session);\n+ return NativeMemorySegmentImpl.makeNativeSegmentUnchecked(MemoryAddress.ofLong(value), byteSize, null, session);\n@@ -94,1 +94,1 @@\n- return NativeMemorySegmentImpl.makeNativeSegmentUnchecked(MemoryAddress.ofLong(value), byteSize, MemorySessionImpl.GLOBAL);\n+ return NativeMemorySegmentImpl.makeNativeSegmentUnchecked(MemoryAddress.ofLong(value), byteSize, null, MemorySessionImpl.GLOBAL);\n","filename":"src\/java.base\/share\/classes\/jdk\/internal\/foreign\/MemoryAddressImpl.java","additions":2,"deletions":2,"binary":false,"changes":4,"status":"modified"},{"patch":"@@ -259,8 +259,1 @@\n- static class GlobalSessionImpl extends MemorySessionImpl {\n-\n- final Object ref;\n-\n- public GlobalSessionImpl(Object ref) {\n- super(null, null ,null);\n- this.ref = ref;\n- }\n+ public static final MemorySessionImpl GLOBAL = new MemorySessionImpl(null, null, null) {\n@@ -294,7 +287,1 @@\n- }\n-\n- public static final MemorySessionImpl GLOBAL = new GlobalSessionImpl(null);\n-\n- public static MemorySessionImpl heapSession(Object ref) {\n- return new GlobalSessionImpl(ref);\n- }\n+ };\n","filename":"src\/java.base\/share\/classes\/jdk\/internal\/foreign\/MemorySessionImpl.java","additions":2,"deletions":15,"binary":false,"changes":17,"status":"modified"},{"patch":"@@ -44,1 +44,1 @@\n- public static final MemorySegment EVERYTHING = new NativeMemorySegmentImpl(0, Long.MAX_VALUE, false, MemorySessionImpl.GLOBAL) {\n+ public static final MemorySegment EVERYTHING = new NativeMemorySegmentImpl(0, Long.MAX_VALUE, false, null, MemorySessionImpl.GLOBAL) {\n@@ -65,0 +65,1 @@\n+ final Object ref;\n@@ -67,1 +68,1 @@\n- NativeMemorySegmentImpl(long min, long length, boolean readOnly, MemorySessionImpl session) {\n+ NativeMemorySegmentImpl(long min, long length, boolean readOnly, Object ref, MemorySessionImpl session) {\n@@ -70,0 +71,1 @@\n+ this.ref = ref;\n@@ -81,1 +83,1 @@\n- return new NativeMemorySegmentImpl(min + offset, size, readOnly, session);\n+ return new NativeMemorySegmentImpl(min + offset, size, readOnly, ref, session);\n@@ -86,1 +88,1 @@\n- return nioAccess.newDirectByteBuffer(min, (int) this.length, null,\n+ return nioAccess.newDirectByteBuffer(min, (int) this.length, ref,\n@@ -130,1 +132,1 @@\n- false, sessionImpl);\n+ false, null, sessionImpl);\n@@ -145,1 +147,1 @@\n- public static MemorySegment makeNativeSegmentUnchecked(MemoryAddress min, long bytesSize, MemorySession session) {\n+ public static MemorySegment makeNativeSegmentUnchecked(MemoryAddress min, long bytesSize, Object ref, MemorySession session) {\n@@ -148,1 +150,1 @@\n- AbstractMemorySegmentImpl segment = new NativeMemorySegmentImpl(min.toRawLongValue(), bytesSize, false, sessionImpl);\n+ AbstractMemorySegmentImpl segment = new NativeMemorySegmentImpl(min.toRawLongValue(), bytesSize, false, ref, sessionImpl);\n","filename":"src\/java.base\/share\/classes\/jdk\/internal\/foreign\/NativeMemorySegmentImpl.java","additions":9,"deletions":7,"binary":false,"changes":16,"status":"modified"},{"patch":"@@ -1226,1 +1226,1 @@\n- readOnly, sessionImpl);\n+ readOnly, null, sessionImpl);\n","filename":"src\/java.base\/share\/classes\/sun\/nio\/ch\/FileChannelImpl.java","additions":1,"deletions":1,"binary":false,"changes":2,"status":"modified"}]}
0 commit comments