diff --git a/sootup.core/src/main/java/sootup/core/Language.java b/sootup.core/src/main/java/sootup/core/Language.java deleted file mode 100644 index 62dbf1204af..00000000000 --- a/sootup.core/src/main/java/sootup/core/Language.java +++ /dev/null @@ -1,41 +0,0 @@ -package sootup.core; -/*- - * #%L - * Soot - * %% - * Copyright (C) 2019-2020 Linghui Luo, Markus Schmidt - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . - * #L% - */ - -/** - * This class is a container for language specific information - * - * @author Markus Schmidt - */ -public abstract class Language { - - public abstract String getName(); - - public abstract int getVersion(); - - public abstract IdentifierFactory getIdentifierFactory(); - - @Override - public String toString() { - return getName() + " " + getVersion(); - } -} diff --git a/sootup.java.bytecode.frontend/src/main/java/sootup/java/bytecode/frontend/inputlocation/ModuleMultiReleaseJarAnalysisInputLocation.java b/sootup.java.bytecode.frontend/src/main/java/sootup/java/bytecode/frontend/inputlocation/ModuleMultiReleaseJarAnalysisInputLocation.java index 8dd3151a0d4..07cb41fca49 100644 --- a/sootup.java.bytecode.frontend/src/main/java/sootup/java/bytecode/frontend/inputlocation/ModuleMultiReleaseJarAnalysisInputLocation.java +++ b/sootup.java.bytecode.frontend/src/main/java/sootup/java/bytecode/frontend/inputlocation/ModuleMultiReleaseJarAnalysisInputLocation.java @@ -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; @@ -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); /* diff --git a/sootup.java.bytecode.frontend/src/main/java/sootup/java/bytecode/frontend/inputlocation/MultiReleaseJarAnalysisInputLocation.java b/sootup.java.bytecode.frontend/src/main/java/sootup/java/bytecode/frontend/inputlocation/MultiReleaseJarAnalysisInputLocation.java index b4986398b97..8260556dc25 100644 --- a/sootup.java.bytecode.frontend/src/main/java/sootup/java/bytecode/frontend/inputlocation/MultiReleaseJarAnalysisInputLocation.java +++ b/sootup.java.bytecode.frontend/src/main/java/sootup/java/bytecode/frontend/inputlocation/MultiReleaseJarAnalysisInputLocation.java @@ -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; @@ -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 bodyInterceptors; @Nonnull protected final Map inputLocations = new LinkedHashMap<>(); + private final int version; + public static AnalysisInputLocation create( @Nonnull Path path, @Nonnull SourceType srcType, - @Nonnull Language language, + int version, List 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 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 bodyInterceptors, boolean isMultiRelease) { super(path, srcType); - this.language = language; + this.version = version; this.bodyInterceptors = bodyInterceptors; if (!isMultiRelease) { @@ -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())); }); @@ -199,8 +197,8 @@ public Collection getClassSources(@Nonnull View view) { } @Nonnull - public Language getLanguage() { - return language; + public int getVersion() { + return version; } public static boolean isMultiReleaseJar(Path path) { diff --git a/sootup.java.bytecode.frontend/src/test/java/sootup/java/bytecode/frontend/inputlocation/ModuleMultiReleaseJarAnalysisInputLocationTest.java b/sootup.java.bytecode.frontend/src/test/java/sootup/java/bytecode/frontend/inputlocation/ModuleMultiReleaseJarAnalysisInputLocationTest.java index 5da2a993345..5bbff8e1a41 100644 --- a/sootup.java.bytecode.frontend/src/test/java/sootup/java/bytecode/frontend/inputlocation/ModuleMultiReleaseJarAnalysisInputLocationTest.java +++ b/sootup.java.bytecode.frontend/src/test/java/sootup/java/bytecode/frontend/inputlocation/ModuleMultiReleaseJarAnalysisInputLocationTest.java @@ -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; @@ -70,8 +69,7 @@ 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( @@ -79,8 +77,7 @@ public void modularMultiReleaseJar() { 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(), diff --git a/sootup.java.bytecode.frontend/src/test/java/sootup/java/bytecode/frontend/inputlocation/MultiReleaseJarAnalysisInputLocationTest.java b/sootup.java.bytecode.frontend/src/test/java/sootup/java/bytecode/frontend/inputlocation/MultiReleaseJarAnalysisInputLocationTest.java index 5383d5d8481..3aa440dec84 100644 --- a/sootup.java.bytecode.frontend/src/test/java/sootup/java/bytecode/frontend/inputlocation/MultiReleaseJarAnalysisInputLocationTest.java +++ b/sootup.java.bytecode.frontend/src/test/java/sootup/java/bytecode/frontend/inputlocation/MultiReleaseJarAnalysisInputLocationTest.java @@ -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) @@ -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"); diff --git a/sootup.java.core/src/main/java/sootup/java/core/language/JavaLanguage.java b/sootup.java.core/src/main/java/sootup/java/core/language/JavaLanguage.java deleted file mode 100644 index d698bf88f24..00000000000 --- a/sootup.java.core/src/main/java/sootup/java/core/language/JavaLanguage.java +++ /dev/null @@ -1,75 +0,0 @@ -package sootup.java.core.language; - -/*- - * #%L - * Soot - a J*va Optimization Framework - * %% - * Copyright (C) 2019-2020 Linghui Luo - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . - * #L% - */ - -import javax.annotation.Nonnull; -import sootup.core.IdentifierFactory; -import sootup.core.Language; -import sootup.java.core.JavaIdentifierFactory; -import sootup.java.core.JavaModuleIdentifierFactory; - -/** - * Language specific Configuration for Java. - * - * @author Markus Schmidt - * @author Linghui Luo - */ -public class JavaLanguage extends Language { - - /** The identifier factory. */ - @Nonnull private final IdentifierFactory identifierFactory; - - /** The version number of Java. */ - private final int version; - - /** - * Instantiates a new java language with given version e.g 8 or 9 - * - * @param version the Java version, not the major release version within the class file - */ - public JavaLanguage(int version) { - this.version = version; - if (version < 9) { - identifierFactory = JavaIdentifierFactory.getInstance(); - } else { - identifierFactory = JavaModuleIdentifierFactory.getInstance(); - } - } - - @Override - @Nonnull - public String getName() { - return "Java"; - } - - @Override - public int getVersion() { - return version; - } - - @Override - @Nonnull - public IdentifierFactory getIdentifierFactory() { - return identifierFactory; - } -} diff --git a/sootup.jimple.frontend/src/main/java/sootup/jimple/frontend/JimpleLanguage.java b/sootup.jimple.frontend/src/main/java/sootup/jimple/frontend/JimpleLanguage.java deleted file mode 100644 index fb523f38f93..00000000000 --- a/sootup.jimple.frontend/src/main/java/sootup/jimple/frontend/JimpleLanguage.java +++ /dev/null @@ -1,52 +0,0 @@ -package sootup.jimple.frontend; - -/*- - * #%L - * SootUp - * %% - * Copyright (C) 1997 - 2024 Raja Vallée-Rai and others - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . - * #L% - */ - -import sootup.core.IdentifierFactory; -import sootup.core.Language; -import sootup.java.core.JavaIdentifierFactory; - -public class JimpleLanguage extends Language { - - private static JimpleLanguage INSTANCE = new JimpleLanguage(); - - public static JimpleLanguage getInstance() { - return INSTANCE; - } - - @Override - public String getName() { - return "Jimple"; - } - - @Override - public int getVersion() { - return -1; // there is no real versioning other than "old" Soot and FutureSoot at the moment - } - - @Override - public IdentifierFactory getIdentifierFactory() { - // FIXME [ms] ? - return JavaIdentifierFactory.getInstance(); - } -} diff --git a/sootup.jimple.frontend/src/main/java/sootup/jimple/frontend/JimpleView.java b/sootup.jimple.frontend/src/main/java/sootup/jimple/frontend/JimpleView.java index aa8d879e872..bb169ec5f58 100644 --- a/sootup.jimple.frontend/src/main/java/sootup/jimple/frontend/JimpleView.java +++ b/sootup.jimple.frontend/src/main/java/sootup/jimple/frontend/JimpleView.java @@ -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. @@ -97,7 +98,7 @@ public synchronized Optional getClass(@Nonnull ClassType type) { @Nonnull @Override public IdentifierFactory getIdentifierFactory() { - return new JimpleLanguage().getIdentifierFactory(); + return JavaIdentifierFactory.getInstance(); } @Nonnull