Some java.nio classes like `Buffer` have fields and inner classes that could be declared `final`. This would make the intent clearer and could potentially unlock performance optimizations.
Historically, some of these fields were mutated (e.g. a mapped buffer could change its address to zero) but now they appear to retain their values throughout the instance lifetimes.
Making these fields final also provides safe publication across threads. Even though these classes are not intended to be thread-safe, they are sometimes used by designated garbage collect threads.
Historically, some of these fields were mutated (e.g. a mapped buffer could change its address to zero) but now they appear to retain their values throughout the instance lifetimes.
Making these fields final also provides safe publication across threads. Even though these classes are not intended to be thread-safe, they are sometimes used by designated garbage collect threads.
- relates to
-
JDK-8261329 (bf) Consolidate and unify NIO Buffer memory access operations
-
- Open
-