diff --git a/memorycompiler/src/main/java/com/taobao/arthas/compiler/PackageInternalsFinder.java b/memorycompiler/src/main/java/com/taobao/arthas/compiler/PackageInternalsFinder.java index 471afc690..917c8cc92 100644 --- a/memorycompiler/src/main/java/com/taobao/arthas/compiler/PackageInternalsFinder.java +++ b/memorycompiler/src/main/java/com/taobao/arthas/compiler/PackageInternalsFinder.java @@ -98,18 +98,22 @@ public class PackageInternalsFinder { JarURLConnection jarConn = (JarURLConnection) packageFolderURL.openConnection(); String rootEntryName = jarConn.getEntryName(); - int rootEnd = rootEntryName.length() + 1; - Enumeration entryEnum = jarConn.getJarFile().entries(); - while (entryEnum.hasMoreElements()) { - JarEntry jarEntry = entryEnum.nextElement(); - String name = jarEntry.getName(); - if (name.startsWith(rootEntryName) && name.indexOf('/', rootEnd) == -1 && name.endsWith(CLASS_FILE_EXTENSION)) { - URI uri = URI.create(jarUri + "!/" + name); - String binaryName = name.replaceAll("/", "."); - binaryName = binaryName.replaceAll(CLASS_FILE_EXTENSION + "$", ""); + if (rootEntryName != null) { + //可能为 null(自己没有类文件时) + int rootEnd = rootEntryName.length() + 1; - result.add(new CustomJavaFileObject(binaryName, uri)); + Enumeration entryEnum = jarConn.getJarFile().entries(); + while (entryEnum.hasMoreElements()) { + JarEntry jarEntry = entryEnum.nextElement(); + String name = jarEntry.getName(); + if (name.startsWith(rootEntryName) && name.indexOf('/', rootEnd) == -1 && name.endsWith(CLASS_FILE_EXTENSION)) { + URI uri = URI.create(jarUri + "!/" + name); + String binaryName = name.replaceAll("/", "."); + binaryName = binaryName.replaceAll(CLASS_FILE_EXTENSION + "$", ""); + + result.add(new CustomJavaFileObject(binaryName, uri)); + } } } } catch (Exception e) {