diff --git a/sootup.callgraph/src/main/java/sootup/callgraph/AbstractCallGraphAlgorithm.java b/sootup.callgraph/src/main/java/sootup/callgraph/AbstractCallGraphAlgorithm.java index be599ea6adc..95ff7c7588b 100644 --- a/sootup.callgraph/src/main/java/sootup/callgraph/AbstractCallGraphAlgorithm.java +++ b/sootup.callgraph/src/main/java/sootup/callgraph/AbstractCallGraphAlgorithm.java @@ -446,30 +446,16 @@ public CallGraph addClass(@Nonnull CallGraph oldCallGraph, @Nonnull JavaClassTyp * @return - MethodSignature of main method. */ public MethodSignature findMainMethod() { - Set classes = new HashSet<>(); /* Set to track the classes to check */ - for (SootClass aClass : view.getClasses()) { - if (!aClass.isLibraryClass()) { - classes.add(aClass); - } - } - - Collection mainMethods = new HashSet<>(); /* Set to store the methods */ - for (SootClass aClass : classes) { - for (SootMethod method : aClass.getMethods()) { - if (method.isStatic() - && method - .getSignature() - .equals( - JavaIdentifierFactory.getInstance() - .getMethodSignature( - aClass.getType(), - "main", - "void", - Collections.singletonList("java.lang.String[]")))) { - mainMethods.add(method); - } - } - } + Collection mainMethods = + view.getClasses() + .filter(aClass -> !aClass.isLibraryClass()) + .flatMap(aClass -> aClass.getMethods().stream()) + .filter( + method -> + method.isStatic() + && JavaIdentifierFactory.getInstance() + .isMainSubSignature(method.getSignature().getSubSignature())) + .collect(Collectors.toSet()); if (mainMethods.size() > 1) { throw new RuntimeException( diff --git a/sootup.core/src/main/java/sootup/core/views/View.java b/sootup.core/src/main/java/sootup/core/views/View.java index 90298498163..14c80c51339 100644 --- a/sootup.core/src/main/java/sootup/core/views/View.java +++ b/sootup.core/src/main/java/sootup/core/views/View.java @@ -22,8 +22,8 @@ * #L% */ -import java.util.Collection; import java.util.Optional; +import java.util.stream.Stream; import javax.annotation.Nonnull; import sootup.core.IdentifierFactory; import sootup.core.model.SootClass; @@ -44,7 +44,7 @@ public interface View { /** Return all classes in the view. */ @Nonnull - Collection getClasses(); + Stream getClasses(); /** * Return a class with given signature. diff --git a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/RuntimeJarConversionTests.java b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/RuntimeJarConversionTests.java index 18110fc5ef3..63b933f07cc 100644 --- a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/RuntimeJarConversionTests.java +++ b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/RuntimeJarConversionTests.java @@ -34,7 +34,7 @@ public void testJarWithDefaultInterceptors() { private static void convertInputLocation(AnalysisInputLocation inputLocation) { JavaView view = new JavaView(Collections.singletonList(inputLocation)); - long classesCount = view.getClasses().size(); + long classesCount = view.getClasses().count(); if (debug) { System.out.println("classes: " + classesCount); } @@ -42,7 +42,7 @@ private static void convertInputLocation(AnalysisInputLocation inputLocation) { long[] progress = {0}; long count = - view.getClasses().stream() + view.getClasses() .peek( c -> { if (!debug) { diff --git a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/Soot1577Test.java b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/Soot1577Test.java index 364ed101d28..606cee291d1 100644 --- a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/Soot1577Test.java +++ b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/Soot1577Test.java @@ -26,8 +26,8 @@ public void test() { JavaView view = new JavaView(inputLocation); - assertEquals(1, view.getClasses().size()); + assertEquals(1, view.getClasses().count()); - view.getClasses().stream().findFirst().get().getMethods().forEach(SootMethod::getBody); + view.getClasses().findFirst().get().getMethods().forEach(SootMethod::getBody); } } diff --git a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/Soot1580Test.java b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/Soot1580Test.java index 1ae14d0d56e..2237e2e9f29 100644 --- a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/Soot1580Test.java +++ b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/Soot1580Test.java @@ -29,7 +29,7 @@ public void test() { JavaView view = new JavaView(Collections.singletonList(inputLocation)); - assertEquals(91, view.getClasses().size()); + assertEquals(91, view.getClasses().count()); ClassType clazzType = JavaIdentifierFactory.getInstance().getClassType("cn.jpush.android.data.f"); diff --git a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/inputlocation/MultiReleaseJarAnalysisInputLocationTest.java b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/inputlocation/MultiReleaseJarAnalysisInputLocationTest.java index d822c17c910..545a37cd77e 100644 --- a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/inputlocation/MultiReleaseJarAnalysisInputLocationTest.java +++ b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/inputlocation/MultiReleaseJarAnalysisInputLocationTest.java @@ -148,7 +148,8 @@ public void multiReleaseJar() { // getClasses List collectedClassesWPrintBody9 = - view_9.getClasses().stream() + view_9 + .getClasses() .map(c -> c.getMethod(printBodyMethodSubSig)) .filter(Optional::isPresent) .map(m -> m.get().getBody().toString()) @@ -157,7 +158,8 @@ public void multiReleaseJar() { assertTrue(collectedClassesWPrintBody9.get(0).contains("java 9")); List collectedClassesWPrintBody10 = - view_10.getClasses().stream() + view_10 + .getClasses() .map(c -> c.getMethod(printBodyMethodSubSig)) .filter(Optional::isPresent) .map(m -> m.get().getBody().toString()) diff --git a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/inputlocation/PathBasedAnalysisInputLocationTest.java b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/inputlocation/PathBasedAnalysisInputLocationTest.java index 29b03486384..49f59bc2e9e 100644 --- a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/inputlocation/PathBasedAnalysisInputLocationTest.java +++ b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/inputlocation/PathBasedAnalysisInputLocationTest.java @@ -123,7 +123,7 @@ public void testClassInWar() { // Get the view JavaView view = new JavaView(new JavaClassPathAnalysisInputLocation(warFile)); - assertEquals(19, view.getClasses().size()); + assertEquals(19, view.getClasses().count()); // Create java class signature ClassType utilsClassSignature = view.getIdentifierFactory().getClassType("Employee", "ds"); @@ -215,11 +215,7 @@ public void testInputLocationLibraryMode() { Collection classes = new HashSet<>(); // Set to track the classes to check - for (SootClass aClass : view.getClasses()) { - if (!aClass.isLibraryClass()) { - classes.add(aClass); - } - } + view.getClasses().filter(aClass -> !aClass.isLibraryClass()).forEach(classes::add); assertEquals(0, classes.size(), "User Defined class found, expected none"); } diff --git a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/inputlocation/RandomJarTest.java b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/inputlocation/RandomJarTest.java index e0d7101b855..6d8207f0bba 100644 --- a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/inputlocation/RandomJarTest.java +++ b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/inputlocation/RandomJarTest.java @@ -6,6 +6,7 @@ import java.io.IOException; import java.io.PrintWriter; import java.util.Collection; +import java.util.stream.Collectors; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import sootup.core.inputlocation.AnalysisInputLocation; @@ -99,7 +100,7 @@ public void writeTestMetrics(TestMetrics testMetrics) { private Collection getClasses(JavaView view) { try { - return view.getClasses(); + return view.getClasses().collect(Collectors.toList()); } catch (Exception e) { throw new RuntimeException("Error while getting class list", e); } diff --git a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/interceptors/AggregatorTest.java b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/interceptors/AggregatorTest.java index eec8aa1b219..a845dcba242 100644 --- a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/interceptors/AggregatorTest.java +++ b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/interceptors/AggregatorTest.java @@ -194,8 +194,7 @@ public void testIssue739() { final ClassType classType = view.getIdentifierFactory().getClassType("Issue739_Aggregator"); assertTrue(view.getClass(classType).isPresent()); - for (JavaSootMethod javaSootMethod : - view.getClasses().stream().findFirst().get().getMethods()) { + for (JavaSootMethod javaSootMethod : view.getClasses().findFirst().get().getMethods()) { final Body body = javaSootMethod.getBody(); } } @@ -215,8 +214,7 @@ public void testIssue911() { final ClassType classType = view.getIdentifierFactory().getClassType("Issue911_Aggregator"); assertTrue(view.getClass(classType).isPresent()); - for (JavaSootMethod javaSootMethod : - view.getClasses().stream().findFirst().get().getMethods()) { + for (JavaSootMethod javaSootMethod : view.getClasses().findFirst().get().getMethods()) { final Body body = javaSootMethod.getBody(); } } diff --git a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/interceptors/LocalSplitterTest.java b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/interceptors/LocalSplitterTest.java index 0c4dac0332b..5c647256004 100644 --- a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/interceptors/LocalSplitterTest.java +++ b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/interceptors/LocalSplitterTest.java @@ -60,7 +60,7 @@ public void JRT() { // ~200_000 methods view.getClasses() - .parallelStream() + .parallel() .flatMap(clazz -> clazz.getMethods().stream()) .filter(method -> !method.isAbstract() && !method.isNative()) .forEach(SootMethod::getBody); diff --git a/sootup.java.core/src/main/java/sootup/java/core/views/JavaView.java b/sootup.java.core/src/main/java/sootup/java/core/views/JavaView.java index 8afe18bc4af..5add98e949e 100644 --- a/sootup.java.core/src/main/java/sootup/java/core/views/JavaView.java +++ b/sootup.java.core/src/main/java/sootup/java/core/views/JavaView.java @@ -22,11 +22,10 @@ * #L% */ -import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; +import java.util.stream.Stream; import javax.annotation.Nonnull; import sootup.core.cache.ClassCache; import sootup.core.cache.FullCache; @@ -82,20 +81,17 @@ protected JavaView( /** Resolves all classes that are part of the view and stores them in the cache. */ @Override @Nonnull - public synchronized Collection getClasses() { + public synchronized Stream getClasses() { if (isFullyResolved && cache instanceof FullCache) { - return cache.getClasses().stream() - .map(clazz -> (JavaSootClass) clazz) - .collect(Collectors.toList()); + return cache.getClasses().stream().map(clazz -> (JavaSootClass) clazz); } - Collection resolvedClasses = + Stream resolvedClasses = inputLocations.stream() .flatMap(location -> location.getClassSources(this).stream()) .map(this::buildClassFrom) .filter(Optional::isPresent) - .map(Optional::get) - .collect(Collectors.toList()); + .map(Optional::get); isFullyResolved = true; diff --git a/sootup.java.core/src/test/java/sootup/java/core/views/JavaViewTest.java b/sootup.java.core/src/test/java/sootup/java/core/views/JavaViewTest.java index 23dfc9b6f39..0f5821607f1 100644 --- a/sootup.java.core/src/test/java/sootup/java/core/views/JavaViewTest.java +++ b/sootup.java.core/src/test/java/sootup/java/core/views/JavaViewTest.java @@ -2,10 +2,10 @@ import static org.junit.jupiter.api.Assertions.*; -import java.util.Collection; import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; +import java.util.stream.Stream; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Tag; @@ -71,12 +71,12 @@ public void testResolveUndefinedClassAfterAllResolved() { @Disabled public void testResolveAll() { - Collection classes = this.view.getClasses(); + Stream classes = this.view.getClasses(); - assertEquals(classes.size(), this.signatures.size()); + assertEquals(classes.count(), this.signatures.size()); assertEquals( - classes.stream() + classes .map(AbstractClass::getType) .sorted(Comparator.comparing(Type::toString)) .collect(Collectors.toList()), diff --git a/sootup.java.sourcecode/src/test/java/sootup/java/sourcecode/inputlocation/JavaSourcePathNamespaceTest.java b/sootup.java.sourcecode/src/test/java/sootup/java/sourcecode/inputlocation/JavaSourcePathNamespaceTest.java index eb2f5620666..183f29b8bc7 100644 --- a/sootup.java.sourcecode/src/test/java/sootup/java/sourcecode/inputlocation/JavaSourcePathNamespaceTest.java +++ b/sootup.java.sourcecode/src/test/java/sootup/java/sourcecode/inputlocation/JavaSourcePathNamespaceTest.java @@ -62,7 +62,7 @@ public void testGetClassSources() { final JavaView view = new JavaView(inputLocation); Collection classSources = - view.getClasses().stream().map(jsc -> jsc.getClassSource()).collect(Collectors.toList()); + view.getClasses().map(jsc -> jsc.getClassSource()).collect(Collectors.toList()); ClassType type = new JavaClassType("Array1", PackageName.DEFAULT_PACKAGE); Optional optionalFoundType = @@ -91,11 +91,7 @@ public void testInputSourcePathLibraryMode() { JavaView view = new JavaView(inputLocation); Set classes = new HashSet<>(); // Set to track the classes to check - for (SootClass aClass : view.getClasses()) { - if (!aClass.isLibraryClass()) { - classes.add(aClass); - } - } + view.getClasses().filter(aClass -> !aClass.isLibraryClass()).forEach(classes::add); assertEquals(0, classes.size(), "User Defined class found, expected none"); } diff --git a/sootup.jimple.parser/src/main/java/sootup/jimple/parser/JimpleView.java b/sootup.jimple.parser/src/main/java/sootup/jimple/parser/JimpleView.java index 17a964b742c..5d07861501b 100644 --- a/sootup.jimple.parser/src/main/java/sootup/jimple/parser/JimpleView.java +++ b/sootup.jimple.parser/src/main/java/sootup/jimple/parser/JimpleView.java @@ -27,6 +27,7 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; +import java.util.stream.Stream; import javax.annotation.Nonnull; import sootup.core.IdentifierFactory; import sootup.core.cache.ClassCache; @@ -77,8 +78,8 @@ public JimpleView( @Override @Nonnull - public synchronized Collection getClasses() { - return getAbstractClassSources(); + public synchronized Stream getClasses() { + return getAbstractClassSources().stream(); } @Nonnull diff --git a/sootup.qilin/src/main/java/qilin/core/PTAScene.java b/sootup.qilin/src/main/java/qilin/core/PTAScene.java index 97fee24201d..8ea9ecad168 100644 --- a/sootup.qilin/src/main/java/qilin/core/PTAScene.java +++ b/sootup.qilin/src/main/java/qilin/core/PTAScene.java @@ -95,13 +95,11 @@ public SootMethod getMethod(String methodSignature) { } public Collection getApplicationClasses() { - Collection classes = view.getClasses(); - return classes.stream().filter(SootClass::isApplicationClass).collect(Collectors.toSet()); + return view.getClasses().filter(SootClass::isApplicationClass).collect(Collectors.toSet()); } public Collection getLibraryClasses() { - Collection classes = view.getClasses(); - return classes.stream().filter(SootClass::isLibraryClass).collect(Collectors.toSet()); + return view.getClasses().filter(SootClass::isLibraryClass).collect(Collectors.toSet()); } public boolean containsMethod(String methodSignature) { @@ -117,7 +115,7 @@ public boolean containsField(String fieldSignature) { } public Collection getClasses() { - return view.getClasses(); + return view.getClasses().collect(Collectors.toList()); } public Collection getPhantomClasses() { diff --git a/sootup.qilin/src/main/java/qilin/core/VirtualCalls.java b/sootup.qilin/src/main/java/qilin/core/VirtualCalls.java index ac4d39f5618..1c8a4f3e68c 100644 --- a/sootup.qilin/src/main/java/qilin/core/VirtualCalls.java +++ b/sootup.qilin/src/main/java/qilin/core/VirtualCalls.java @@ -44,7 +44,7 @@ public class VirtualCalls { public VirtualCalls(View view) { this.view = view; - this.typeToVtbl = DataFactory.createMap(view.getClasses().size()); + this.typeToVtbl = DataFactory.createMap((int) view.getClasses().count()); } public SootMethod resolveSpecial( diff --git a/sootup.qilin/src/main/java/qilin/core/builder/CallGraphBuilder.java b/sootup.qilin/src/main/java/qilin/core/builder/CallGraphBuilder.java index e388732bb69..8bb391570df 100644 --- a/sootup.qilin/src/main/java/qilin/core/builder/CallGraphBuilder.java +++ b/sootup.qilin/src/main/java/qilin/core/builder/CallGraphBuilder.java @@ -72,7 +72,7 @@ public CallGraphBuilder(PTA pta) { this.ptaScene = pta.getScene(); ptaScene.setCallGraph(new OnFlyCallGraph()); this.virtualCalls = new VirtualCalls(ptaScene.getView()); - receiverToSites = DataFactory.createMap(ptaScene.getView().getClasses().size()); + receiverToSites = DataFactory.createMap((int) ptaScene.getView().getClasses().count()); methodToInvokeStmt = DataFactory.createMap(); reachMethods = DataFactory.createSet(); calledges = DataFactory.createSet(); diff --git a/sootup.qilin/src/main/java/qilin/core/builder/ExceptionHandler.java b/sootup.qilin/src/main/java/qilin/core/builder/ExceptionHandler.java index 986efabc42f..86622921b43 100644 --- a/sootup.qilin/src/main/java/qilin/core/builder/ExceptionHandler.java +++ b/sootup.qilin/src/main/java/qilin/core/builder/ExceptionHandler.java @@ -40,7 +40,7 @@ public class ExceptionHandler { public ExceptionHandler(PTA pta) { this.pta = pta; this.pag = pta.getPag(); - this.throwNodeToSites = DataFactory.createMap(pta.getView().getClasses().size()); + this.throwNodeToSites = DataFactory.createMap((int) pta.getView().getClasses().count()); } public Collection throwSitesLookUp(VarNode throwNode) { diff --git a/sootup.qilin/src/main/java/qilin/core/builder/FakeMainFactory.java b/sootup.qilin/src/main/java/qilin/core/builder/FakeMainFactory.java index faa7846ca95..05ec0e96f23 100644 --- a/sootup.qilin/src/main/java/qilin/core/builder/FakeMainFactory.java +++ b/sootup.qilin/src/main/java/qilin/core/builder/FakeMainFactory.java @@ -20,7 +20,6 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.Collections; import java.util.EnumSet; import java.util.Iterator; @@ -348,10 +347,7 @@ public List all() { /** Returns a list of all static initializers. */ public List clinits() { List ret = new ArrayList<>(); - Collection classes = view.getClasses(); - for (SootClass cl : classes) { - addMethod(ret, cl, sigClinit); - } + view.getClasses().forEach(cl -> addMethod(ret, cl, sigClinit)); return ret; } diff --git a/sootup.qilin/src/main/java/qilin/stat/CallGraphStat.java b/sootup.qilin/src/main/java/qilin/stat/CallGraphStat.java index eeaffa6692e..8ba33912909 100644 --- a/sootup.qilin/src/main/java/qilin/stat/CallGraphStat.java +++ b/sootup.qilin/src/main/java/qilin/stat/CallGraphStat.java @@ -18,7 +18,6 @@ package qilin.stat; -import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.Set; @@ -31,7 +30,6 @@ import qilin.core.pag.ContextMethod; import qilin.core.pag.ContextVarNode; import qilin.core.pag.LocalVarNode; -import sootup.core.model.SootClass; import sootup.core.model.SootMethod; public class CallGraphStat implements AbstractStat { @@ -70,10 +68,8 @@ public CallGraphStat(PTA pta) { private void init() { // stat method numbers - Collection clazzs = pta.getView().getClasses(); - for (SootClass clazz : clazzs) { - allMethods += clazz.getMethods().size(); - } + allMethods += + pta.getView().getClasses().map(clazz -> clazz.getMethods().size()).reduce(0, Integer::sum); // OnFlyCallGraph csCallGraph = pta.getCgb().getCallGraph(); CSCallEdges = csCallGraph.size(); diff --git a/sootup.tests/src/test/java/sootup/tests/CacheTest.java b/sootup.tests/src/test/java/sootup/tests/CacheTest.java index a7dd764ade1..843bac497c0 100644 --- a/sootup.tests/src/test/java/sootup/tests/CacheTest.java +++ b/sootup.tests/src/test/java/sootup/tests/CacheTest.java @@ -49,7 +49,7 @@ public void fullCacheTest() { view.getClass(utilsOperationClassType); assertEquals(2, view.getCachedClassesCount()); - view.getClasses(); + view.getClasses().count(); assertEquals(6, view.getCachedClassesCount()); } @@ -72,7 +72,7 @@ public void lruCacheTest() { assertEquals(1, view.getCachedClassesCount()); JavaView newView = new JavaView(inputLocations, new LRUCacheProvider()); - newView.getClasses(); + newView.getClasses().count(); assertEquals(6, newView.getCachedClassesCount()); } } diff --git a/sootup.tests/src/test/java/sootup/tests/MutableSootClientTest.java b/sootup.tests/src/test/java/sootup/tests/MutableSootClientTest.java index 4ceb62d1483..7633b063720 100644 --- a/sootup.tests/src/test/java/sootup/tests/MutableSootClientTest.java +++ b/sootup.tests/src/test/java/sootup/tests/MutableSootClientTest.java @@ -54,10 +54,10 @@ public void setupMutableView() { */ @Test public void classRemovalTest() { - int classesBeforeSize = mv.getClasses().size(); + long classesBeforeSize = mv.getClasses().count(); ClassType classType = mv.getIdentifierFactory().getClassType("utils.Operations"); mv.removeClass(classType); - int classesAfterSize = mv.getClasses().size(); + long classesAfterSize = mv.getClasses().count(); assertEquals(classesBeforeSize, classesAfterSize + 1); } @@ -85,9 +85,9 @@ public void classAdditionTest() { Collections.emptySet(), Collections.emptySet()); - int classesBeforeSize = mv.getClasses().size(); + long classesBeforeSize = mv.getClasses().count(); mv.addClass(newClass.buildClass(SourceType.Application)); - int classesAfterSize = mv.getClasses().size(); + long classesAfterSize = mv.getClasses().count(); assertEquals(classesBeforeSize, classesAfterSize - 1); } diff --git a/sootup.tests/src/test/java/sootup/tests/validator/CheckInitValidatorTest.java b/sootup.tests/src/test/java/sootup/tests/validator/CheckInitValidatorTest.java index 4da64924568..4ac3dd4a507 100644 --- a/sootup.tests/src/test/java/sootup/tests/validator/CheckInitValidatorTest.java +++ b/sootup.tests/src/test/java/sootup/tests/validator/CheckInitValidatorTest.java @@ -60,11 +60,7 @@ public PackageName getPackageName() { classes = new HashSet<>(); // Set to track the classes to check - for (SootClass aClass : jimpleView.getClasses()) { - if (!aClass.isLibraryClass()) { - classes.add(aClass); - } - } + jimpleView.getClasses().forEach(classes::add); } @Test diff --git a/sootup.tests/src/test/java/sootup/tests/validator/FieldRefValidatorTest.java b/sootup.tests/src/test/java/sootup/tests/validator/FieldRefValidatorTest.java index c9a8da0826f..ba9493f275c 100644 --- a/sootup.tests/src/test/java/sootup/tests/validator/FieldRefValidatorTest.java +++ b/sootup.tests/src/test/java/sootup/tests/validator/FieldRefValidatorTest.java @@ -61,11 +61,7 @@ public PackageName getPackageName() { classes = new HashSet<>(); // Set to track the classes to check - for (SootClass aClass : jimpleView.getClasses()) { - if (!aClass.isLibraryClass()) { - classes.add(aClass); - } - } + jimpleView.getClasses().forEach(classes::add); } @Test diff --git a/sootup.tests/src/test/java/sootup/tests/validator/LocalsValidatorTest.java b/sootup.tests/src/test/java/sootup/tests/validator/LocalsValidatorTest.java index 468f060a900..524b33f70f8 100644 --- a/sootup.tests/src/test/java/sootup/tests/validator/LocalsValidatorTest.java +++ b/sootup.tests/src/test/java/sootup/tests/validator/LocalsValidatorTest.java @@ -59,11 +59,7 @@ public PackageName getPackageName() { classes = new HashSet<>(); // Set to track the classes to check - for (SootClass aClass : jimpleView.getClasses()) { - if (!aClass.isLibraryClass()) { - classes.add(aClass); - } - } + jimpleView.getClasses().forEach(classes::add); } @Test diff --git a/sootup.tests/src/test/java/sootup/tests/validator/NewValidatorTest.java b/sootup.tests/src/test/java/sootup/tests/validator/NewValidatorTest.java index 5b7a573bb3b..83b3b4cbc8a 100644 --- a/sootup.tests/src/test/java/sootup/tests/validator/NewValidatorTest.java +++ b/sootup.tests/src/test/java/sootup/tests/validator/NewValidatorTest.java @@ -61,11 +61,7 @@ public PackageName getPackageName() { classes = new HashSet<>(); // Set to track the classes to check - for (SootClass aClass : view.getClasses()) { - if (!aClass.isLibraryClass()) { - classes.add(aClass); - } - } + view.getClasses().forEach(classes::add); } @Test