Skip to content

Commit d117350

Browse files
committed
8300866: Declare some classes final in java.io
Reviewed-by: alanb
1 parent 1a3cb8c commit d117350

File tree

5 files changed

+12
-14
lines changed

5 files changed

+12
-14
lines changed

src/java.base/share/classes/java/io/ExpiringCache.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,23 @@
2323
* questions.
2424
*/
2525

26-
/*
27-
*/
28-
2926
package java.io;
3027

3128
import java.util.Map;
3229
import java.util.LinkedHashMap;
3330
import java.util.Set;
3431

35-
class ExpiringCache {
32+
final class ExpiringCache {
3633

3734
private static final int QUERY_OVERFLOW = 300;
3835
private static final int MAX_ENTRIES = 200;
3936
private final long millisUntilExpiration;
4037
private final Map<String,Entry> map;
38+
4139
// Clear out old entries every few queries
4240
private int queryCount;
4341

44-
static class Entry {
42+
static final class Entry {
4543
private long timestamp;
4644
private String val;
4745

src/java.base/share/classes/java/io/ObjectInputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3862,7 +3862,7 @@ long getBytesRead() {
38623862
* as memory conservation, it does not enforce this constraint.
38633863
*/
38643864
// REMIND: add full description of exception propagation algorithm?
3865-
private static class HandleTable {
3865+
private static final class HandleTable {
38663866

38673867
/* status codes indicating whether object has associated exception */
38683868
private static final byte STATUS_OK = 1;

src/java.base/share/classes/java/io/ObjectOutputStream.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,7 +1754,7 @@ private int getFieldOffset(String name, Class<?> type) {
17541754
* bracketed by block data markers (see object serialization specification
17551755
* for details).
17561756
*/
1757-
private static class BlockDataOutputStream
1757+
private static final class BlockDataOutputStream
17581758
extends OutputStream implements DataOutput
17591759
{
17601760
/** maximum data block length */
@@ -2260,7 +2260,7 @@ private void writeUTFBody(String s) throws IOException {
22602260
* Lightweight identity hash table which maps objects to integer handles,
22612261
* assigned in ascending order.
22622262
*/
2263-
private static class HandleTable {
2263+
private static final class HandleTable {
22642264

22652265
/* number of mappings in table/next available handle */
22662266
private int size;
@@ -2385,7 +2385,7 @@ private int hash(Object obj) {
23852385
* Lightweight identity hash table which maps objects to replacement
23862386
* objects.
23872387
*/
2388-
private static class ReplaceTable {
2388+
private static final class ReplaceTable {
23892389

23902390
/* maps object -> index */
23912391
private final HandleTable htab;
@@ -2449,7 +2449,7 @@ private void grow() {
24492449
* Stack to keep debug information about the state of the
24502450
* serialization process, for embedding in exception messages.
24512451
*/
2452-
private static class DebugTraceInfoStack {
2452+
private static final class DebugTraceInfoStack {
24532453
private final List<String> stack;
24542454

24552455
DebugTraceInfoStack() {

src/java.base/share/classes/java/io/ObjectStreamClass.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,7 +1871,7 @@ public int compare(MemberSignature ms1, MemberSignature ms2) {
18711871
* Class for computing and caching field/constructor/method signatures
18721872
* during serialVersionUID calculation.
18731873
*/
1874-
private static class MemberSignature {
1874+
private static final class MemberSignature {
18751875

18761876
public final Member member;
18771877
public final String name;
@@ -1902,7 +1902,7 @@ public MemberSignature(Method meth) {
19021902
* Class for setting and retrieving serializable field values in batch.
19031903
*/
19041904
// REMIND: dynamically generate these?
1905-
private static class FieldReflector {
1905+
private static final class FieldReflector {
19061906

19071907
/** handle for performing unsafe operations */
19081908
private static final Unsafe UNSAFE = Unsafe.getUnsafe();

src/java.base/share/classes/java/io/ProxyingConsole.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public Charset charset() {
145145
return delegate.charset();
146146
}
147147

148-
private static class WrappingReader extends Reader {
148+
private static final class WrappingReader extends Reader {
149149
private final Reader r;
150150
private final Object lock;
151151

@@ -168,7 +168,7 @@ public void close() {
168168
}
169169
}
170170

171-
private static class WrappingWriter extends PrintWriter {
171+
private static final class WrappingWriter extends PrintWriter {
172172
private final PrintWriter pw;
173173
private final Object lock;
174174

0 commit comments

Comments
 (0)