From d630ba9a6f946489e6f936efbb80109ba6953ac2 Mon Sep 17 00:00:00 2001 From: zhangjin Date: Mon, 8 Jul 2019 15:37:07 +0800 Subject: [PATCH] sm support classloader hash. #767 --- .../core/command/klass100/SearchMethodCommand.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/com/taobao/arthas/core/command/klass100/SearchMethodCommand.java b/core/src/main/java/com/taobao/arthas/core/command/klass100/SearchMethodCommand.java index bb41ed291..840ccdd59 100644 --- a/core/src/main/java/com/taobao/arthas/core/command/klass100/SearchMethodCommand.java +++ b/core/src/main/java/com/taobao/arthas/core/command/klass100/SearchMethodCommand.java @@ -99,7 +99,7 @@ public class SearchMethodCommand extends AnnotatedCommand { } if (isDetail) { - process.write(RenderUtil.render(renderConstructor(constructor), process.width()) + "\n"); + process.write(RenderUtil.render(renderConstructor(constructor, clazz), process.width()) + "\n"); } else { String line = format("%s %s%n", clazz.getName(), methodNameWithDescriptor); process.write(line); @@ -114,7 +114,7 @@ public class SearchMethodCommand extends AnnotatedCommand { } if (isDetail) { - process.write(RenderUtil.render(renderMethod(method), process.width()) + "\n"); + process.write(RenderUtil.render(renderMethod(method, clazz), process.width()) + "\n"); } else { String line = format("%s %s%n", clazz.getName(), methodNameWithDescriptor); process.write(line); @@ -135,7 +135,7 @@ public class SearchMethodCommand extends AnnotatedCommand { return isRegEx ? new RegexMatcher(methodPattern) : new WildcardMatcher(methodPattern); } - private Element renderMethod(Method method) { + private Element renderMethod(Method method, Class clazz) { TableElement table = new TableElement().leftCellPadding(1).rightCellPadding(1); table.row(label("declaring-class").style(bold.bold()), label(method.getDeclaringClass().getName())) @@ -144,11 +144,12 @@ public class SearchMethodCommand extends AnnotatedCommand { .row(label("annotation").style(bold.bold()), label(TypeRenderUtils.drawAnnotation(method))) .row(label("parameters").style(bold.bold()), label(TypeRenderUtils.drawParameters(method))) .row(label("return").style(bold.bold()), label(TypeRenderUtils.drawReturn(method))) - .row(label("exceptions").style(bold.bold()), label(TypeRenderUtils.drawExceptions(method))); + .row(label("exceptions").style(bold.bold()), label(TypeRenderUtils.drawExceptions(method))) + .row(label("classLoaderHash").style(bold.bold()), label(StringUtils.classLoaderHash(clazz))); return table; } - private Element renderConstructor(Constructor constructor) { + private Element renderConstructor(Constructor constructor, Class clazz) { TableElement table = new TableElement().leftCellPadding(1).rightCellPadding(1); table.row(label("declaring-class").style(bold.bold()), label(constructor.getDeclaringClass().getName())) @@ -156,7 +157,8 @@ public class SearchMethodCommand extends AnnotatedCommand { .row(label("modifier").style(bold.bold()), label(StringUtils.modifier(constructor.getModifiers(), ','))) .row(label("annotation").style(bold.bold()), label(TypeRenderUtils.drawAnnotation(constructor.getDeclaredAnnotations()))) .row(label("parameters").style(bold.bold()), label(TypeRenderUtils.drawParameters(constructor))) - .row(label("exceptions").style(bold.bold()), label(TypeRenderUtils.drawExceptions(constructor))); + .row(label("exceptions").style(bold.bold()), label(TypeRenderUtils.drawExceptions(constructor))) + .row(label("classLoaderHash").style(bold.bold()), label(StringUtils.classLoaderHash(clazz))); return table; }