From 51842f7ff17ccd986381527116b40c182e97f22a Mon Sep 17 00:00:00 2001 From: hengyunabc Date: Wed, 27 May 2020 19:49:32 +0800 Subject: [PATCH] fix redefine may throw NullPointerException problem. close #1215 --- .../taobao/arthas/core/command/klass100/RedefineCommand.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/taobao/arthas/core/command/klass100/RedefineCommand.java b/core/src/main/java/com/taobao/arthas/core/command/klass100/RedefineCommand.java index 3a09c5d55..5bcdc2780 100644 --- a/core/src/main/java/com/taobao/arthas/core/command/klass100/RedefineCommand.java +++ b/core/src/main/java/com/taobao/arthas/core/command/klass100/RedefineCommand.java @@ -113,7 +113,8 @@ public class RedefineCommand extends AnnotatedCommand { List definitions = new ArrayList(); for (Class clazz : inst.getAllLoadedClasses()) { if (bytesMap.containsKey(clazz.getName())) { - if (hashCode != null && !Integer.toHexString(clazz.getClassLoader().hashCode()).equals(hashCode)) { + ClassLoader classLoader = clazz.getClassLoader(); + if (classLoader != null && hashCode != null && !Integer.toHexString(classLoader.hashCode()).equals(hashCode)) { continue; } definitions.add(new ClassDefinition(clazz, bytesMap.get(clazz.getName())));