8343039: Remove jdk.internal.misc.InternalLock and usages from java.io

Reviewed-by: liach, alanb
This commit is contained in:
Brian Burkhalter 2024-11-15 16:11:34 +00:00
parent 3c38ed4128
commit 0b9b82af03
19 changed files with 548 additions and 1789 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2024, 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
@ -27,7 +27,6 @@ package java.io;
import java.util.Arrays;
import java.util.Objects;
import jdk.internal.misc.InternalLock;
/**
* A {@code PushbackInputStream} adds
@ -54,10 +53,6 @@ import jdk.internal.misc.InternalLock;
* @since 1.0
*/
public class PushbackInputStream extends FilterInputStream {
// initialized to null when PushbackInputStream is sub-classed
private final InternalLock closeLock;
/**
* The pushback buffer.
* @since 1.1
@ -101,13 +96,6 @@ public class PushbackInputStream extends FilterInputStream {
}
this.buf = new byte[size];
this.pos = size;
// use monitors when PushbackInputStream is sub-classed
if (getClass() == PushbackInputStream.class) {
closeLock = InternalLock.newLockOrNull();
} else {
closeLock = null;
}
}
/**
@ -386,27 +374,12 @@ public class PushbackInputStream extends FilterInputStream {
*
* @throws IOException if an I/O error occurs.
*/
public void close() throws IOException {
if (closeLock != null) {
closeLock.lock();
try {
implClose();
} finally {
closeLock.unlock();
}
} else {
synchronized (this) {
implClose();
}
}
}
private void implClose() throws IOException {
if (in != null) {
in.close();
in = null;
buf = null;
}
public synchronized void close() throws IOException {
if (in == null)
return;
in.close();
in = null;
buf = null;
}
@Override