8313743: Make fields final in sun.nio.ch

Reviewed-by: bpb
This commit is contained in:
Andrey Turbanov 2023-08-14 07:04:05 +00:00
parent ec0cc6300a
commit b88c273503
9 changed files with 25 additions and 27 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2023, 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
@ -59,7 +59,7 @@ abstract class AsynchronousChannelGroupImpl
private final AtomicInteger threadCount = new AtomicInteger();
// associated Executor for timeouts
private ScheduledThreadPoolExecutor timeoutExecutor;
private final ScheduledThreadPoolExecutor timeoutExecutor;
// task queue for when using a fixed thread pool. In that case, a thread
// waiting on I/O events must be awoken to poll tasks from this queue.

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2023, 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
@ -58,7 +58,7 @@ abstract class AsynchronousServerSocketChannelImpl
private final Object stateLock = new Object();
// close support
private ReadWriteLock closeLock = new ReentrantReadWriteLock();
private final ReadWriteLock closeLock = new ReentrantReadWriteLock();
private volatile boolean closed;
// set true when accept operation is cancelled

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2023, 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
@ -49,7 +49,7 @@ class FileLockTable {
* FileLock (and FileChannel) alive.
*/
private static class FileLockReference extends WeakReference<FileLock> {
private FileKey fileKey;
private final FileKey fileKey;
FileLockReference(FileLock referent,
ReferenceQueue<FileLock> queue,
@ -66,11 +66,11 @@ class FileLockTable {
// The system-wide map is a ConcurrentHashMap that is keyed on the FileKey.
// The map value is a list of file locks represented by FileLockReferences.
// All access to the list must be synchronized on the list.
private static ConcurrentHashMap<FileKey, List<FileLockReference>> lockMap =
new ConcurrentHashMap<FileKey, List<FileLockReference>>();
private static final ConcurrentHashMap<FileKey, List<FileLockReference>> lockMap =
new ConcurrentHashMap<>();
// reference queue for cleared refs
private static ReferenceQueue<FileLock> queue = new ReferenceQueue<FileLock>();
private static final ReferenceQueue<FileLock> queue = new ReferenceQueue<>();
// The connection to which this table is connected
private final Channel channel;

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2023, 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
@ -69,7 +69,7 @@ class IOVecWrapper {
final long address;
// Address size in bytes
static int addressSize;
static final int addressSize;
private static class Deallocator implements Runnable {
private final AllocatedNativeObject obj;

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2023, 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
@ -30,8 +30,8 @@ package sun.nio.ch;
*/
class OptionKey {
private int level;
private int name;
private final int level;
private final int name;
OptionKey(int level, int name) {
this.level = level;

View file

@ -53,7 +53,7 @@ public class Util {
private static final long MAX_CACHED_BUFFER_SIZE = getMaxCachedBufferSize();
// Per-carrier-thread cache of temporary direct buffers
private static TerminatingThreadLocal<BufferCache> bufferCache = new TerminatingThreadLocal<>() {
private static final TerminatingThreadLocal<BufferCache> bufferCache = new TerminatingThreadLocal<>() {
@Override
protected BufferCache initialValue() {
return new BufferCache();
@ -112,7 +112,7 @@ public class Util {
*/
private static class BufferCache {
// the array of buffers
private ByteBuffer[] buffers;
private final ByteBuffer[] buffers;
// the number of buffers in the cache
private int count;
@ -378,7 +378,7 @@ public class Util {
// -- Unsafe access --
private static Unsafe unsafe = Unsafe.getUnsafe();
private static final Unsafe unsafe = Unsafe.getUnsafe();
private static byte _get(long a) {
return unsafe.getByte(a);