diff --git a/hotswap-agent-core/src/main/java/org/hotswap/agent/plugin/jvm/ClassInitPlugin.java b/hotswap-agent-core/src/main/java/org/hotswap/agent/plugin/jvm/ClassInitPlugin.java index 06043ef85..bb706d1ed 100644 --- a/hotswap-agent-core/src/main/java/org/hotswap/agent/plugin/jvm/ClassInitPlugin.java +++ b/hotswap-agent-core/src/main/java/org/hotswap/agent/plugin/jvm/ClassInitPlugin.java @@ -94,8 +94,11 @@ public void edit(FieldAccess f) throws CannotCompileException { reinitializeStatics[0] = true; } if (originalField != null) { - // ENUM$VALUES is last in enumeration - if (originalClass.isEnum() && "ENUM$VALUES".equals(f.getFieldName())) { + // Enum class contains an array field, in javac it's name starts with $VALUES, + // in eclipse compiler starts with ENUM$VALUES + if (originalClass.isEnum() && f.getSignature().startsWith("[L") + && (f.getFieldName().startsWith("$VALUES") + || f.getFieldName().startsWith("ENUM$VALUES"))) { if (reinitializeStatics[0]) { LOGGER.debug("New field will be initialized {}", f.getFieldName()); } else { @@ -149,7 +152,7 @@ private static boolean checkOldEnumValues(CtClass ctClass, Class originalClas try { CtField existing = ctClass.getDeclaredField(en.toString()); } catch (NotFoundException e) { - LOGGER.debug("Enum field deleted. ENUM$VALUES will be reinitialized {}", en.toString()); + LOGGER.debug("Enum field deleted. $VALUES will be reinitialized {}", en.toString()); return true; } }