Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: changing sootclass getname to getpathplusclassname #2022

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/generated/jastadd/soot/JastAddJ/ClassDecl.java
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ public void jimplify1phase2() {
}
for(Iterator iter = interfacesIterator(); iter.hasNext(); ) {
TypeDecl typeDecl = (TypeDecl)iter.next();
if(!sc.implementsInterface(typeDecl.getSootClassDecl().getName()))
if(!sc.implementsInterface(typeDecl.getSootClassDecl().getPathPlusClassName()))
sc.addInterface(typeDecl.getSootClassDecl());
}
if(isNestedType())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public void jimplify1phase2() {
sc.setSuperclass(typeObject().getSootClassDecl());
for(Iterator iter = superinterfacesIterator(); iter.hasNext(); ) {
TypeDecl typeDecl = (TypeDecl)iter.next();
if(typeDecl != typeObject() && !sc.implementsInterface(typeDecl.getSootClassDecl().getName()))
if(typeDecl != typeObject() && !sc.implementsInterface(typeDecl.getSootClassDecl().getPathPlusClassName()))
sc.addInterface(typeDecl.getSootClassDecl());
}
if(isNestedType())
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/soot/AbstractASMBackend.java
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ protected void generateMethods() {
exceptions = new String[exceptionList.size()];
int i = 0;
for (SootClass exc : exceptionList) {
exceptions[i] = slashify(exc.getName());
exceptions[i] = slashify(exc.getPathPlusClassName());
++i;
}
} else {
Expand Down Expand Up @@ -611,7 +611,7 @@ protected void generateAnnotationElems(AnnotationVisitor av, Collection<Annotati
* Emits the bytecode for a reference to an outer class if necessary
*/
protected void generateOuterClassReference() {
String outerClassName = slashify(sc.getOuterClass().getName());
String outerClassName = slashify(sc.getOuterClass().getPathPlusClassName());
String enclosingMethod = null;
String enclosingMethodSig = null;
EnclosingMethodTag emTag = (EnclosingMethodTag) sc.getTag(EnclosingMethodTag.NAME);
Expand Down Expand Up @@ -641,7 +641,7 @@ protected void generateClassHeader() {
int modifier = getModifiers(sc.getModifiers(), sc);

// Retrieve class-name
String className = slashify(sc.getName());
String className = slashify(sc.getPathPlusClassName());
// Retrieve generics
SignatureTag sigTag = (SignatureTag) sc.getTag(SignatureTag.NAME);
String sig = sigTag == null ? null : sigTag.getSignature();
Expand All @@ -653,14 +653,14 @@ protected void generateClassHeader() {
String superClass = "java/lang/Object".equals(className) ? null : "java/lang/Object";
SootClass csuperClass = sc.getSuperclassUnsafe();
if (csuperClass != null) {
superClass = slashify(csuperClass.getName());
superClass = slashify(csuperClass.getPathPlusClassName());
}

// Retrieve directly implemented interfaces
String[] interfaces = new String[sc.getInterfaceCount()];
int i = 0;
for (SootClass interf : sc.getInterfaces()) {
interfaces[i] = slashify(interf.getName());
interfaces[i] = slashify(interf.getPathPlusClassName());
++i;
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/soot/AbstractJasminClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ public AbstractJasminClass(SootClass sootClass) {
}

if (Options.v().verbose()) {
logger.debug("[" + sootClass.getName() + "] Constructing baf.JasminClass...");
logger.debug("[" + sootClass.getPathPlusClassName() + "] Constructing baf.JasminClass...");
}

code = new LinkedList<String>();
Expand Down Expand Up @@ -450,13 +450,13 @@ public AbstractJasminClass(SootClass sootClass) {
}
if (Modifier.isInterface(modifiers)) {
modifiers -= Modifier.INTERFACE;
emit(".interface " + Modifier.toString(modifiers) + " " + slashify(sootClass.getName()));
emit(".interface " + Modifier.toString(modifiers) + " " + slashify(sootClass.getPathPlusClassName()));
} else {
emit(".class " + Modifier.toString(modifiers) + " " + slashify(sootClass.getName()));
emit(".class " + Modifier.toString(modifiers) + " " + slashify(sootClass.getPathPlusClassName()));
}

if (sootClass.hasSuperclass()) {
emit(".super " + slashify(sootClass.getSuperclass().getName()));
emit(".super " + slashify(sootClass.getSuperclass().getPathPlusClassName()));
} else {
emit(".no_super");
}
Expand All @@ -466,7 +466,7 @@ public AbstractJasminClass(SootClass sootClass) {

// Emit the interfaces
for (SootClass inter : sootClass.getInterfaces()) {
emit(".implements " + slashify(inter.getName()));
emit(".implements " + slashify(inter.getPathPlusClassName()));
}
/*
* why do this???? if(sootClass.getInterfaceCount() != 0) emit("");
Expand Down Expand Up @@ -663,7 +663,7 @@ protected void emitMethod(SootMethod method) {
+ jasminDescriptorOf(method.makeRef()));

for (SootClass exceptClass : method.getExceptions()) {
emit(".throws " + exceptClass.getName());
emit(".throws " + exceptClass.getPathPlusClassName());
}
if (method.hasTag(SyntheticTag.NAME) || Modifier.isSynthetic(method.getModifiers())) {
emit(".synthetic");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/soot/AbstractTrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,6 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE

private void writeObject(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
out.writeObject(exception.getName());
out.writeObject(exception.getPathPlusClassName());
}
}
4 changes: 2 additions & 2 deletions src/main/java/soot/BriefUnitPrinter.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void startUnit(Unit u) {
public void methodRef(SootMethodRef m) {
handleIndent();
if (!baf && m.resolve().isStatic()) {
output.append(m.getDeclaringClass().getName());
output.append(m.getDeclaringClass().getPathPlusClassName());
literal(".");
}
output.append(m.name());
Expand All @@ -60,7 +60,7 @@ public void methodRef(SootMethodRef m) {
public void fieldRef(SootFieldRef f) {
handleIndent();
if (baf || f.resolve().isStatic()) {
output.append(f.declaringClass().getName());
output.append(f.declaringClass().getPathPlusClassName());
literal(".");
}
output.append(f.name());
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/soot/Hierarchy.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public List<SootClass> getSuperclassesOfIncluding(SootClass sootClass) {
public List<SootClass> getSuperclassesOf(SootClass sootClass) {
sootClass.checkLevel(SootClass.HIERARCHY);
if (sootClass.isInterface()) {
throw new IllegalArgumentException(sootClass.getName() + " is an interface, but class is expected");
throw new IllegalArgumentException(sootClass.getPathPlusClassName() + " is an interface, but class is expected");
}

checkState();
Expand Down Expand Up @@ -303,7 +303,7 @@ public List<SootClass> getSubinterfacesOfIncluding(SootClass sootClass) {
public List<SootClass> getSubinterfacesOf(SootClass sootClass) {
sootClass.checkLevel(SootClass.HIERARCHY);
if (!sootClass.isInterface()) {
throw new IllegalArgumentException(sootClass.getName() + " is a class, but interface is expected");
throw new IllegalArgumentException(sootClass.getPathPlusClassName() + " is a class, but interface is expected");
}

checkState();
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/soot/JastAddInitialResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void formAst(String fullPath, List<String> locations, String className) {
classNameToCU.put(className, u);
} else {
for (SootClass sc : types) {
classNameToCU.put(sc.getName(), u);
classNameToCU.put(sc.getPathPlusClassName(), u);
}
}
}
Expand Down Expand Up @@ -113,10 +113,11 @@ private TypeDecl findNestedTypeDecl(TypeDecl typeDecl, SootClass sc) {
}

public Dependencies resolveFromJavaFile(SootClass sootclass) {
CompilationUnit u = classNameToCU.get(sootclass.getName());
CompilationUnit u = classNameToCU.get(sootclass.getPathPlusClassName());

if (u == null) {
throw new RuntimeException("Error: couldn't find class: " + sootclass.getName() + " are the packages set properly?");
throw new RuntimeException("Error: couldn't find class: " + sootclass.getPathPlusClassName()
+ " are the packages set properly?");
}

HashSet<SootClass> types = new HashSet<SootClass>();
Expand All @@ -132,7 +133,7 @@ public Dependencies resolveFromJavaFile(SootClass sootclass) {
m.setSource(new MethodSource() {
public Body getBody(SootMethod m, String phaseName) {
SootClass sc = m.getDeclaringClass();
CompilationUnit u = classNameToCU.get(sc.getName());
CompilationUnit u = classNameToCU.get(sc.getPathPlusClassName());
for (TypeDecl typeDecl : u.getTypeDecls()) {
typeDecl = findNestedTypeDecl(typeDecl, sc);
if (typeDecl != null) {
Expand All @@ -159,7 +160,7 @@ public Body getBody(SootMethod m, String phaseName) {
}
}
throw new RuntimeException(
"Could not find body for " + m.getSignature() + " in " + m.getDeclaringClass().getName());
"Could not find body for " + m.getSignature() + " in " + m.getDeclaringClass().getPathPlusClassName());
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/soot/JimpleClassSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public Dependencies resolve(SootClass sc) {
// set outer class if not set (which it should not be) and class name contains outer class indicator
String outerClassName = null;
if (!sc.hasOuterClass()) {
String className = sc.getName();
String className = sc.getPathPlusClassName();
if (className.contains("$")) {
if (className.contains("$-")) {
/*
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/soot/LambdaMetaFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public SootMethodRef makeLambdaHelper(List<? extends Value> bootstrapArgs, int t
// Our thunk class implements the functional interface
SootClass functionalInterfaceToImplement = ((RefType) invokedType[invokedType.length - 1]).getSootClass();

final String enclosingClassname = enclosingClass.getName();
final String enclosingClassname = enclosingClass.getPathPlusClassName();

String className;
final boolean readableClassnames = true;
Expand Down Expand Up @@ -201,7 +201,7 @@ public SootMethodRef makeLambdaHelper(List<? extends Value> bootstrapArgs, int t
// it can be invoked from the thunk class
if (MethodHandle.Kind.REF_INVOKE_STATIC.getValue() == implMethod.getKind()) {
SootClass declClass = implMethod.getMethodRef().getDeclaringClass();
if (declClass.getName().equals(enclosingClassname)) {
if (declClass.getPathPlusClassName().equals(enclosingClassname)) {
SootMethod method = implMethod.getMethodRef().resolve();
method.setModifiers((method.getModifiers() & ~Modifier.PRIVATE) | Modifier.PUBLIC);
}
Expand Down Expand Up @@ -268,11 +268,11 @@ private synchronized void resolveHandle(MethodHandle implMethod) {
Scene scene = Scene.v();

SootMethodRef methodRef = implMethod.getMethodRef();
scene.forceResolve(methodRef.getDeclaringClass().getName(), SootClass.HIERARCHY);
scene.forceResolve(methodRef.getDeclaringClass().getPathPlusClassName(), SootClass.HIERARCHY);

Stream.concat(Stream.of(methodRef.getReturnType()), methodRef.getParameterTypes().stream())
.filter(t -> t instanceof RefType)
.forEach(t -> scene.forceResolve(((RefType) t).getSootClass().getName(), SootClass.HIERARCHY));
.forEach(t -> scene.forceResolve(((RefType) t).getSootClass().getPathPlusClassName(), SootClass.HIERARCHY));
}

private void addDispatch(String name, SootClass tclass, MethodType implMethodType, MethodType instantiatedMethodType,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/soot/ModulePathSourceLocator.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public ClassSource getClassSource(String className, Optional<String> moduleName)
if (classesToLoad == null) {
classesToLoad = new HashSet<String>(ModuleScene.v().getBasicClasses());
for (SootClass c : ModuleScene.v().getApplicationClasses()) {
classesToLoad.add(c.getName());
classesToLoad.add(c.getPathPlusClassName());
}
this.classesToLoad = classesToLoad;
}
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/soot/ModuleScene.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ private String defaultJavaModulePath() {
@Override
protected void addClassSilent(SootClass c) {
if (c.isInScene()) {
throw new RuntimeException("already managed: " + c.getName());
throw new RuntimeException("already managed: " + c.getPathPlusClassName());
}

final String className = c.getName();
final String className = c.getPathPlusClassName();
if (containsClass(className, Optional.fromNullable(c.moduleName))) {
throw new RuntimeException("duplicate class: " + className);
}
Expand Down Expand Up @@ -532,7 +532,8 @@ public void loadDynamicClasses() {
SootClass c = iterator.next();
if (!c.isConcrete()) {
if (opts.verbose()) {
logger.warn("dynamic class " + c.getName() + " is abstract or an interface, and it will not be considered.");
logger.warn("dynamic class " + c.getPathPlusClassName()
+ " is abstract or an interface, and it will not be considered.");
}
iterator.remove();
}
Expand Down Expand Up @@ -562,7 +563,7 @@ protected void prepareClasses() {
if (Options.v().app()) {
s.setApplicationClass();
}
if (optionsClasses.contains(s.getName())) {
if (optionsClasses.contains(s.getPathPlusClassName())) {
s.setApplicationClass();
continue;
}
Expand All @@ -574,7 +575,7 @@ protected void prepareClasses() {
}
if (s.isApplicationClass()) {
// make sure we have the support
loadClassAndSupport(s.getName(), Optional.fromNullable(s.moduleName));
loadClassAndSupport(s.getPathPlusClassName(), Optional.fromNullable(s.moduleName));
}
}
}
Expand All @@ -593,7 +594,7 @@ public void setMainClassFromOptions() {
for (String s : Options.v().classes()) {
SootClass c = getSootClass(s, null);
if (c.declaresMethod("main", mainArgs, VoidType.v())) {
logger.debug("No main class given. Inferred '" + c.getName() + "' as main class.");
logger.debug("No main class given. Inferred '" + c.getPathPlusClassName() + "' as main class.");
setMainClass(c);
return;
}
Expand All @@ -602,7 +603,7 @@ public void setMainClassFromOptions() {
// try to infer a main class from the usual classpath if none is given
for (SootClass c : getApplicationClasses()) {
if (c.declaresMethod("main", mainArgs, VoidType.v())) {
logger.debug("No main class given. Inferred '" + c.getName() + "' as main class.");
logger.debug("No main class given. Inferred '" + c.getPathPlusClassName() + "' as main class.");
setMainClass(c);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/soot/PackManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -882,13 +882,13 @@ private void outputDava() {
private void runBodyPacks(SootClass c) {
final int format = Options.v().output_format();
if (format == Options.output_format_dava) {
logger.debug("Decompiling {}...", c.getName());
logger.debug("Decompiling {}...", c.getPathPlusClassName());

// January 13th, 2006 SootMethodAddedByDava is set to false for
// SuperFirstStmtHandler
G.v().SootMethodAddedByDava = false;
} else {
logger.debug("Transforming {}...", c.getName());
logger.debug("Transforming {}...", c.getPathPlusClassName());
}

boolean produceBaf = false, produceGrimp = false, produceDava = false, produceJimple = true, produceShimple = false;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/soot/PolymorphicMethodRef.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class PolymorphicMethodRef extends SootMethodRefImpl {
* @return if the class is allowed according to the JVM Spec
*/
public static boolean handlesClass(SootClass declaringClass) {
return handlesClass(declaringClass.getName());
return handlesClass(declaringClass.getPathPlusClassName());
}

public static boolean handlesClass(String declaringClassName) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/soot/Printer.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ private String printSignature(SootClass sootClass) {
if (customClassSignaturePrinter != null) {
return customClassSignaturePrinter.apply(sootClass);
} else {
return Scene.v().quotedNameOf(sootClass.getName());
return Scene.v().quotedNameOf(sootClass.getPathPlusClassName());
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/soot/RefType.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ public static RefType v(String className) {
*/
public static RefType v(SootClass c) {
if (ModuleUtil.module_mode()) {
return ModuleRefType.v(c.getName(), Optional.fromNullable(c.moduleName));
return ModuleRefType.v(c.getPathPlusClassName(), Optional.fromNullable(c.moduleName));
} else {
return v(c.getName());
return v(c.getPathPlusClassName());
}
}

Expand Down
Loading