From c7aa50559e03ce66ef70a1a92ffe182cad9a3172 Mon Sep 17 00:00:00 2001 From: Alexander Dorokhov Date: Mon, 5 Mar 2018 14:22:51 +0100 Subject: [PATCH] HotswapperPlugin: listen also to FileEvent.CREATE In some environments (especially Gradle + Kotlin + Mac OS), the old class files are removed before newly compiled files are written to file system. In this case WatchService generate ENTRY_DELETE and ENTRY_CREATE instead of just ENTRY_MODIFY. That means HotswapperPlugin does not detect changes in class files. This change makes the plugin listen to ENTRY_CREATE as well. --- .../org/hotswap/agent/plugin/hotswapper/HotswapperPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotswap-agent-core/src/main/java/org/hotswap/agent/plugin/hotswapper/HotswapperPlugin.java b/hotswap-agent-core/src/main/java/org/hotswap/agent/plugin/hotswapper/HotswapperPlugin.java index c6b7cb3c6..c9d61cba5 100644 --- a/hotswap-agent-core/src/main/java/org/hotswap/agent/plugin/hotswapper/HotswapperPlugin.java +++ b/hotswap-agent-core/src/main/java/org/hotswap/agent/plugin/hotswapper/HotswapperPlugin.java @@ -51,7 +51,7 @@ public class HotswapperPlugin { /** * For each changed class create a reload command. */ - @OnClassFileEvent(classNameRegexp = ".*", events = {FileEvent.MODIFY}) + @OnClassFileEvent(classNameRegexp = ".*", events = {FileEvent.MODIFY, FileEvent.CREATE}) public void watchReload(CtClass ctClass, ClassLoader appClassLoader, URL url) throws IOException, CannotCompileException { if (!ClassLoaderHelper.isClassLoaded(appClassLoader, ctClass.getName())) { LOGGER.trace("Class {} not loaded yet, no need for autoHotswap, skipped URL {}", ctClass.getName(), url);