8129776: The optimized Stream returned from Files.lines should unmap the mapped byte buffer (if created) when closed

Reviewed-by: rriggs, psandoz, alanb
This commit is contained in:
Brian Burkhalter 2021-02-08 22:18:00 +00:00
parent ad525bcd38
commit 7451962849
3 changed files with 50 additions and 18 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -32,6 +32,7 @@ import java.util.Objects;
import jdk.internal.access.foreign.MemorySegmentProxy;
import jdk.internal.access.foreign.UnmapperProxy;
import jdk.internal.misc.ScopedMemoryAccess;
import jdk.internal.misc.Unsafe;
/**
@ -132,7 +133,7 @@ public abstract class MappedByteBuffer
@Override
public void unmap() {
throw new UnsupportedOperationException();
Unsafe.getUnsafe().invokeCleaner(MappedByteBuffer.this);
}
} : null;
}