Class HighSensitivityRegistrar

java.lang.Object
com.redhat.devtools.intellij.common.utils.HighSensitivityRegistrar

public class HighSensitivityRegistrar extends 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"
  • Constructor Details

    • HighSensitivityRegistrar

      public HighSensitivityRegistrar()
  • Method Details

    • 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 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(Path path, WatchEvent.Kind<Path>[] kinds, WatchService service) throws IOException
      Throws:
      IOException
    • getSensitivityWatchEventModifierClass

      protected Class<WatchEvent.Modifier> getSensitivityWatchEventModifierClass() throws 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:
      ClassNotFoundException - if the modifier class could not be found