Skip to content

Commit

Permalink
Merge pull request #1116 from soot-oss/removeLanguageConstruct
Browse files Browse the repository at this point in the history
Remove Language construct
  • Loading branch information
swissiety authored Oct 18, 2024
2 parents a306ce6 + 6701758 commit 07598f6
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 213 deletions.
41 changes: 0 additions & 41 deletions sootup.core/src/main/java/sootup/core/Language.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.Set;
import java.util.concurrent.ExecutionException;
import javax.annotation.Nonnull;
import sootup.core.Language;
import sootup.core.frontend.SootClassSource;
import sootup.core.model.SourceType;
import sootup.core.transform.BodyInterceptor;
Expand All @@ -45,8 +44,8 @@
public class ModuleMultiReleaseJarAnalysisInputLocation extends MultiReleaseJarAnalysisInputLocation
implements ModuleInfoAnalysisInputLocation {
public ModuleMultiReleaseJarAnalysisInputLocation(
@Nonnull Path path, @Nonnull SourceType srcType, @Nonnull Language language) {
super(path, srcType, language);
@Nonnull Path path, @Nonnull SourceType srcType, int version) {
super(path, srcType, version);

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nonnull;
import sootup.core.Language;
import sootup.core.frontend.SootClassSource;
import sootup.core.inputlocation.AnalysisInputLocation;
import sootup.core.model.SourceType;
Expand All @@ -59,52 +58,53 @@ public class MultiReleaseJarAnalysisInputLocation extends ArchiveBasedAnalysisIn
// "usual" Jar
protected static final Integer DEFAULT_VERSION = 0;

@Nonnull protected final Language language;
@Nonnull private final List<BodyInterceptor> bodyInterceptors;

@Nonnull
protected final Map<Integer, AnalysisInputLocation> inputLocations = new LinkedHashMap<>();

private final int version;

public static AnalysisInputLocation create(
@Nonnull Path path,
@Nonnull SourceType srcType,
@Nonnull Language language,
int version,
List<BodyInterceptor> bodyInterceptors) {

if (isMultiReleaseJar(path)) {
return new MultiReleaseJarAnalysisInputLocation(
path, srcType, language, bodyInterceptors, true);
path, srcType, version, bodyInterceptors, true);
}

return create(
path, srcType, bodyInterceptors, Collections.singletonList(Paths.get("/META-INF")));
}

public MultiReleaseJarAnalysisInputLocation(@Nonnull Path path, @Nonnull Language language) {
this(path, SourceType.Application, language);
public MultiReleaseJarAnalysisInputLocation(@Nonnull Path path, int version) {
this(path, SourceType.Application, version);
}

public MultiReleaseJarAnalysisInputLocation(
@Nonnull Path path, @Nonnull SourceType srcType, @Nonnull Language language) {
this(path, srcType, language, BytecodeBodyInterceptors.Default.getBodyInterceptors());
@Nonnull Path path, @Nonnull SourceType srcType, int version) {
this(path, srcType, version, BytecodeBodyInterceptors.Default.getBodyInterceptors());
}

public MultiReleaseJarAnalysisInputLocation(
@Nonnull Path path,
@Nonnull SourceType srcType,
@Nonnull Language language,
int version,
@Nonnull List<BodyInterceptor> bodyInterceptors) {
this(path, srcType, language, bodyInterceptors, isMultiReleaseJar(path));
this(path, srcType, version, bodyInterceptors, isMultiReleaseJar(path));
}

protected MultiReleaseJarAnalysisInputLocation(
@Nonnull Path path,
@Nonnull SourceType srcType,
@Nonnull Language language,
int version,
@Nonnull List<BodyInterceptor> bodyInterceptors,
boolean isMultiRelease) {
super(path, srcType);
this.language = language;
this.version = version;
this.bodyInterceptors = bodyInterceptors;

if (!isMultiRelease) {
Expand All @@ -128,16 +128,14 @@ protected MultiReleaseJarAnalysisInputLocation(
return versionDirName.substring(0, versionDirName.length() - 1);
})
.map(Integer::new)
.filter(version -> version <= language.getVersion())
.filter(ver -> ver <= version)
.sorted(Comparator.reverseOrder())
.forEach(
version -> {
ver -> {
final Path versionRoot =
archiveRoot
.getFileSystem()
.getPath("/META-INF", "versions", version.toString());
archiveRoot.getFileSystem().getPath("/META-INF", "versions", ver.toString());
inputLocations.put(
version,
ver,
create(versionRoot, sourceType, bodyInterceptors, Collections.emptyList()));
});

Expand Down Expand Up @@ -199,8 +197,8 @@ public Collection<JavaSootClassSource> getClassSources(@Nonnull View view) {
}

@Nonnull
public Language getLanguage() {
return language;
public int getVersion() {
return version;
}

public static boolean isMultiReleaseJar(Path path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import sootup.core.types.ClassType;
import sootup.java.core.JavaModuleIdentifierFactory;
import sootup.java.core.ModuleInfoAnalysisInputLocation;
import sootup.java.core.language.JavaLanguage;
import sootup.java.core.signatures.ModuleSignature;
import sootup.java.core.types.ModuleJavaClassType;
import sootup.java.core.views.JavaModuleView;
Expand Down Expand Up @@ -70,17 +69,15 @@ public void modularMultiReleaseJar() {
getIdentifierFactory().getClassType("de.upb.swt.multirelease.Main");

ModuleInfoAnalysisInputLocation moduleMultiReleaseJarAnalysisInputLocation8 =
new ModuleMultiReleaseJarAnalysisInputLocation(
mmrj, SourceType.Application, new JavaLanguage(8));
new ModuleMultiReleaseJarAnalysisInputLocation(mmrj, SourceType.Application, 8);

final JavaView view_8 =
new JavaModuleView(
Collections.emptyList(),
Collections.singletonList(moduleMultiReleaseJarAnalysisInputLocation8));

ModuleMultiReleaseJarAnalysisInputLocation moduleMultiReleaseJarAnalysisInputLocation9 =
new ModuleMultiReleaseJarAnalysisInputLocation(
mmrj, SourceType.Application, new JavaLanguage(9));
new ModuleMultiReleaseJarAnalysisInputLocation(mmrj, SourceType.Application, 9);
final JavaModuleView view_9 =
new JavaModuleView(
Collections.emptyList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import sootup.core.model.SourceType;
import sootup.core.signatures.MethodSubSignature;
import sootup.core.types.ClassType;
import sootup.java.core.language.JavaLanguage;
import sootup.java.core.views.JavaView;

@Tag(TestCategories.JAVA_8_CATEGORY)
Expand All @@ -56,25 +55,15 @@ public class MultiReleaseJarAnalysisInputLocationTest extends AnalysisInputLocat
public void multiReleaseJar() {

view_min =
new JavaView(
new MultiReleaseJarAnalysisInputLocation(
mrj, SourceType.Application, new JavaLanguage(1)));
view_8 =
new JavaView(
new MultiReleaseJarAnalysisInputLocation(
mrj, SourceType.Application, new JavaLanguage(8)));
view_9 =
new JavaView(
new MultiReleaseJarAnalysisInputLocation(
mrj, SourceType.Application, new JavaLanguage(9)));
new JavaView(new MultiReleaseJarAnalysisInputLocation(mrj, SourceType.Application, 1));
view_8 = new JavaView(new MultiReleaseJarAnalysisInputLocation(mrj, SourceType.Application, 8));
view_9 = new JavaView(new MultiReleaseJarAnalysisInputLocation(mrj, SourceType.Application, 9));
view_10 =
new JavaView(
new MultiReleaseJarAnalysisInputLocation(
mrj, SourceType.Application, new JavaLanguage(10)));
new JavaView(new MultiReleaseJarAnalysisInputLocation(mrj, SourceType.Application, 10));
view_max =
new JavaView(
new MultiReleaseJarAnalysisInputLocation(
mrj, SourceType.Application, new JavaLanguage(Integer.MAX_VALUE)));
mrj, SourceType.Application, Integer.MAX_VALUE));

classType = getIdentifierFactory().getClassType("de.upb.sse.multirelease.Utility");
classType2 = getIdentifierFactory().getClassType("de.upb.sse.multirelease.Main");
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import sootup.core.model.SourceType;
import sootup.core.types.ClassType;
import sootup.core.views.AbstractView;
import sootup.java.core.JavaIdentifierFactory;

/**
* The Class JimpleView manages the Sootclasses of the application being analyzed.
Expand Down Expand Up @@ -97,7 +98,7 @@ public synchronized Optional<SootClass> getClass(@Nonnull ClassType type) {
@Nonnull
@Override
public IdentifierFactory getIdentifierFactory() {
return new JimpleLanguage().getIdentifierFactory();
return JavaIdentifierFactory.getInstance();
}

@Nonnull
Expand Down

0 comments on commit 07598f6

Please sign in to comment.