@@ -165,15 +165,15 @@ public synchronized SootMethodRef makeLambdaHelper(List<? extends Value> bootstr
165
165
final boolean readableClassnames = true ;
166
166
if (readableClassnames ) {
167
167
// class names cannot contain <>
168
- String implMethodName = implMethod .getMethodRef ().name ();
168
+ String implMethodName = implMethod .getMethodRef ().getName ();
169
169
String dummyName = "<init>" .equals (implMethodName ) ? "init" : implMethodName ;
170
170
// XXX: $ causes confusion in inner class inference; remove for now
171
171
dummyName = dummyName .replaceAll ("\\ $" , "_" );
172
172
className = enclosingClassnamePrefix + dummyName + "__" + uniqSupply ();
173
173
} else {
174
174
className = "soot.dummy.lambda" + uniqSupply ();
175
175
}
176
- SootClass tclass = new SootClass (className );
176
+ SootClass tclass = Scene . v (). makeSootClass (className );
177
177
tclass .setModifiers (Modifier .PUBLIC | Modifier .FINAL );
178
178
tclass .setSuperclass (Scene .v ().getObjectType ().getSootClass ());
179
179
tclass .addInterface (functionalInterfaceToImplement );
@@ -189,17 +189,17 @@ public synchronized SootMethodRef makeLambdaHelper(List<? extends Value> bootstr
189
189
// It contains fields for all the captures in the lambda
190
190
List <SootField > capFields = new ArrayList <SootField >(capTypes .size ());
191
191
for (int i = 0 ; i < capTypes .size (); i ++) {
192
- SootField f = new SootField ("cap" + i , capTypes .get (i ), 0 );
192
+ SootField f = Scene . v (). makeSootField ("cap" + i , capTypes .get (i ), 0 );
193
193
capFields .add (f );
194
194
tclass .addField (f );
195
195
}
196
196
197
197
// if the implMethod is a new private static in the enclosing class, make it public access so
198
198
// it can be invoked from the thunk class
199
199
if (MethodHandle .Kind .REF_INVOKE_STATIC .getValue () == implMethod .getKind ()) {
200
- if ( implMethod .getMethodRef ().declaringClass (). getName (). equals ( enclosingClassname )) {
201
- SootMethod method
202
- = implMethod . getMethodRef (). declaringClass () .getMethod (implMethod .getMethodRef ().getSubSignature ());
200
+ SootClass declClass = implMethod .getMethodRef ().getDeclaringClass ();
201
+ if ( declClass . getName (). equals ( enclosingClassname )) {
202
+ SootMethod method = declClass .getMethod (implMethod .getMethodRef ().getSubSignature ());
203
203
int modifiers = method .getModifiers () & ~Modifier .PRIVATE ;
204
204
modifiers = modifiers | Modifier .PUBLIC ;
205
205
method .setModifiers (modifiers );
@@ -209,13 +209,13 @@ public synchronized SootMethodRef makeLambdaHelper(List<? extends Value> bootstr
209
209
MethodSource ms = new ThunkMethodSource (capFields , samMethodType , implMethod , instantiatedMethodType );
210
210
211
211
// Bootstrap method creates a new instance of this class
212
- SootMethod tboot = new SootMethod ("bootstrap$" , capTypes , functionalInterfaceToImplement .getType (),
212
+ SootMethod tboot = Scene . v (). makeSootMethod ("bootstrap$" , capTypes , functionalInterfaceToImplement .getType (),
213
213
Modifier .PUBLIC | Modifier .STATIC );
214
214
tclass .addMethod (tboot );
215
215
tboot .setSource (ms );
216
216
217
217
// Constructor just copies the captures
218
- SootMethod tctor = new SootMethod ("<init>" , capTypes , VoidType .v (), Modifier .PUBLIC );
218
+ SootMethod tctor = Scene . v (). makeSootMethod ("<init>" , capTypes , VoidType .v (), Modifier .PUBLIC );
219
219
tclass .addMethod (tctor );
220
220
tctor .setSource (ms );
221
221
@@ -251,7 +251,8 @@ public synchronized SootMethodRef makeLambdaHelper(List<? extends Value> bootstr
251
251
private void addDispatch (String name , SootClass tclass , MethodType implMethodType , MethodType instantiatedMethodType ,
252
252
List <SootField > capFields , MethodHandle implMethod ) {
253
253
ThunkMethodSource ms = new ThunkMethodSource (capFields , implMethodType , implMethod , instantiatedMethodType );
254
- SootMethod m = new SootMethod (name , implMethodType .getParameterTypes (), implMethodType .getReturnType (), Modifier .PUBLIC );
254
+ SootMethod m = Scene .v ().makeSootMethod (name , implMethodType .getParameterTypes (), implMethodType .getReturnType (),
255
+ Modifier .PUBLIC );
255
256
tclass .addMethod (m );
256
257
m .setSource (ms );
257
258
}
@@ -294,10 +295,6 @@ public Wrapper() {
294
295
295
296
}
296
297
297
- private boolean isWrapper (Type t ) {
298
- return wrapperTypes .containsKey (t );
299
- }
300
-
301
298
}
302
299
303
300
private class ThunkMethodSource implements MethodSource {
@@ -463,7 +460,7 @@ private void getInvokeBody(SootClass tclass, JimpleBody jb) {
463
460
}
464
461
Iterator <Local > iplItr = instParamLocals .iterator ();
465
462
if (capFields .size () == 0 && iplItr .hasNext () && needsReceiver ) {
466
- RefType receiverType = implMethod .getMethodRef ().declaringClass ().getType ();
463
+ RefType receiverType = implMethod .getMethodRef ().getDeclaringClass ().getType ();
467
464
Local l = adapt (iplItr .next (), receiverType , jb , us , lc );
468
465
args .add (l );
469
466
}
@@ -476,7 +473,7 @@ private void getInvokeBody(SootClass tclass, JimpleBody jb) {
476
473
while (iplItr .hasNext ()) {
477
474
Local pl = iplItr .next ();
478
475
479
- Type to = implMethod .getMethodRef ().parameterType (j );
476
+ Type to = implMethod .getMethodRef ().getParameterType (j );
480
477
481
478
Local l = adapt (pl , to , jb , us , lc );
482
479
args .add (l );
@@ -648,7 +645,7 @@ private Local wideningPrimitiveConversion(Local fromLocal, Type to, JimpleBody j
648
645
private void invokeImplMethod (JimpleBody jb , PatchingChain <Unit > us , LocalGenerator lc , List <Local > args ) {
649
646
Value value = _invokeImplMethod (jb , us , lc , args );
650
647
651
- if (value instanceof InvokeExpr && soot .VoidType .v ().equals (implMethod .getMethodRef ().returnType ())) {
648
+ if (value instanceof InvokeExpr && soot .VoidType .v ().equals (implMethod .getMethodRef ().getReturnType ())) {
652
649
// implementation method is void
653
650
us .add (Jimple .v ().newInvokeStmt (value ));
654
651
us .add (Jimple .v ().newReturnVoidStmt ());
@@ -702,7 +699,7 @@ private Value _invokeImplMethod(JimpleBody jb, PatchingChain<Unit> us, LocalGene
702
699
return Jimple .v ().newVirtualInvokeExpr (args .get (0 ), methodRef , rest (args ));
703
700
}
704
701
case REF_INVOKE_CONSTRUCTOR :
705
- RefType type = methodRef .declaringClass ().getType ();
702
+ RefType type = methodRef .getDeclaringClass ().getType ();
706
703
NewExpr newRef = Jimple .v ().newNewExpr (type );
707
704
Local newLocal = lc .generateLocal (type );
708
705
us .add (Jimple .v ().newAssignStmt (newLocal , newRef ));
0 commit comments