Class NioUtil

java.lang.Object
io.deephaven.io.NioUtil

public class NioUtil extends Object
General utilities for NIO
  • Constructor Details

    • NioUtil

      public NioUtil()
  • Method Details

    • reduceSelectorGarbage

      public static Selector reduceSelectorGarbage(Selector selector)
      Use reflection to change the collection implementations so iteration operations used in the selector implementation will not produce garbage.

      This is only applied when the system property java.specification.version is equal to "1.8".

      We can do this because, by looking at the source code, we can tell that there are no simultaneous iterations so reusing one iterator is OK. Because of concurrent modification issues and thread safety issues, this is generally likely to be the case anyway. The implementation of selector is not likely to change between minor JDK revisions. A major JDK release might produce a rewrite, but in that case we can check the JDK version and apply the appropriate set of patches.