Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8297344

Improve clarity, performance and, safety in some java.nio classes

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • core-libs
    • None

      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.

            pminborg Per-Ake Minborg
            pminborg Per-Ake Minborg
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: