class TreeWatcherNIO extends AbstractNIO2Watcher {


    private final static WatchEvent.Modifier HIGH;
    private final static WatchEvent.Modifier FILE_TREE;
    private final static WatchEvent.Modifier[] MODIFIERS;

    static {
        // try to set high sensitivity
        HIGH =  getWatchEventModifier("com.sun.nio.file.SensitivityWatchEventModifier","HIGH");
        // try to set file tree modifier
        FILE_TREE = getWatchEventModifier("com.sun.nio.file.ExtendedWatchEventModifier", "FILE_TREE");

        if(FILE_TREE != null) {
            MODIFIERS =  new WatchEvent.Modifier[] { FILE_TREE, HIGH };
        } else {
            MODIFIERS =  new WatchEvent.Modifier[] { HIGH };
        }
    }
    /**
     * Instantiates a new tree watcher nio.
     *
     * @throws IOException Signals that an I/O exception has occurred.
     */
    public TreeWatcherNIO() throws IOException {
        super();
    }

    /**
     * Register the given directory with the WatchService.
     *
     * @param dir the directory to register watch on
     * @throws IOException Signals that an I/O exception has occurred.
     */
    private void register(Path dir) throws IOException {<FILL_FUNCTION_BODY>}

    /**
     * Register the given directory,  with the
     * WatchService. Sub-directories are automatically watched (filesystem supported)
     *
     * @param dir the dir
     * @throws IOException Signals that an I/O exception has occurred.
     */
    @Override
    protected void registerAll(Path dir) throws IOException {
        LOGGER.info("Registering directory {} ", dir);
        register(dir);
    }
}


        for(Path p: keys.values()) {
            // This may NOT be correct for all cases (ensure resolve will work!)
            if(dir.startsWith(p)) {
                LOGGER.debug("Path {} watched via {}", dir, p);
                return;
            }
        }

        if (FILE_TREE == null) {
            LOGGER.debug("WATCHING:ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY - high} {}", dir);
        } else {
            LOGGER.debug("WATCHING: ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY - fileTree,high {}", dir);
        }

        final WatchKey key = dir.register(watcher, KINDS,  MODIFIERS);

        keys.put(key, dir);
    
<methods>public void <init>() throws java.io.IOException,public void addDirectory(java.nio.file.Path) throws java.io.IOException,public synchronized void addEventListener(java.lang.ClassLoader, java.net.URI, org.hotswap.agent.watch.WatchEventListener) ,public void addEventListener(java.lang.ClassLoader, java.net.URL, org.hotswap.agent.watch.WatchEventListener) ,public void closeClassLoader(java.lang.ClassLoader) ,public void run() ,public void stop() <variables>protected static final Kind<?>[] KINDS,protected org.hotswap.agent.logging.AgentLogger LOGGER,protected Map<org.hotswap.agent.watch.WatchEventListener,java.lang.ClassLoader> classLoaderListeners,protected final non-sealed org.hotswap.agent.watch.nio.EventDispatcher dispatcher,protected final non-sealed Map<java.nio.file.WatchKey,java.nio.file.Path> keys,private final Map<java.nio.file.Path,List<org.hotswap.agent.watch.WatchEventListener>> listeners,private java.lang.Thread runner,private volatile boolean stopped,protected java.nio.file.WatchService watcher