Class HighSensitivityRegistrar


  • public class HighSensitivityRegistrar
    extends java.lang.Object
    A class that allows testing and grabbing SensitivityWatchEventModifier#HIGH reflectively. This allows the code to run in jdks where it does not exists (ex. IBM, etc.). SensitivityWatchEventModifier#HIGH is required for the WatchService to work ~reliably on MacOS where no native hooks but polling is used.
    See Also:
    "https://bugs.openjdk.java.net/browse/JDK-7133447", "https://stackoverflow.com/questions/9588737/is-java-7-watchservice-slow-for-anyone-else"
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean exists()  
      java.nio.file.WatchEvent.Modifier get()
      Returns the SensitivityWatchEventModifier#HIGH if it exists (on sun jvms or openjdk), null otherwise.
      protected java.lang.Class<java.nio.file.WatchEvent.Modifier> getSensitivityWatchEventModifierClass()
      Returns the class SensitivityWatchEventModifier if it exists.
      protected boolean isMac()
      Returns true if the current this is running on is MacOS.
      boolean isRequired()  
      void registerService​(java.nio.file.Path path, java.nio.file.WatchEvent.Kind<java.nio.file.Path>[] kinds, java.nio.file.WatchService service)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HighSensitivityRegistrar

        public HighSensitivityRegistrar()
    • Method Detail

      • isRequired

        public boolean isRequired()
      • isMac

        protected boolean isMac()
        Returns true if the current this is running on is MacOS. Returns false otherwise. Method could be private but is kept protected for testing purposes.
        Returns:
        true if the current system is MacOS
      • exists

        public boolean exists()
      • get

        public java.nio.file.WatchEvent.Modifier get()
        Returns the SensitivityWatchEventModifier#HIGH if it exists (on sun jvms or openjdk), null otherwise.
        Returns:
        SensitivityWatchEventModifier#HIGH if it exists
      • registerService

        public void registerService​(java.nio.file.Path path,
                                    java.nio.file.WatchEvent.Kind<java.nio.file.Path>[] kinds,
                                    java.nio.file.WatchService service)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • getSensitivityWatchEventModifierClass

        protected java.lang.Class<java.nio.file.WatchEvent.Modifier> getSensitivityWatchEventModifierClass()
                                                                                                    throws java.lang.ClassNotFoundException
        Returns the class SensitivityWatchEventModifier if it exists. Throws ClassNotFoundException if it was not found. Method could be private, is kept protected for testing purposes.
        Returns:
        SensitivityWatchEventModifier if it was found
        Throws:
        java.lang.ClassNotFoundException - if the modifier class could not be found