diff --git a/src/java.base/share/classes/sun/nio/ch/AsynchronousChannelGroupImpl.java b/src/java.base/share/classes/sun/nio/ch/AsynchronousChannelGroupImpl.java index 4751cdea3d3..0c15c1a6439 100644 --- a/src/java.base/share/classes/sun/nio/ch/AsynchronousChannelGroupImpl.java +++ b/src/java.base/share/classes/sun/nio/ch/AsynchronousChannelGroupImpl.java @@ -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. diff --git a/src/java.base/share/classes/sun/nio/ch/AsynchronousServerSocketChannelImpl.java b/src/java.base/share/classes/sun/nio/ch/AsynchronousServerSocketChannelImpl.java index 8ce7ef1f986..cdc3a883734 100644 --- a/src/java.base/share/classes/sun/nio/ch/AsynchronousServerSocketChannelImpl.java +++ b/src/java.base/share/classes/sun/nio/ch/AsynchronousServerSocketChannelImpl.java @@ -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 diff --git a/src/java.base/share/classes/sun/nio/ch/FileLockTable.java b/src/java.base/share/classes/sun/nio/ch/FileLockTable.java index 9b7b7081f94..4b820a63d1d 100644 --- a/src/java.base/share/classes/sun/nio/ch/FileLockTable.java +++ b/src/java.base/share/classes/sun/nio/ch/FileLockTable.java @@ -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 { - private FileKey fileKey; + private final FileKey fileKey; FileLockReference(FileLock referent, ReferenceQueue 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> lockMap = - new ConcurrentHashMap>(); + private static final ConcurrentHashMap> lockMap = + new ConcurrentHashMap<>(); // reference queue for cleared refs - private static ReferenceQueue queue = new ReferenceQueue(); + private static final ReferenceQueue queue = new ReferenceQueue<>(); // The connection to which this table is connected private final Channel channel; diff --git a/src/java.base/share/classes/sun/nio/ch/IOVecWrapper.java b/src/java.base/share/classes/sun/nio/ch/IOVecWrapper.java index a2319d23e0e..d33d7f55d0b 100644 --- a/src/java.base/share/classes/sun/nio/ch/IOVecWrapper.java +++ b/src/java.base/share/classes/sun/nio/ch/IOVecWrapper.java @@ -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; diff --git a/src/java.base/share/classes/sun/nio/ch/OptionKey.java b/src/java.base/share/classes/sun/nio/ch/OptionKey.java index ebb272aea44..1b8a58e1d05 100644 --- a/src/java.base/share/classes/sun/nio/ch/OptionKey.java +++ b/src/java.base/share/classes/sun/nio/ch/OptionKey.java @@ -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; diff --git a/src/java.base/share/classes/sun/nio/ch/Util.java b/src/java.base/share/classes/sun/nio/ch/Util.java index 1f30a119360..bf9fc0c0f7c 100644 --- a/src/java.base/share/classes/sun/nio/ch/Util.java +++ b/src/java.base/share/classes/sun/nio/ch/Util.java @@ -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 = new TerminatingThreadLocal<>() { + private static final TerminatingThreadLocal 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); diff --git a/src/java.base/windows/classes/sun/nio/ch/PollArrayWrapper.java b/src/java.base/windows/classes/sun/nio/ch/PollArrayWrapper.java index fac5cfd9de9..1a33d47d27c 100644 --- a/src/java.base/windows/classes/sun/nio/ch/PollArrayWrapper.java +++ b/src/java.base/windows/classes/sun/nio/ch/PollArrayWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -51,7 +51,7 @@ class PollArrayWrapper { @Native private static final short FD_OFFSET = 0; // fd offset in pollfd @Native private static final short EVENT_OFFSET = 4; // events offset in pollfd - static short SIZE_POLLFD = 8; // sizeof pollfd struct + static final short SIZE_POLLFD = 8; // sizeof pollfd struct private int size; // Size of the pollArray diff --git a/src/java.base/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java b/src/java.base/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java index 22cdcfa17cc..20fdfc46ae3 100644 --- a/src/java.base/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java +++ b/src/java.base/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2022, 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 @@ -45,10 +45,9 @@ class WindowsAsynchronousSocketChannelImpl extends AsynchronousSocketChannelImpl implements Iocp.OverlappedChannel { private static final Unsafe unsafe = Unsafe.getUnsafe(); - private static int addressSize = unsafe.addressSize(); private static int dependsArch(int value32, int value64) { - return (addressSize == 4) ? value32 : value64; + return (unsafe.addressSize() == 4) ? value32 : value64; } /* diff --git a/src/java.base/windows/classes/sun/nio/ch/WindowsSelectorImpl.java b/src/java.base/windows/classes/sun/nio/ch/WindowsSelectorImpl.java index df26857c04b..977a1653fdd 100644 --- a/src/java.base/windows/classes/sun/nio/ch/WindowsSelectorImpl.java +++ b/src/java.base/windows/classes/sun/nio/ch/WindowsSelectorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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,14 +49,13 @@ import jdk.internal.misc.Unsafe; class WindowsSelectorImpl extends SelectorImpl { private static final Unsafe unsafe = Unsafe.getUnsafe(); - private static int addressSize = unsafe.addressSize(); private static int dependsArch(int value32, int value64) { - return (addressSize == 4) ? value32 : value64; + return (unsafe.addressSize() == 4) ? value32 : value64; } // Initial capacity of the poll array - private final int INIT_CAP = 8; + private static final int INIT_CAP = 8; // Maximum number of sockets for select(). // Should be INIT_CAP times a power of 2 private static final int MAX_SELECTABLE_FDS = 1024; @@ -74,7 +73,7 @@ class WindowsSelectorImpl extends SelectorImpl { private SelectionKeyImpl[] channelArray = new SelectionKeyImpl[INIT_CAP]; // The global native poll array holds file descriptors and event masks - private PollArrayWrapper pollWrapper; + private final PollArrayWrapper pollWrapper; // The number of valid entries in poll array, including entries occupied // by wakeup socket handle.