Skip to content

Commit

Permalink
Make sure lambda method is public
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcMil authored and mbenz89 committed Jan 10, 2019
1 parent 42dd2f5 commit 4a138ea
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/main/java/soot/LambdaMetaFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ public synchronized SootMethodRef makeLambdaHelper(List<? extends Value> bootstr
if (enclosingClass.isApplicationClass()) {
tclass.setApplicationClass();
}

for (SootMethod m : tclass.getMethods()) {
// There is no reason not to load the bodies directly. After all,
// we are introducing new classes while loading bodies.
// we are introducing new classes while loading bodies.
m.retrieveActiveBody();
}

Expand Down Expand Up @@ -320,6 +320,7 @@ public ThunkMethodSource(List<SootField> capFields, MethodType implMethodType, M
this.instantiatedMethodType = instantiatedMethodType;
}

@Override
public Body getBody(SootMethod m, String phaseName) {
if (!phaseName.equals("jb")) {
throw new Error("unsupported body type: " + phaseName);
Expand Down Expand Up @@ -687,11 +688,18 @@ private Value _invokeImplMethod(JimpleBody jb, PatchingChain<Unit> us, LocalGene
final SootClass calledClass = methodRef.getDeclaringClass();
// It can be the case that the method is not in the same class (or a super class).
// As such, we need a virtual call in these cases.
if (Scene.v().getOrMakeFastHierarchy().canStoreClass(currentClass, calledClass))
{
return Jimple.v().newSpecialInvokeExpr(args.get(0), methodRef, rest(args));
if (Scene.v().getOrMakeFastHierarchy().canStoreClass(currentClass, calledClass)) {
return Jimple.v().newSpecialInvokeExpr(args.get(0), methodRef, rest(args));
} else {
return Jimple.v().newVirtualInvokeExpr(args.get(0), methodRef, rest(args));
SootMethod m = implMethod.getMethodRef().resolve();
if (!m.isPublic()) {
// make sure the method is public
int mod = Modifier.PUBLIC | m.getModifiers();
mod &= ~Modifier.PRIVATE;
mod &= ~Modifier.PROTECTED;
m.setModifiers(mod);
}
return Jimple.v().newVirtualInvokeExpr(args.get(0), methodRef, rest(args));
}
case REF_INVOKE_CONSTRUCTOR:
RefType type = methodRef.declaringClass().getType();
Expand Down

0 comments on commit 4a138ea

Please sign in to comment.