Tabnine Logo
SootClass.addMethod
Code IndexAdd Tabnine to your IDE (free)

How to use
addMethod
method
in
soot.SootClass

Best Java code snippets using soot.SootClass.addMethod (Showing top 20 results out of 315)

origin: Sable/soot

private void addProcedureToClass(soot.SootMethod method) {
 sootClass.addMethod(method);
}
origin: Sable/soot

/**
 * Changes the set of parameter types of this method.
 */
public synchronized void setParameterTypes(List<Type> l) {
 boolean wasDeclared = isDeclared;
 SootClass oldDeclaringClass = declaringClass;
 if (wasDeclared) {
  oldDeclaringClass.removeMethod(this);
 }
 this.parameterTypes = l.toArray(new Type[l.size()]);
 subSig = null;
 sig = null;
 subsignature = Scene.v().getSubSigNumberer().findOrAdd(getSubSignature());
 if (wasDeclared) {
  oldDeclaringClass.addMethod(this);
 }
}
origin: Sable/soot

public MonitorConverter(Singletons.Global g) {
 SootClass davaMonitor = new SootClass("soot.dava.toolkits.base.DavaMonitor.DavaMonitor", Modifier.PUBLIC);
 davaMonitor.setSuperclass(Scene.v().loadClassAndSupport("java.lang.Object"));
 LinkedList objectSingleton = new LinkedList();
 objectSingleton.add(RefType.v("java.lang.Object"));
 v = Scene.v().makeSootMethod("v", new LinkedList(), RefType.v("soot.dava.toolkits.base.DavaMonitor.DavaMonitor"),
   Modifier.PUBLIC | Modifier.STATIC);
 enter = Scene.v().makeSootMethod("enter", objectSingleton, VoidType.v(), Modifier.PUBLIC | Modifier.SYNCHRONIZED);
 exit = Scene.v().makeSootMethod("exit", objectSingleton, VoidType.v(), Modifier.PUBLIC | Modifier.SYNCHRONIZED);
 davaMonitor.addMethod(v);
 davaMonitor.addMethod(enter);
 davaMonitor.addMethod(exit);
 Scene.v().addClass(davaMonitor);
}
origin: Sable/soot

public void outAMethodMember(AMethodMember node) {
 int modifier = 0;
 Type type;
 String name;
 List parameterList = null;
 List<SootClass> throwsClause = null;
 if (node.getThrowsClause() != null) {
  throwsClause = (List<SootClass>) mProductions.removeLast();
 }
 if (node.getParameterList() != null) {
  parameterList = (List) mProductions.removeLast();
 } else {
  parameterList = new ArrayList();
 }
 Object o = mProductions.removeLast();
 name = (String) o;
 type = (Type) mProductions.removeLast();
 modifier = processModifiers(node.getModifier());
 SootMethod method;
 if (throwsClause != null) {
  method = Scene.v().makeSootMethod(name, parameterList, type, modifier, throwsClause);
 } else {
  method = Scene.v().makeSootMethod(name, parameterList, type, modifier);
 }
 mSootClass.addMethod(method);
}
origin: Sable/soot

private void addDispatch(String name, SootClass tclass, MethodType implMethodType, MethodType instantiatedMethodType,
  List<SootField> capFields, MethodHandle implMethod) {
 ThunkMethodSource ms = new ThunkMethodSource(capFields, implMethodType, implMethod, instantiatedMethodType);
 SootMethod m = new SootMethod(name, implMethodType.getParameterTypes(), implMethodType.getReturnType(), Modifier.PUBLIC);
 tclass.addMethod(m);
 m.setSource(ms);
}
origin: Sable/soot

/** Sets the name of this method. */
public synchronized void setName(String name) {
 boolean wasDeclared = isDeclared;
 SootClass oldDeclaringClass = declaringClass;
 if (wasDeclared) {
  oldDeclaringClass.removeMethod(this);
 }
 this.name = name;
 subSig = null;
 sig = null;
 subsignature = Scene.v().getSubSigNumberer().findOrAdd(getSubSignature());
 if (wasDeclared) {
  oldDeclaringClass.addMethod(this);
 }
}
origin: Sable/soot

/** Sets the return type of this method. */
public synchronized void setReturnType(Type t) {
 boolean wasDeclared = isDeclared;
 SootClass oldDeclaringClass = declaringClass;
 if (wasDeclared) {
  oldDeclaringClass.removeMethod(this);
 }
 returnType = t;
 subSig = null;
 sig = null;
 subsignature = Scene.v().getSubSigNumberer().findOrAdd(getSubSignature());
 if (wasDeclared) {
  oldDeclaringClass.addMethod(this);
 }
}
origin: Sable/soot

/**
 * @ast method
 * @aspect EmitJimple
 * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/JimpleBackend/EmitJimple.jrag:145
 */
public void jimplify1phase2() {
  if (needsClinit() && !getSootClassDecl().declaresMethod("<clinit>", new ArrayList())) {
    clinit = Scene.v().makeSootMethod("<clinit>", new ArrayList(), soot.VoidType.v(), soot.Modifier.STATIC,
        new ArrayList());
    getSootClassDecl().addMethod(clinit);
  }
  for (Iterator iter = nestedTypes().iterator(); iter.hasNext();) {
    TypeDecl typeDecl = (TypeDecl) iter.next();
    typeDecl.jimplify1phase2();
  }
  for (int i = 0; i < getNumBodyDecl(); i++)
    if (getBodyDecl(i).generate())
      getBodyDecl(i).jimplify1phase2();
  addAttributes();
}
origin: Sable/soot

mSootClass.addMethod(method);
origin: Sable/soot

/**
 * Loads a single method from a dex file
 *
 * @param method
 *          The method to load
 * @param declaringClass
 *          The class that declares the method to load
 * @param annotations
 *          The worker object for handling annotations
 * @param dexMethodFactory
 *          The factory method for creating dex methods
 */
protected void loadMethod(Method method, SootClass declaringClass, DexAnnotation annotations, DexMethod dexMethodFactory) {
 SootMethod sm = dexMethodFactory.makeSootMethod(method);
 if (declaringClass.declaresMethod(sm.getName(), sm.getParameterTypes(), sm.getReturnType())) {
  return;
 }
 declaringClass.addMethod(sm);
 annotations.handleMethodAnnotation(sm, method);
}
origin: Sable/soot

private soot.SootMethod makeLiFieldAccessMethod(soot.SootClass classToInvoke, polyglot.types.LocalInstance li) {
 String name = "access$" + soot.javaToJimple.InitialResolver.v().getNextPrivateAccessCounter() + "00";
 ArrayList paramTypes = new ArrayList();
 paramTypes.add(classToInvoke.getType());
 soot.SootMethod meth = Scene.v().makeSootMethod(name, paramTypes, Util.getSootType(li.type()), soot.Modifier.STATIC);
 classToInvoke.addMethod(meth);
 PrivateFieldAccMethodSource src
   = new PrivateFieldAccMethodSource(Util.getSootType(li.type()), "val$" + li.name(), false, classToInvoke);
 meth.setActiveBody(src.getBody(meth, null));
 meth.addTag(new soot.tagkit.SyntheticTag());
 return meth;
}
origin: Sable/soot

private static soot.SootMethod makeOuterThisAccessMethod(soot.SootClass classToInvoke) {
 String name = "access$" + soot.javaToJimple.InitialResolver.v().getNextPrivateAccessCounter() + "00";
 ArrayList paramTypes = new ArrayList();
 paramTypes.add(classToInvoke.getType());
 soot.SootMethod meth
   = Scene.v().makeSootMethod(name, paramTypes, classToInvoke.getFieldByName("this$0").getType(), soot.Modifier.STATIC);
 classToInvoke.addMethod(meth);
 PrivateFieldAccMethodSource src = new PrivateFieldAccMethodSource(classToInvoke.getFieldByName("this$0").getType(),
   "this$0", classToInvoke.getFieldByName("this$0").isStatic(), classToInvoke);
 meth.setActiveBody(src.getBody(meth, null));
 meth.addTag(new soot.tagkit.SyntheticTag());
 return meth;
}
origin: Sable/soot

addToClass.addMethod(sootMethod);
sootMethod.addTag(new soot.tagkit.SyntheticTag());
origin: Sable/soot

/**
 * @ast method
 * @aspect EmitJimple
 * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/JimpleBackend/EmitJimple.jrag:210
 */
public void jimplify1phase2() {
  String name = name();
  ArrayList parameters = new ArrayList();
  ArrayList paramnames = new ArrayList();
  for (int i = 0; i < getNumParameter(); i++) {
    parameters.add(getParameter(i).type().getSootType());
    paramnames.add(getParameter(i).name());
  }
  soot.Type returnType = type().getSootType();
  int modifiers = sootTypeModifiers();
  ArrayList throwtypes = new ArrayList();
  for (int i = 0; i < getNumException(); i++)
    throwtypes.add(getException(i).type().getSootClassDecl());
  String signature = SootMethod.getSubSignature(name, parameters, returnType);
  if (!hostType().getSootClassDecl().declaresMethod(signature)) {
    SootMethod m = Scene.v().makeSootMethod(name, parameters, returnType, modifiers, throwtypes);
    hostType().getSootClassDecl().addMethod(m);
    m.addTag(new soot.tagkit.ParamNamesTag(paramnames));
    sootMethod = m;
  } else {
    sootMethod = hostType().getSootClassDecl().getMethod(signature);
  }
  addAttributes();
}
origin: Sable/soot

private SootMethod getOrCreateInitializer(SootClass sc, Set<SootField> alreadyInitialized) {
 SootMethod smInit;
 // Create a static initializer if we don't already have one
 smInit = sc.getMethodByNameUnsafe(SootMethod.staticInitializerName);
 if (smInit == null) {
  smInit = Scene.v().makeSootMethod(SootMethod.staticInitializerName, Collections.<Type>emptyList(), VoidType.v());
  smInit.setActiveBody(Jimple.v().newBody(smInit));
  sc.addMethod(smInit);
  smInit.setModifiers(Modifier.PUBLIC | Modifier.STATIC);
 } else if (smInit.isPhantom()) {
  return null;
 } else {
  smInit.retrieveActiveBody();
  // We need to collect those variables that are already initialized
  // somewhere
  for (Unit u : smInit.getActiveBody().getUnits()) {
   Stmt s = (Stmt) u;
   for (ValueBox vb : s.getDefBoxes()) {
    if (vb.getValue() instanceof FieldRef) {
     alreadyInitialized.add(((FieldRef) vb.getValue()).getField());
    }
   }
  }
 }
 return smInit;
}
origin: Sable/soot

private soot.SootMethod addGetMethodAccessMeth(soot.SootClass conClass, polyglot.ast.Call call) {
 if ((InitialResolver.v().getPrivateMethodGetAccessMap() != null) && (InitialResolver.v().getPrivateMethodGetAccessMap()
   .containsKey(new polyglot.util.IdentityKey(call.methodInstance())))) {
  return InitialResolver.v().getPrivateMethodGetAccessMap().get(new polyglot.util.IdentityKey(call.methodInstance()));
 }
 String name = "access$" + soot.javaToJimple.InitialResolver.v().getNextPrivateAccessCounter() + "00";
 ArrayList paramTypes = new ArrayList();
 if (!call.methodInstance().flags().isStatic()) {
  // add this param type
  // paramTypes.add(Util.getSootType(call.methodInstance().container()));
  paramTypes.add(conClass.getType());
 }
 ArrayList sootParamsTypes = getSootParamsTypes(call);
 paramTypes.addAll(sootParamsTypes);
 soot.SootMethod meth = Scene.v().makeSootMethod(name, paramTypes, Util.getSootType(call.methodInstance().returnType()),
   soot.Modifier.STATIC);
 PrivateMethodAccMethodSource pmams = new PrivateMethodAccMethodSource(call.methodInstance());
 conClass.addMethod(meth);
 meth.setActiveBody(pmams.getBody(meth, null));
 InitialResolver.v().addToPrivateMethodGetAccessMap(call, meth);
 meth.addTag(new soot.tagkit.SyntheticTag());
 return meth;
}
origin: Sable/soot

private soot.SootMethod addGetFieldAccessMeth(soot.SootClass conClass, polyglot.ast.Field field) {
 if ((InitialResolver.v().getPrivateFieldGetAccessMap() != null) && (InitialResolver.v().getPrivateFieldGetAccessMap()
   .containsKey(new polyglot.util.IdentityKey(field.fieldInstance())))) {
  return InitialResolver.v().getPrivateFieldGetAccessMap().get(new polyglot.util.IdentityKey(field.fieldInstance()));
 }
 String name = "access$" + soot.javaToJimple.InitialResolver.v().getNextPrivateAccessCounter() + "00";
 ArrayList paramTypes = new ArrayList();
 if (!field.flags().isStatic()) {
  // add this param type
  paramTypes.add(conClass.getType());// (soot.Local)getBaseLocal(field.target()));
  // paramTypes.add(Util.getSootType(field.target().type()));
 }
 soot.SootMethod meth = Scene.v().makeSootMethod(name, paramTypes, Util.getSootType(field.type()), soot.Modifier.STATIC);
 PrivateFieldAccMethodSource pfams
   = new PrivateFieldAccMethodSource(Util.getSootType(field.type()), field.name(), field.flags().isStatic(), conClass);
 conClass.addMethod(meth);
 meth.setActiveBody(pfams.getBody(meth, null));
 InitialResolver.v().addToPrivateFieldGetAccessMap(field, meth);
 meth.addTag(new soot.tagkit.SyntheticTag());
 return meth;
}
origin: Sable/soot

private soot.SootMethod addSetAccessMeth(soot.SootClass conClass, polyglot.ast.Field field, soot.Value param) {
 if ((InitialResolver.v().getPrivateFieldSetAccessMap() != null) && (InitialResolver.v().getPrivateFieldSetAccessMap()
   .containsKey(new polyglot.util.IdentityKey(field.fieldInstance())))) {
  return InitialResolver.v().getPrivateFieldSetAccessMap().get(new polyglot.util.IdentityKey(field.fieldInstance()));
 }
 String name = "access$" + soot.javaToJimple.InitialResolver.v().getNextPrivateAccessCounter() + "00";
 ArrayList paramTypes = new ArrayList();
 if (!field.flags().isStatic()) {
  // add this param type
  paramTypes.add(conClass.getType());
  // paramTypes.add(Util.getSootType(field.target().type()));
 }
 soot.Type retType;
 paramTypes.add(Util.getSootType(field.type()));
 retType = Util.getSootType(field.type());
 /*
  * if (param.getType() instanceof soot.NullType){ paramTypes.add(soot.RefType.v("java.lang.Object")); retType =
  * soot.RefType.v("java.lang.Object"); } else { paramTypes.add(param.getType()); retType = param.getType(); }
  */
 soot.SootMethod meth = Scene.v().makeSootMethod(name, paramTypes, retType, soot.Modifier.STATIC);
 PrivateFieldSetMethodSource pfsms
   = new PrivateFieldSetMethodSource(Util.getSootType(field.type()), field.name(), field.flags().isStatic());
 conClass.addMethod(meth);
 meth.setActiveBody(pfsms.getBody(meth, null));
 InitialResolver.v().addToPrivateFieldSetAccessMap(field, meth);
 meth.addTag(new soot.tagkit.SyntheticTag());
 return meth;
}
origin: Sable/soot

private soot.SootMethod makeSuperAccessMethod(soot.SootClass classToInvoke, Object memberToAccess) {
 String name = "access$" + soot.javaToJimple.InitialResolver.v().getNextPrivateAccessCounter() + "00";
 ArrayList paramTypes = new ArrayList();
 paramTypes.add(classToInvoke.getType());
 soot.SootMethod meth;
 soot.MethodSource src;
 if (memberToAccess instanceof polyglot.ast.Field) {
  polyglot.ast.Field fieldToAccess = (polyglot.ast.Field) memberToAccess;
  meth = Scene.v().makeSootMethod(name, paramTypes, Util.getSootType(fieldToAccess.type()), soot.Modifier.STATIC);
  PrivateFieldAccMethodSource fSrc = new PrivateFieldAccMethodSource(Util.getSootType(fieldToAccess.type()),
    fieldToAccess.name(), fieldToAccess.flags().isStatic(),
    ((soot.RefType) Util.getSootType(fieldToAccess.target().type())).getSootClass());
  src = fSrc;
 } else if (memberToAccess instanceof polyglot.ast.Call) {
  polyglot.ast.Call methToAccess = (polyglot.ast.Call) memberToAccess;
  paramTypes.addAll(getSootParamsTypes(methToAccess));
  meth = Scene.v().makeSootMethod(name, paramTypes, Util.getSootType(methToAccess.methodInstance().returnType()),
    soot.Modifier.STATIC);
  PrivateMethodAccMethodSource mSrc = new PrivateMethodAccMethodSource(methToAccess.methodInstance());
  src = mSrc;
 } else {
  throw new RuntimeException("trying to access unhandled member type: " + memberToAccess);
 }
 classToInvoke.addMethod(meth);
 meth.setActiveBody(src.getBody(meth, null));
 meth.addTag(new soot.tagkit.SyntheticTag());
 return meth;
}
origin: Sable/soot

final SootMethod staticInitializerMethod = Scene.v().makeSootMethod(SootMethod.staticInitializerName,
  Collections.emptyList(), VoidType.v(), Modifier.STATIC);
sootClass.addMethod(staticInitializerMethod);
body = Jimple.v().newBody(staticInitializerMethod);
staticInitializerMethod.setActiveBody(body);
sootSootClassaddMethod

Javadoc

Adds the given method to this class.

Popular methods of SootClass

  • isInterface
    Convenience method; returns true if this class is an interface.
  • getMethods
  • getName
    Returns the name of this class.
  • setApplicationClass
    Makes this class an application class.
  • getFields
    Returns a backed Chain of fields.
  • getInterfaces
    Returns a backed Chain of the interfaces that are directly implemented by this class. (see getInterf
  • getSuperclass
    WARNING: interfaces are subclasses of the java.lang.Object class! Returns the superclass of this cla
  • hasSuperclass
    WARNING: interfaces are subclasses of the java.lang.Object class! Does this class have a superclass?
  • resolvingLevel
  • declaresMethod
    Does this class declare a method with the given subsignature?
  • getMethod
  • getType
    Returns the RefType corresponding to this class.
  • getMethod,
  • getType,
  • isApplicationClass,
  • isLibraryClass,
  • addField,
  • isAbstract,
  • isPhantom,
  • <init>,
  • declaresField

Popular in Java

  • Running tasks concurrently on multiple threads
  • addToBackStack (FragmentTransaction)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • requestLocationUpdates (LocationManager)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • Collectors (java.util.stream)
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now