diff --git a/core/src/main/java/com/taobao/arthas/core/util/StringUtils.java b/core/src/main/java/com/taobao/arthas/core/util/StringUtils.java index b7700d71..d18b8d88 100644 --- a/core/src/main/java/com/taobao/arthas/core/util/StringUtils.java +++ b/core/src/main/java/com/taobao/arthas/core/util/StringUtils.java @@ -957,15 +957,18 @@ public abstract class StringUtils { return text.substring(pos + after.length()); } + // print|(ILjava/util/List;)V public static String[] splitMethodInfo(String methodInfo) { int index = methodInfo.indexOf('|'); return new String[] { methodInfo.substring(0, index), methodInfo.substring(index + 1, methodInfo.length()) }; } + // demo/MathGame|primeFactors|(I)Ljava/util/List;|24 public static String[] splitInvokeInfo(String invokeInfo) { int index1 = invokeInfo.indexOf('|'); int index2 = invokeInfo.indexOf('|', index1 + 1); + int index3 = invokeInfo.indexOf('|', index2 + 1); return new String[] { invokeInfo.substring(0, index1), invokeInfo.substring(index1 + 1, index2), - invokeInfo.substring(index2 + 1, invokeInfo.length()) }; + invokeInfo.substring(index2 + 1, index3), invokeInfo.substring(index3 + 1, invokeInfo.length()) }; } } diff --git a/core/src/test/java/com/taobao/arthas/core/advisor/SpyImplTest.java b/core/src/test/java/com/taobao/arthas/core/advisor/SpyImplTest.java index 047d32f6..5d6110cf 100644 --- a/core/src/test/java/com/taobao/arthas/core/advisor/SpyImplTest.java +++ b/core/src/test/java/com/taobao/arthas/core/advisor/SpyImplTest.java @@ -17,12 +17,14 @@ public class SpyImplTest { Assertions.assertThat(StringUtils.splitMethodInfo("a|b")).containsExactly("a", "b"); Assertions.assertThat(StringUtils.splitMethodInfo("xxxxxxxxxx|fffffffffff")).containsExactly("xxxxxxxxxx", "fffffffffff"); + Assertions.assertThat(StringUtils.splitMethodInfo("print|(ILjava/util/List;)V")).containsExactly("print", + "(ILjava/util/List;)V"); } @Test public void testSplitInvokeInfo() throws Throwable { - Assertions.assertThat(StringUtils.splitInvokeInfo("a|b|c")).containsExactly("a", "b", "c"); - Assertions.assertThat(StringUtils.splitInvokeInfo("xxxxxxxxxx|fffffffffff|yyy")).containsExactly("xxxxxxxxxx", - "fffffffffff", "yyy"); + Assertions.assertThat(StringUtils.splitInvokeInfo("demo/MathGame|primeFactors|(I)Ljava/util/List;|24")) + .containsExactly("demo/MathGame", "primeFactors", "(I)Ljava/util/List;", "24"); + } }