From fd320e61ee262fddff266811218901cba50904e8 Mon Sep 17 00:00:00 2001 From: rootphantomy Date: Thu, 27 Oct 2022 15:31:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Egetresult=E7=9A=84debug?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/app/MainScreen.java | 38 +++++++++++++++++++------------ 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/main/java/app/MainScreen.java b/src/main/java/app/MainScreen.java index 6d4dc4b..7b02129 100644 --- a/src/main/java/app/MainScreen.java +++ b/src/main/java/app/MainScreen.java @@ -35,10 +35,12 @@ public class MainScreen { private static final List has_parameter = new ArrayList<>(); + //获取commond + private static final Commands command = new Commands(); + public static void screen(String[] args) throws Exception { Logo.PrintLogo();//打印logo System.out.println("============================================================================================"); - Commands command = new Commands(); //获取commond JCommander jc = JCommander.newBuilder().addObject(command).build(); jc.parse(args); if (command.help) { @@ -52,7 +54,7 @@ public static void screen(String[] args) throws Exception { if(command.isjar){ readbasicjar = true; } - getClassFileList(command.jarpath, true, readbasicjar); + getClassFileList(command.jarpath, readbasicjar); discovery(); inherit(); @@ -95,10 +97,7 @@ public static void screen(String[] args) throws Exception { String returnparameter = ""; String parameter = ""; String method = ""; - boolean sta_tic = false; - if(command.isstatic){ - sta_tic = true; - } + boolean sta_tic = command.isstatic; if (command.paramter != null) { parameter = command.paramter.replace(".", "/").replace("|", "$"); } @@ -408,11 +407,21 @@ public static void make_methoddunnolist(HashMap> hashMap){ } public static HashMap> getresult(HashSet hashSet,List list){ HashMap> returnresult = new HashMap<>(); - for(String s:hashSet){ - List list1 = getlist(s,list); - returnresult.put(s,list1); + if (command.isdedug){ + for(String s:hashSet){ + List list1 = getlist(s,list); + returnresult.put(s,list1); + System.out.println(returnresult); + } + } + else { + for(String s:hashSet){ + List list1 = getlist(s,list); + returnresult.put(s,list1); + } } return returnresult; + } public static List getlist(String s,List list){ List list1 = new ArrayList<>(); @@ -576,8 +585,8 @@ public static void has_interfaces(List interfacea){ for (Map.Entry handle : classMap.entrySet()) { List interfaces = handle.getValue().getInterfaces(); if (interfaces != null) { - for (int j = 0; j < interfaces.size(); j++) { - if (interfaces.get(j).contains(s.replace(".", "/").replace("|", "$"))) { + for (String anInterface : interfaces) { + if (anInterface.contains(s.replace(".", "/").replace("|", "$"))) { hasinterfaces.add(handle.getKey().getName()); } } @@ -613,11 +622,11 @@ private static void discovery() { DiscoveryService.start(classFileList, discoveredClasses, discoveredMethods, classMap, methodMap, classFileByName); } - private static void getClassFileList(String path,boolean readjar,boolean readbasicjar) throws Exception { + private static void getClassFileList(String path, boolean readbasicjar) throws Exception { ReadUtil readUtil = new ReadUtil(); File file = new File(path); if(file.isDirectory()){ - getclassfromfloder(path,readjar,readbasicjar); + getclassfromfloder(path, true,readbasicjar); } if(file.isFile()){ if(path.endsWith(".txt")){ @@ -627,7 +636,7 @@ private static void getClassFileList(String path,boolean readjar,boolean readbas classFileList.addAll(ClassUtil.getAllClassesFromJars(Collections.singletonList(s), readbasicjar)); } else if (new File(s).isDirectory()) { - getclassfromfloder(s, readjar, readbasicjar); + getclassfromfloder(s, true, readbasicjar); } else { System.out.println("导入出错!!!!!!!!!!!!!"); } @@ -643,6 +652,7 @@ public static void getclassfromfloder(String path,boolean readjar,boolean readba if(readjar){ List jarfiles = ReadUtil.noRecursion(file,".jar"); + assert jarfiles != null; for (String jarfile : jarfiles) { classFileList.addAll(ClassUtil.getAllClassesFromJars(Collections.singletonList(jarfile), readbasicjar)); }