Skip to content

Commit

Permalink
Merge pull request #680 from soot-oss/removeIncompleteMultiReleaseHan…
Browse files Browse the repository at this point in the history
…dling

remove incomplete multi release handling in the class type generation…
  • Loading branch information
stschott authored Sep 8, 2023
2 parents c8bea01 + 51afb96 commit 3ca576d
Showing 1 changed file with 4 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import javax.annotation.Nonnull;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.ClassUtils;
import org.apache.commons.lang3.StringUtils;
import sootup.core.IdentifierFactory;
import sootup.core.model.SootClass;
import sootup.core.signatures.FieldSignature;
Expand Down Expand Up @@ -234,24 +233,15 @@ public AnnotationType getAnnotationType(final String fullyQualifiedClassName) {
@Override
@Nonnull
public JavaClassType fromPath(@Nonnull final Path rootDirectory, @Nonnull final Path file) {
String path = file.toString();
String separator = file.getFileSystem().getSeparator();

// for multi release jars, remove beginning of path
// /META-INF/versions/15/de/upb...
// we only want /de/upb...
if (path.startsWith("/META-INF/")) {
// start at 4th separator
int index = StringUtils.ordinalIndexOf(path, separator, 4);
path = path.substring(index);
}

final int nameCountBaseDir =
rootDirectory.toString().isEmpty() ? 0 : rootDirectory.getNameCount();

String fullyQualifiedName =
FilenameUtils.removeExtension(
file.subpath(nameCountBaseDir, file.getNameCount()).toString().replace(separator, "."));
file.subpath(nameCountBaseDir, file.getNameCount())
.toString()
.replace(file.getFileSystem().getSeparator(), "."));

return getClassType(fullyQualifiedName);
}
Expand Down Expand Up @@ -524,7 +514,7 @@ public MethodSubSignature parseMethodSubSignature(@Nonnull String subSignature)

return true;
})
.map(typeName -> getType(typeName))
.map(this::getType)
.collect(Collectors.toList());

return getMethodSubSignature(methodName, getType(returnName), argsList);
Expand Down

0 comments on commit 3ca576d

Please sign in to comment.