@@ -256,8 +256,11 @@ public static ArrayList<JarEntry> getAllClassesFromJar(JarInputStream JarInputSt
256256
257257 //Fetch filtered classes from a list of JarEntry
258258 public static ArrayList <JarEntry > getFilteredClassesFromJar (ArrayList <JarEntry > listOfAllClasses , String className ) {
259- listOfAllClasses = listOfAllClasses .stream ().filter (e -> e .getName ().endsWith (className )).collect (Collectors .toCollection (ArrayList ::new ));
260- return listOfAllClasses ;
259+ ArrayList <JarEntry > listOfFilteredClasses = new ArrayList <>();
260+ for (JarEntry entry : listOfAllClasses )
261+ if (entry .getName ().endsWith (className ))
262+ listOfFilteredClasses .add (entry );
263+ return listOfFilteredClasses ;
261264 }
262265public static ArrayList <Pair <String , String >> fetchAllMethodSignaturesForyaml (JarFile JarFile ,JarEntry jar ) throws IOException {
263266 ClassParser cp = new ClassParser (JarFile .getInputStream (jar ), jar .getName ());
@@ -267,7 +270,9 @@ public static ArrayList<Pair<String, String>> fetchAllMethodSignaturesForyaml (J
267270 String className =jc .getClassName ().substring (jc .getClassName ().lastIndexOf ("." )+1 );
268271 ArrayList <Pair <String , String >> signatureResults = new ArrayList <>();
269272 for (Method tempMethod : methods )
270- if (Arrays .stream (tempMethod .getAnnotationEntries ()).filter (e ->e .getAnnotationType ().equals ("Lorg/junit/Test;" )).toArray ().length > 0 ){
273+ if (Arrays .stream (tempMethod .getAnnotationEntries ())
274+ .map (e ->e .getAnnotationType ())
275+ .anyMatch (e ->e .equals ("Lorg/junit/Test;" ))){
271276 String methodDescriptor =tempMethod .getName () + tempMethod .getSignature ();
272277 signatureResults .add (new Pair <>(className +"#" +tempMethod .getName (),jc .getClassName () + "." + methodDescriptor ));
273278 }
@@ -286,12 +291,19 @@ public static String fetchMethodSignatures(JarFile JarFile, JarEntry jar, String
286291 signatureResults .add (tempMethod );
287292
288293 if (returnType .isPresent ()) {
289- signatureResults = signatureResults .stream ().filter (e -> e .getReturnType ().toString ().contains (returnType .get ())).collect (Collectors .toCollection (ArrayList ::new ));
294+ ArrayList <Method > tempsignatureResults = new ArrayList <>();
295+ for (Method tempMethod : signatureResults )
296+ if (tempMethod .getReturnType ().toString ().contains (returnType .get ()))
297+ tempsignatureResults .add (tempMethod );
298+ signatureResults =new ArrayList <>(tempsignatureResults );
290299
291300 if (paramterTypes .isPresent ()) {
292301 String [] paramlist = paramterTypes .get ().split ("," );
293302 for (Method tempMethod : signatureResults )
294- if (Arrays .equals (paramlist , Arrays .stream (tempMethod .getArgumentTypes ()).map (Type ::toString ).map (e -> e .substring (e .lastIndexOf ("." ) + 1 )).toArray ()))
303+ if (Arrays .equals (paramlist , Arrays .stream (tempMethod .getArgumentTypes ())
304+ .map (Type ::toString )
305+ .map (e -> e .substring (e .lastIndexOf ("." ) + 1 ))
306+ .toArray ()))
295307 return jc .getClassName () + "." + tempMethod .getName () + tempMethod .getSignature ();
296308 }
297309 validateMethodList (signatureResults );
0 commit comments