RFR JDK-8234049: Implementation of Memory Access API (Incubator)
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Wed Dec 11 00:13:39 UTC 2019
On 10/12/2019 18:45, Paul Sandoz wrote:
> MemoryScope changes look good.
>
> In j.u.concurrent we use ExceptionInInitializerError in the static blocks when there is an error looking up the VH,
>
> FWIW close can also fail because it has already been closed but the exception message does not distinguish between the two states (active or already closed).
>
> Paul.
>
Hi Paul,
would something like this be satisfactory?
diff -r 50ef46599c56
src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/MemoryScope.java
---
a/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/MemoryScope.java
Tue Dec 10 16:28:03 2019 +0000
+++
b/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/MemoryScope.java
Wed Dec 11 00:12:20 2019 +0000
@@ -48,7 +48,7 @@
try {
COUNT_HANDLE =
MethodHandles.lookup().findVarHandle(MemoryScope.class, "activeCount",
int.class);
} catch (Throwable ex) {
- throw new IllegalStateException(ex);
+ throw new ExceptionInInitializerError(ex);
}
}
@@ -107,6 +107,9 @@
void close() {
if (!COUNT_HANDLE.compareAndSet(this, UNACQUIRED, CLOSED)) {
+ //first check if already closed...
+ checkAliveConfined();
+ //...if not, then we have acquired views that are still active
throw new IllegalStateException("Cannot close a segment
that has active acquired views");
}
if (cleanupAction != null) {
If you need a full webrev please let me know.
Thanks
Maurizio
More information about the core-libs-dev
mailing list