From 331b5cf94575217245449388f3d910446e138ff6 Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 22 Aug 2024 14:57:36 +0200 Subject: [PATCH 1/3] Issue 979 fixed --- docs/callgraphs.md | 2 +- docs/typehierarchy.md | 2 +- .../icfg/ICFGDotExporterTest.java | 10 +-- .../interprocedural/ifds/CGEdgeUtilTest.java | 4 +- .../ifds/IFDSTaintTestSetUp.java | 4 +- .../sootup/callgraph/CallGraphTestBase.java | 6 +- .../callgraph/ConcreteDispatchTest.java | 4 +- .../InstantiateClassValueVisitorTest.java | 4 +- .../classhierarchy/ClassHierarchy.java | 4 +- .../DefaultRTJarAnalysisInputLocation.java | 2 +- .../DefaultRuntimeAnalysisInputLocation.java | 66 +++++++++++++++++++ .../bytecode/RuntimeJarConversionTests.java | 10 +-- .../frontend/AsmMethodSourceTest.java | 4 +- .../PathBasedAnalysisInputLocationTest.java | 4 +- .../typeresolving/BytecodeHierarchyTest.java | 5 +- .../typeresolving/TypeAssignerTestSuite.java | 4 +- .../test/java/sootup/tests/CallGraphTest.java | 4 +- .../HierarchyComparatorTest.java | 4 +- 18 files changed, 105 insertions(+), 38 deletions(-) create mode 100644 sootup.java.bytecode/src/main/java/sootup/java/bytecode/inputlocation/DefaultRuntimeAnalysisInputLocation.java diff --git a/docs/callgraphs.md b/docs/callgraphs.md index a28fb696935..4103da9fdfc 100644 --- a/docs/callgraphs.md +++ b/docs/callgraphs.md @@ -13,7 +13,7 @@ Below, we show how to create a type hierarchy: String cpString = "src/test/resources/Callgraph/binary"; List inputLocations = new ArrayList(); inputLocations.add(new JavaClassPathAnalysisInputLocation(cpStr)); - inputLocations.add(new DefaultRTJarAnalysisInputLocation()); + inputLocations.add(new DefaultRuntimeAnalysisInputLocation()); JavaView view = new JavaView(inputLocations); ``` diff --git a/docs/typehierarchy.md b/docs/typehierarchy.md index 7c07b3c983d..ab758863f85 100644 --- a/docs/typehierarchy.md +++ b/docs/typehierarchy.md @@ -9,7 +9,7 @@ The TypeHierarchy models the relationship of Classes or Interfaces of a OOP prog String cpString = "src/test/resources/Callgraph/binary"; List inputLocations = new ArrayList(); inputLocations.add(new JavaClassPathAnalysisInputLocation(cpStr)); - inputLocations.add(new DefaultRTJarAnalysisInputLocation()); + inputLocations.add(new DefaultRuntimeAnalysisInputLocation()); JavaView view = new JavaView(inputLocations); TypeHierarchy typehierarchy = view.getTypeHierarchy(); diff --git a/sootup.analysis/src/test/java/sootup/analysis/interprocedural/icfg/ICFGDotExporterTest.java b/sootup.analysis/src/test/java/sootup/analysis/interprocedural/icfg/ICFGDotExporterTest.java index dd1363c95ee..cf0e20e10c5 100644 --- a/sootup.analysis/src/test/java/sootup/analysis/interprocedural/icfg/ICFGDotExporterTest.java +++ b/sootup.analysis/src/test/java/sootup/analysis/interprocedural/icfg/ICFGDotExporterTest.java @@ -16,7 +16,7 @@ import sootup.core.model.SootClass; import sootup.core.model.SootMethod; import sootup.core.signatures.MethodSignature; -import sootup.java.bytecode.inputlocation.DefaultRTJarAnalysisInputLocation; +import sootup.java.bytecode.inputlocation.DefaultRuntimeAnalysisInputLocation; import sootup.java.bytecode.inputlocation.JavaClassPathAnalysisInputLocation; import sootup.java.core.JavaIdentifierFactory; import sootup.java.core.types.JavaClassType; @@ -39,7 +39,7 @@ public CallGraph loadCallGraph(JavaView view) { @Test public void ICFGDotExportTest() { List inputLocations = new ArrayList<>(); - inputLocations.add(new DefaultRTJarAnalysisInputLocation()); + inputLocations.add(new DefaultRuntimeAnalysisInputLocation()); inputLocations.add(new JavaClassPathAnalysisInputLocation("src/test/resources/icfg/binary")); view = new JavaView(inputLocations); @@ -74,7 +74,7 @@ public void ICFGDotExportTest() { @Test public void ICFGDotExportTest2() { List inputLocations = new ArrayList<>(); - inputLocations.add(new DefaultRTJarAnalysisInputLocation()); + inputLocations.add(new DefaultRuntimeAnalysisInputLocation()); inputLocations.add(new JavaClassPathAnalysisInputLocation("src/test/resources/icfg/binary")); view = new JavaView(inputLocations); @@ -109,7 +109,7 @@ public void ICFGDotExportTest2() { @Test public void ICFGArrayListDotExport() { List inputLocations = new ArrayList<>(); - inputLocations.add(new DefaultRTJarAnalysisInputLocation()); + inputLocations.add(new DefaultRuntimeAnalysisInputLocation()); inputLocations.add(new JavaClassPathAnalysisInputLocation("src/test/resources/icfg/binary")); view = new JavaView(inputLocations); @@ -136,7 +136,7 @@ public void ICFGArrayListDotExport() { @Test public void ICFGInterfaceDotExport() { List inputLocations = new ArrayList<>(); - inputLocations.add(new DefaultRTJarAnalysisInputLocation()); + inputLocations.add(new DefaultRuntimeAnalysisInputLocation()); inputLocations.add(new JavaClassPathAnalysisInputLocation("src/test/resources/icfg/binary")); view = new JavaView(inputLocations); diff --git a/sootup.analysis/src/test/java/sootup/analysis/interprocedural/ifds/CGEdgeUtilTest.java b/sootup.analysis/src/test/java/sootup/analysis/interprocedural/ifds/CGEdgeUtilTest.java index d475614fa74..94101aff547 100644 --- a/sootup.analysis/src/test/java/sootup/analysis/interprocedural/ifds/CGEdgeUtilTest.java +++ b/sootup.analysis/src/test/java/sootup/analysis/interprocedural/ifds/CGEdgeUtilTest.java @@ -39,7 +39,7 @@ import sootup.core.types.PrimitiveType; import sootup.core.types.Type; import sootup.core.util.printer.StmtPrinter; -import sootup.java.bytecode.inputlocation.DefaultRTJarAnalysisInputLocation; +import sootup.java.bytecode.inputlocation.DefaultRuntimeAnalysisInputLocation; import sootup.java.core.JavaIdentifierFactory; import sootup.java.core.types.JavaClassType; import sootup.java.core.views.JavaView; @@ -138,7 +138,7 @@ public void testGetCallEdges() { } List inputLocations = new ArrayList<>(); - inputLocations.add(new DefaultRTJarAnalysisInputLocation()); + inputLocations.add(new DefaultRuntimeAnalysisInputLocation()); inputLocations.add(new JavaSourcePathAnalysisInputLocation("src/test/resources/callgraph/")); JavaView view = new JavaView(inputLocations); diff --git a/sootup.analysis/src/test/java/sootup/analysis/interprocedural/ifds/IFDSTaintTestSetUp.java b/sootup.analysis/src/test/java/sootup/analysis/interprocedural/ifds/IFDSTaintTestSetUp.java index 5f92f37de25..eab39f94676 100644 --- a/sootup.analysis/src/test/java/sootup/analysis/interprocedural/ifds/IFDSTaintTestSetUp.java +++ b/sootup.analysis/src/test/java/sootup/analysis/interprocedural/ifds/IFDSTaintTestSetUp.java @@ -36,7 +36,7 @@ import sootup.core.model.SootMethod; import sootup.core.model.SourceType; import sootup.core.signatures.MethodSignature; -import sootup.java.bytecode.inputlocation.DefaultRTJarAnalysisInputLocation; +import sootup.java.bytecode.inputlocation.DefaultRuntimeAnalysisInputLocation; import sootup.java.bytecode.inputlocation.JavaClassPathAnalysisInputLocation; import sootup.java.core.JavaIdentifierFactory; import sootup.java.core.types.JavaClassType; @@ -78,7 +78,7 @@ private void runAnalysis() { */ private void setupSoot(String targetTestClassName) { List inputLocations = new ArrayList<>(); - inputLocations.add(new DefaultRTJarAnalysisInputLocation()); + inputLocations.add(new DefaultRuntimeAnalysisInputLocation()); inputLocations.add( new JavaClassPathAnalysisInputLocation( "src/test/resources/taint/binary", SourceType.Application, Collections.emptyList())); diff --git a/sootup.callgraph/src/test/java/sootup/callgraph/CallGraphTestBase.java b/sootup.callgraph/src/test/java/sootup/callgraph/CallGraphTestBase.java index ada8ad12c69..03cd9305c03 100644 --- a/sootup.callgraph/src/test/java/sootup/callgraph/CallGraphTestBase.java +++ b/sootup.callgraph/src/test/java/sootup/callgraph/CallGraphTestBase.java @@ -20,7 +20,7 @@ import sootup.core.model.SourceType; import sootup.core.signatures.MethodSignature; import sootup.core.types.ClassType; -import sootup.java.bytecode.inputlocation.DefaultRTJarAnalysisInputLocation; +import sootup.java.bytecode.inputlocation.DefaultRuntimeAnalysisInputLocation; import sootup.java.bytecode.inputlocation.JavaClassPathAnalysisInputLocation; import sootup.java.core.JavaIdentifierFactory; import sootup.java.core.types.JavaClassType; @@ -45,7 +45,7 @@ private JavaView createViewForClassPath(String classPath) { private JavaView createViewForClassPath(String classPath, boolean useSourceCodeFrontend) { List inputLocations = new ArrayList<>(); - inputLocations.add(new DefaultRTJarAnalysisInputLocation()); + inputLocations.add(new DefaultRuntimeAnalysisInputLocation()); if (useSourceCodeFrontend) { inputLocations.add(new JavaSourcePathAnalysisInputLocation(classPath)); } else { @@ -1053,7 +1053,7 @@ public void testStopAtLibraryClass() { String classPath = "src/test/resources/callgraph/Library/binary/"; List inputLocations = new ArrayList<>(); - inputLocations.add(new DefaultRTJarAnalysisInputLocation()); + inputLocations.add(new DefaultRuntimeAnalysisInputLocation()); inputLocations.add( new JavaClassPathAnalysisInputLocation(classPath + "application/", SourceType.Application)); inputLocations.add( diff --git a/sootup.callgraph/src/test/java/sootup/callgraph/ConcreteDispatchTest.java b/sootup.callgraph/src/test/java/sootup/callgraph/ConcreteDispatchTest.java index 8af3a84caa0..e793244b59d 100644 --- a/sootup.callgraph/src/test/java/sootup/callgraph/ConcreteDispatchTest.java +++ b/sootup.callgraph/src/test/java/sootup/callgraph/ConcreteDispatchTest.java @@ -13,7 +13,7 @@ import sootup.core.inputlocation.AnalysisInputLocation; import sootup.core.signatures.MethodSignature; import sootup.core.types.ClassType; -import sootup.java.bytecode.inputlocation.DefaultRTJarAnalysisInputLocation; +import sootup.java.bytecode.inputlocation.DefaultRuntimeAnalysisInputLocation; import sootup.java.bytecode.inputlocation.JavaClassPathAnalysisInputLocation; import sootup.java.core.views.JavaView; @@ -32,7 +32,7 @@ public static void setUp() { inputLocations.add( new JavaClassPathAnalysisInputLocation( "src/test/resources/callgraph/ConcreteDispatch/binary")); - inputLocations.add(new DefaultRTJarAnalysisInputLocation()); + inputLocations.add(new DefaultRuntimeAnalysisInputLocation()); view = new JavaView(inputLocations); } diff --git a/sootup.callgraph/src/test/java/sootup/callgraph/InstantiateClassValueVisitorTest.java b/sootup.callgraph/src/test/java/sootup/callgraph/InstantiateClassValueVisitorTest.java index 1720cf190af..6067adeb300 100644 --- a/sootup.callgraph/src/test/java/sootup/callgraph/InstantiateClassValueVisitorTest.java +++ b/sootup.callgraph/src/test/java/sootup/callgraph/InstantiateClassValueVisitorTest.java @@ -63,7 +63,7 @@ import sootup.core.types.ClassType; import sootup.core.types.PrimitiveType; import sootup.core.views.View; -import sootup.java.bytecode.inputlocation.DefaultRTJarAnalysisInputLocation; +import sootup.java.bytecode.inputlocation.DefaultRuntimeAnalysisInputLocation; import sootup.java.core.language.JavaJimple; import sootup.java.core.views.JavaView; @@ -71,7 +71,7 @@ public class InstantiateClassValueVisitorTest { @Test public void testVisitor() { - View view = new JavaView(new DefaultRTJarAnalysisInputLocation()); + View view = new JavaView(new DefaultRuntimeAnalysisInputLocation()); IdentifierFactory identifierFactory = view.getIdentifierFactory(); InstantiateClassValueVisitor instantiateVisitor = new InstantiateClassValueVisitor(); diff --git a/sootup.examples/src/test/java/sootup/examples/classhierarchy/ClassHierarchy.java b/sootup.examples/src/test/java/sootup/examples/classhierarchy/ClassHierarchy.java index f1a4ecee003..b9ab9543096 100644 --- a/sootup.examples/src/test/java/sootup/examples/classhierarchy/ClassHierarchy.java +++ b/sootup.examples/src/test/java/sootup/examples/classhierarchy/ClassHierarchy.java @@ -12,7 +12,7 @@ import sootup.core.inputlocation.AnalysisInputLocation; import sootup.core.typehierarchy.ViewTypeHierarchy; import sootup.core.types.ClassType; -import sootup.java.bytecode.inputlocation.DefaultRTJarAnalysisInputLocation; +import sootup.java.bytecode.inputlocation.DefaultRuntimeAnalysisInputLocation; import sootup.java.bytecode.inputlocation.JavaClassPathAnalysisInputLocation; import sootup.java.core.JavaIdentifierFactory; import sootup.java.core.types.JavaClassType; @@ -39,7 +39,7 @@ public void test() { List inputLocations = new ArrayList<>(); inputLocations.add( new JavaClassPathAnalysisInputLocation("src/test/resources/ClassHierarchy/binary")); - inputLocations.add(new DefaultRTJarAnalysisInputLocation()); // add rt.jar + inputLocations.add(new DefaultRuntimeAnalysisInputLocation()); // add rt.jar JavaView view = new JavaView(inputLocations); diff --git a/sootup.java.bytecode/src/main/java/sootup/java/bytecode/inputlocation/DefaultRTJarAnalysisInputLocation.java b/sootup.java.bytecode/src/main/java/sootup/java/bytecode/inputlocation/DefaultRTJarAnalysisInputLocation.java index c913764fc52..4c4570185d5 100644 --- a/sootup.java.bytecode/src/main/java/sootup/java/bytecode/inputlocation/DefaultRTJarAnalysisInputLocation.java +++ b/sootup.java.bytecode/src/main/java/sootup/java/bytecode/inputlocation/DefaultRTJarAnalysisInputLocation.java @@ -35,7 +35,7 @@ *

Info: This only works if you are running java 8 or older. Otherwise use {@link * JrtFileSystemAnalysisInputLocation}. */ -public class DefaultRTJarAnalysisInputLocation extends ArchiveBasedAnalysisInputLocation { +class DefaultRTJarAnalysisInputLocation extends ArchiveBasedAnalysisInputLocation { public DefaultRTJarAnalysisInputLocation() { this(SourceType.Library); diff --git a/sootup.java.bytecode/src/main/java/sootup/java/bytecode/inputlocation/DefaultRuntimeAnalysisInputLocation.java b/sootup.java.bytecode/src/main/java/sootup/java/bytecode/inputlocation/DefaultRuntimeAnalysisInputLocation.java new file mode 100644 index 00000000000..6dedae11b3f --- /dev/null +++ b/sootup.java.bytecode/src/main/java/sootup/java/bytecode/inputlocation/DefaultRuntimeAnalysisInputLocation.java @@ -0,0 +1,66 @@ +package sootup.java.bytecode.inputlocation; + +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import javax.annotation.Nonnull; +import sootup.core.frontend.SootClassSource; +import sootup.core.inputlocation.AnalysisInputLocation; +import sootup.core.model.SourceType; +import sootup.core.transform.BodyInterceptor; +import sootup.core.types.ClassType; +import sootup.core.views.View; +import sootup.java.core.interceptors.BytecodeBodyInterceptors; + +// Frage: müssten nicht alle Vorkommen von DefaultRT und JrtFile durch DefaultRuntime ersetzt +// werden, wenn DefaultRT mit DefaultRuntime ersetzt wird? +public class DefaultRuntimeAnalysisInputLocation implements AnalysisInputLocation { + + private final AnalysisInputLocation instance; + + public DefaultRuntimeAnalysisInputLocation() { + this(SourceType.Library); + } + + public DefaultRuntimeAnalysisInputLocation(@Nonnull SourceType srcType) { + // doesn't match with the second DefaultRTJarAnalysisInputLocation constructor + // shouldn't be problematic, cause of the third constructor + this(srcType, BytecodeBodyInterceptors.Default.getBodyInterceptors()); + } + + public DefaultRuntimeAnalysisInputLocation( + @Nonnull SourceType srcType, @Nonnull List bodyInterceptors) { + String version = System.getProperty("java.version"); + + if (version.startsWith("1")) { + instance = new DefaultRTJarAnalysisInputLocation(srcType, bodyInterceptors); + } else { + instance = new JrtFileSystemAnalysisInputLocation(srcType, bodyInterceptors); + } + } + + @Nonnull + @Override + public Optional getClassSource( + @Nonnull ClassType type, @Nonnull View view) { + return instance.getClassSource(type, view); + } + + @Nonnull + @Override + public Collection getClassSources(@Nonnull View view) { + return instance.getClassSources(view); + } + + @Nonnull + @Override + public SourceType getSourceType() { + return instance.getSourceType(); + } + + @Nonnull + @Override + public List getBodyInterceptors() { + return instance.getBodyInterceptors(); + } +} 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 fcf56f32ac0..f74f553bb54 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 @@ -20,8 +20,7 @@ import sootup.core.transform.RunTimeBodyInterceptor; import sootup.core.util.DotExporter; import sootup.core.util.Utils; -import sootup.java.bytecode.inputlocation.DefaultRTJarAnalysisInputLocation; -import sootup.java.bytecode.inputlocation.JavaClassPathAnalysisInputLocation; +import sootup.java.bytecode.inputlocation.DefaultRuntimeAnalysisInputLocation; import sootup.java.core.interceptors.BytecodeBodyInterceptors; import sootup.java.core.interceptors.CopyPropagator; import sootup.java.core.interceptors.DeadAssignmentEliminator; @@ -34,7 +33,8 @@ public class RuntimeJarConversionTests { @Test public void testJarWithDefaultInterceptors() { - AnalysisInputLocation inputLocation = new DefaultRTJarAnalysisInputLocation(SourceType.Library); + AnalysisInputLocation inputLocation = + new DefaultRuntimeAnalysisInputLocation(SourceType.Library); convertInputLocation(inputLocation); } @@ -81,7 +81,7 @@ private static void convertInputLocation(AnalysisInputLocation inputLocation) { // @Test public void testJar() { AnalysisInputLocation inputLocation = - new DefaultRTJarAnalysisInputLocation(SourceType.Library, Collections.emptyList()); + new DefaultRuntimeAnalysisInputLocation(SourceType.Library, Collections.emptyList()); convertInputLocation(inputLocation); } @@ -108,7 +108,7 @@ public void testJar() { private static Body convertMethod(String methodSignature) { AnalysisInputLocation inputLocation = - new DefaultRTJarAnalysisInputLocation(SourceType.Library, bodyInterceptors); + new DefaultRuntimeAnalysisInputLocation(SourceType.Library, bodyInterceptors); return convertMethod(methodSignature, inputLocation); } diff --git a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/frontend/AsmMethodSourceTest.java b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/frontend/AsmMethodSourceTest.java index 2b66c1a4c88..78d0b6447fd 100644 --- a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/frontend/AsmMethodSourceTest.java +++ b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/frontend/AsmMethodSourceTest.java @@ -13,7 +13,7 @@ import sootup.core.model.SootMethod; import sootup.core.model.SourceType; import sootup.core.signatures.MethodSignature; -import sootup.java.bytecode.inputlocation.DefaultRTJarAnalysisInputLocation; +import sootup.java.bytecode.inputlocation.DefaultRuntimeAnalysisInputLocation; import sootup.java.bytecode.inputlocation.JavaClassPathAnalysisInputLocation; import sootup.java.core.JavaIdentifierFactory; import sootup.java.core.JavaSootMethod; @@ -31,7 +31,7 @@ public void testFix_StackUnderrun_convertPutFieldInsn_init() { fail("The rt.jar is not available after Java 8. You are using version " + version); } - JavaView view = new JavaView(new DefaultRTJarAnalysisInputLocation()); + JavaView view = new JavaView(new DefaultRuntimeAnalysisInputLocation()); final JavaIdentifierFactory idf = JavaIdentifierFactory.getInstance(); JavaClassType mainClassSignature = 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 cd9f2726ae5..55658e3da1f 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 @@ -182,7 +182,7 @@ void runtimeContains(View view, String classname, String packageName) { @Test public void testRuntimeJar() { - PathBasedAnalysisInputLocation pathBasedNamespace = new DefaultRTJarAnalysisInputLocation(); + AnalysisInputLocation pathBasedNamespace = new DefaultRuntimeAnalysisInputLocation(); JavaView v = new JavaView(pathBasedNamespace); @@ -202,7 +202,7 @@ public void testRuntimeJar() { */ @Test public void testInputLocationLibraryMode() { - JavaView view = new JavaView(new DefaultRTJarAnalysisInputLocation()); + JavaView view = new JavaView(new DefaultRuntimeAnalysisInputLocation()); Collection classes = new HashSet<>(); // Set to track the classes to check diff --git a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/interceptors/typeresolving/BytecodeHierarchyTest.java b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/interceptors/typeresolving/BytecodeHierarchyTest.java index c866386de07..50509f31b3b 100644 --- a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/interceptors/typeresolving/BytecodeHierarchyTest.java +++ b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/interceptors/typeresolving/BytecodeHierarchyTest.java @@ -11,7 +11,7 @@ import sootup.core.IdentifierFactory; import sootup.core.types.*; import sootup.core.util.ImmutableUtils; -import sootup.java.bytecode.inputlocation.DefaultRTJarAnalysisInputLocation; +import sootup.java.bytecode.inputlocation.DefaultRuntimeAnalysisInputLocation; import sootup.java.bytecode.inputlocation.JavaClassPathAnalysisInputLocation; import sootup.java.core.interceptors.typeresolving.BytecodeHierarchy; import sootup.java.core.interceptors.typeresolving.types.BottomType; @@ -57,7 +57,8 @@ public void setUp() { JavaClassPathAnalysisInputLocation analysisInputLocation = new JavaClassPathAnalysisInputLocation(jarFile); view = - new JavaView(Arrays.asList(new DefaultRTJarAnalysisInputLocation(), analysisInputLocation)); + new JavaView( + Arrays.asList(new DefaultRuntimeAnalysisInputLocation(), analysisInputLocation)); // create types IdentifierFactory factory = view.getIdentifierFactory(); diff --git a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/interceptors/typeresolving/TypeAssignerTestSuite.java b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/interceptors/typeresolving/TypeAssignerTestSuite.java index 7a7f55165c2..3806d7684e7 100644 --- a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/interceptors/typeresolving/TypeAssignerTestSuite.java +++ b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/interceptors/typeresolving/TypeAssignerTestSuite.java @@ -12,7 +12,7 @@ import sootup.core.signatures.MethodSignature; import sootup.core.types.ClassType; import sootup.core.types.Type; -import sootup.java.bytecode.inputlocation.DefaultRTJarAnalysisInputLocation; +import sootup.java.bytecode.inputlocation.DefaultRuntimeAnalysisInputLocation; import sootup.java.bytecode.inputlocation.JavaClassPathAnalysisInputLocation; import sootup.java.core.JavaSootClass; import sootup.java.core.JavaSootMethod; @@ -31,7 +31,7 @@ public void buildView(String baseDir, String className) { new JavaClassPathAnalysisInputLocation( baseDir, SourceType.Application, Collections.emptyList()); AnalysisInputLocation rtJar = - new DefaultRTJarAnalysisInputLocation(SourceType.Application, Collections.emptyList()); + new DefaultRuntimeAnalysisInputLocation(SourceType.Application, Collections.emptyList()); view = new JavaView(Arrays.asList(analysisInputLocation, rtJar)); diff --git a/sootup.tests/src/test/java/sootup/tests/CallGraphTest.java b/sootup.tests/src/test/java/sootup/tests/CallGraphTest.java index 1be43da05f5..296b5031507 100644 --- a/sootup.tests/src/test/java/sootup/tests/CallGraphTest.java +++ b/sootup.tests/src/test/java/sootup/tests/CallGraphTest.java @@ -17,7 +17,7 @@ import sootup.core.model.SootClass; import sootup.core.model.SootMethod; import sootup.core.signatures.MethodSignature; -import sootup.java.bytecode.inputlocation.DefaultRTJarAnalysisInputLocation; +import sootup.java.bytecode.inputlocation.DefaultRuntimeAnalysisInputLocation; import sootup.java.core.JavaIdentifierFactory; import sootup.java.core.types.JavaClassType; import sootup.java.core.views.JavaView; @@ -42,7 +42,7 @@ protected AbstractCallGraphAlgorithm createAlgorithm(JavaView view) { private JavaView createViewForClassPath(String classPath) { List inputLocations = new ArrayList<>(); - inputLocations.add(new DefaultRTJarAnalysisInputLocation()); + inputLocations.add(new DefaultRuntimeAnalysisInputLocation()); inputLocations.add(new JavaSourcePathAnalysisInputLocation(classPath)); return new JavaView(inputLocations); diff --git a/sootup.tests/src/test/java/sootup/tests/typehierarchy/HierarchyComparatorTest.java b/sootup.tests/src/test/java/sootup/tests/typehierarchy/HierarchyComparatorTest.java index 0baf2e2cd1f..b8a23129e7c 100644 --- a/sootup.tests/src/test/java/sootup/tests/typehierarchy/HierarchyComparatorTest.java +++ b/sootup.tests/src/test/java/sootup/tests/typehierarchy/HierarchyComparatorTest.java @@ -13,7 +13,7 @@ import sootup.core.typehierarchy.HierarchyComparator; import sootup.core.types.ClassType; import sootup.core.views.View; -import sootup.java.bytecode.inputlocation.DefaultRTJarAnalysisInputLocation; +import sootup.java.bytecode.inputlocation.DefaultRuntimeAnalysisInputLocation; import sootup.java.core.views.JavaView; import sootup.java.sourcecode.inputlocation.JavaSourcePathAnalysisInputLocation; @@ -28,7 +28,7 @@ public static void setUp() { inputLocations.add( new JavaSourcePathAnalysisInputLocation( Collections.singleton("src/test/resources/javatypehierarchy/Comparator"))); - inputLocations.add(new DefaultRTJarAnalysisInputLocation()); + inputLocations.add(new DefaultRuntimeAnalysisInputLocation()); view = new JavaView(inputLocations); } From 2776e84f48112ece7dc3dd1dfb0764411de7ec0c Mon Sep 17 00:00:00 2001 From: Jonas Klauke Date: Thu, 26 Sep 2024 10:21:10 +0200 Subject: [PATCH 2/3] merge cleanup --- .../analysis/interprocedural/ifds/CGEdgeUtilTest.java | 0 .../inputlocation/DefaultRuntimeAnalysisInputLocation.java | 6 ++---- 2 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 sootup.analysis/src/test/java/sootup/analysis/interprocedural/ifds/CGEdgeUtilTest.java diff --git a/sootup.analysis/src/test/java/sootup/analysis/interprocedural/ifds/CGEdgeUtilTest.java b/sootup.analysis/src/test/java/sootup/analysis/interprocedural/ifds/CGEdgeUtilTest.java deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/sootup.java.bytecode.frontend/src/main/java/sootup/java/bytecode/frontend/inputlocation/DefaultRuntimeAnalysisInputLocation.java b/sootup.java.bytecode.frontend/src/main/java/sootup/java/bytecode/frontend/inputlocation/DefaultRuntimeAnalysisInputLocation.java index 6dedae11b3f..a440b658fa6 100644 --- a/sootup.java.bytecode.frontend/src/main/java/sootup/java/bytecode/frontend/inputlocation/DefaultRuntimeAnalysisInputLocation.java +++ b/sootup.java.bytecode.frontend/src/main/java/sootup/java/bytecode/frontend/inputlocation/DefaultRuntimeAnalysisInputLocation.java @@ -1,4 +1,4 @@ -package sootup.java.bytecode.inputlocation; +package sootup.java.bytecode.frontend.inputlocation; import java.util.Collection; import java.util.List; @@ -10,10 +10,8 @@ import sootup.core.transform.BodyInterceptor; import sootup.core.types.ClassType; import sootup.core.views.View; -import sootup.java.core.interceptors.BytecodeBodyInterceptors; +import sootup.interceptors.BytecodeBodyInterceptors; -// Frage: müssten nicht alle Vorkommen von DefaultRT und JrtFile durch DefaultRuntime ersetzt -// werden, wenn DefaultRT mit DefaultRuntime ersetzt wird? public class DefaultRuntimeAnalysisInputLocation implements AnalysisInputLocation { private final AnalysisInputLocation instance; From d9cddecd83fb4d6d2cbbddfd724fa2fba90781a3 Mon Sep 17 00:00:00 2001 From: "M.Schmidt" Date: Tue, 1 Oct 2024 10:54:55 +0200 Subject: [PATCH 3/3] cleanup --- .../DefaultRuntimeAnalysisInputLocation.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sootup.java.bytecode.frontend/src/main/java/sootup/java/bytecode/frontend/inputlocation/DefaultRuntimeAnalysisInputLocation.java b/sootup.java.bytecode.frontend/src/main/java/sootup/java/bytecode/frontend/inputlocation/DefaultRuntimeAnalysisInputLocation.java index a440b658fa6..e300aa472d9 100644 --- a/sootup.java.bytecode.frontend/src/main/java/sootup/java/bytecode/frontend/inputlocation/DefaultRuntimeAnalysisInputLocation.java +++ b/sootup.java.bytecode.frontend/src/main/java/sootup/java/bytecode/frontend/inputlocation/DefaultRuntimeAnalysisInputLocation.java @@ -12,28 +12,28 @@ import sootup.core.views.View; import sootup.interceptors.BytecodeBodyInterceptors; +/** AnalysisInputLocation that points to the shipped Java Runtime of the current JVM execution */ public class DefaultRuntimeAnalysisInputLocation implements AnalysisInputLocation { - private final AnalysisInputLocation instance; + @Nonnull private final AnalysisInputLocation backingInputLocation; public DefaultRuntimeAnalysisInputLocation() { this(SourceType.Library); } public DefaultRuntimeAnalysisInputLocation(@Nonnull SourceType srcType) { - // doesn't match with the second DefaultRTJarAnalysisInputLocation constructor - // shouldn't be problematic, cause of the third constructor this(srcType, BytecodeBodyInterceptors.Default.getBodyInterceptors()); } public DefaultRuntimeAnalysisInputLocation( @Nonnull SourceType srcType, @Nonnull List bodyInterceptors) { - String version = System.getProperty("java.version"); + String version = System.getProperty("java.version"); + // are we using Java 8 or lower in the current JVM execution? if (version.startsWith("1")) { - instance = new DefaultRTJarAnalysisInputLocation(srcType, bodyInterceptors); + backingInputLocation = new DefaultRTJarAnalysisInputLocation(srcType, bodyInterceptors); } else { - instance = new JrtFileSystemAnalysisInputLocation(srcType, bodyInterceptors); + backingInputLocation = new JrtFileSystemAnalysisInputLocation(srcType, bodyInterceptors); } } @@ -41,24 +41,24 @@ public DefaultRuntimeAnalysisInputLocation( @Override public Optional getClassSource( @Nonnull ClassType type, @Nonnull View view) { - return instance.getClassSource(type, view); + return backingInputLocation.getClassSource(type, view); } @Nonnull @Override public Collection getClassSources(@Nonnull View view) { - return instance.getClassSources(view); + return backingInputLocation.getClassSources(view); } @Nonnull @Override public SourceType getSourceType() { - return instance.getSourceType(); + return backingInputLocation.getSourceType(); } @Nonnull @Override public List getBodyInterceptors() { - return instance.getBodyInterceptors(); + return backingInputLocation.getBodyInterceptors(); } }