Skip to content

Commit 079255e

Browse files
committed
8300864: Declare some fields in java.io as final
Reviewed-by: rriggs, lancea
1 parent a56598f commit 079255e

File tree

8 files changed

+112
-112
lines changed

8 files changed

+112
-112
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -55,7 +55,7 @@
5555
*/
5656
public class BufferedInputStream extends FilterInputStream {
5757

58-
private static int DEFAULT_BUFFER_SIZE = 8192;
58+
private static final int DEFAULT_BUFFER_SIZE = 8192;
5959

6060
/**
6161
* As this class is used early during bootstrap, it's motivated to use

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -85,8 +85,8 @@ public class BufferedReader extends Reader {
8585
/** The skipLF flag when the mark was set */
8686
private boolean markedSkipLF = false;
8787

88-
private static int defaultCharBufferSize = 8192;
89-
private static int defaultExpectedLineLength = 80;
88+
private static final int DEFAULT_CHAR_BUFFER_SIZE = 8192;
89+
private static final int DEFAULT_EXPECTED_LINE_LENGTH = 80;
9090

9191
/**
9292
* Creates a buffering character-input stream that uses an input buffer of
@@ -113,7 +113,7 @@ public BufferedReader(Reader in, int sz) {
113113
* @param in A Reader
114114
*/
115115
public BufferedReader(Reader in) {
116-
this(in, defaultCharBufferSize);
116+
this(in, DEFAULT_CHAR_BUFFER_SIZE);
117117
}
118118

119119
/** Checks to make sure that the stream has not been closed */
@@ -414,7 +414,7 @@ private String implReadLine(boolean ignoreLF, boolean[] term) throws IOException
414414
}
415415

416416
if (s == null)
417-
s = new StringBuilder(defaultExpectedLineLength);
417+
s = new StringBuilder(DEFAULT_EXPECTED_LINE_LENGTH);
418418
s.append(cb, startChar, i - startChar);
419419
}
420420
}

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -28,21 +28,21 @@
2828

2929
package java.io;
3030

31-
import java.util.Iterator;
3231
import java.util.Map;
3332
import java.util.LinkedHashMap;
3433
import java.util.Set;
3534

3635
class ExpiringCache {
37-
private long millisUntilExpiration;
38-
private Map<String,Entry> map;
36+
37+
private static final int QUERY_OVERFLOW = 300;
38+
private static final int MAX_ENTRIES = 200;
39+
private final long millisUntilExpiration;
40+
private final Map<String,Entry> map;
3941
// Clear out old entries every few queries
4042
private int queryCount;
41-
private int queryOverflow = 300;
42-
private int MAX_ENTRIES = 200;
4343

4444
static class Entry {
45-
private long timestamp;
45+
private long timestamp;
4646
private String val;
4747

4848
Entry(long timestamp, String val) {
@@ -72,7 +72,7 @@ protected boolean removeEldestEntry(Map.Entry<String,Entry> eldest) {
7272
}
7373

7474
synchronized String get(String key) {
75-
if (++queryCount >= queryOverflow) {
75+
if (++queryCount >= QUERY_OVERFLOW) {
7676
cleanup();
7777
}
7878
Entry entry = entryFor(key);
@@ -83,7 +83,7 @@ synchronized String get(String key) {
8383
}
8484

8585
synchronized void put(String key, String val) {
86-
if (++queryCount >= queryOverflow) {
86+
if (++queryCount >= QUERY_OVERFLOW) {
8787
cleanup();
8888
}
8989
Entry entry = entryFor(key);

0 commit comments

Comments
 (0)