org.jf.dexlib2.iface.Method.getImplementation()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(116)

本文整理了Java中org.jf.dexlib2.iface.Method.getImplementation()方法的一些代码示例,展示了Method.getImplementation()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Method.getImplementation()方法的具体详情如下:
包路径:org.jf.dexlib2.iface.Method
类名称:Method
方法名:getImplementation

Method.getImplementation介绍

[英]Gets a MethodImplementation object that defines the implementation of the method. If this is an abstract method in an abstract class, or an interface method in an interface definition, then the method has no implementation, and this will return null.
[中]获取定义方法实现的MethodImplementation对象。如果这是抽象类中的抽象方法,或者是接口定义中的接口方法,那么该方法没有实现,这将返回null。

代码示例

代码示例来源:origin: JesusFreke/smali

@Nullable @Override public MethodImplementation getImplementation() {
    return method.getImplementation();
  }
}

代码示例来源:origin: CalebFenton/simplify

private String[] buildExceptions(Method method) {
  if (method.getImplementation() == null) {
    return null;
  }
  Set<String> exceptionTypes = new HashSet<>();
  for (TryBlock<? extends ExceptionHandler> tryBlock : method.getImplementation()
      .getTryBlocks()) {
    for (ExceptionHandler handler : tryBlock.getExceptionHandlers()) {
      String type = handler.getExceptionType();
      if (type == null) {
        // Type is null if it's a catchall
        continue;
      }
      exceptionTypes.add(stripName(type));
    }
  }
  return exceptionTypes.toArray(new String[0]);
}

代码示例来源:origin: JesusFreke/smali

public MethodAnalyzer(@Nonnull ClassPath classPath, @Nonnull Method method,
           @Nullable InlineMethodResolver inlineResolver, boolean normalizeVirtualMethods) {
  this.classPath = classPath;
  this.inlineResolver = inlineResolver;
  this.normalizeVirtualMethods = normalizeVirtualMethods;
  this.method = method;
  MethodImplementation methodImpl = method.getImplementation();
  if (methodImpl == null) {
    throw new IllegalArgumentException("The method has no implementation");
  }
  this.methodImpl = methodImpl;
  // Override AnalyzedInstruction and provide custom implementations of some of the methods, so that we don't
  // have to handle the case this special case of instruction being null, in the main class
  startOfMethod = new AnalyzedInstruction(this, new ImmutableInstruction10x(Opcode.NOP), -1, methodImpl.getRegisterCount()) {
    @Override protected boolean addPredecessor(AnalyzedInstruction predecessor) {
      throw new UnsupportedOperationException();
    }
    @Override @Nonnull
    public RegisterType getPredecessorRegisterType(@Nonnull AnalyzedInstruction predecessor, int registerNumber) {
      throw new UnsupportedOperationException();
    }
  };
  buildInstructionList();
  analyzedState = new BitSet(analyzedInstructions.size());
  paramRegisterCount = MethodUtil.getParameterRegisterCount(method);
  analyze();
}

代码示例来源:origin: Sable/soot

MethodImplementation code = method.getImplementation();
if (code == null) {
 throw new RuntimeException("error: no code for method " + method.getName());

代码示例来源:origin: Tencent/tinker

MethodImplementation methodImpl = method.getImplementation();
if (methodImpl != null) {
  methodImpl = new BuilderMutableMethodImplementation(dexBuilder, methodImpl);

代码示例来源:origin: CalebFenton/simplify

String[] exceptions = buildExceptions(method);
MethodVisitor mv = classWriter.visitMethod(access, name, desc, signature, exceptions);
if (method.getImplementation() != null) {
  if (method.getName().equals("<init>") && desc.equals("()V")) {
    hasDefaultConstructor = true;

代码示例来源:origin: JesusFreke/smali

private void internDebug(@Nonnull Method method) {
  for (MethodParameter param: method.getParameters()) {
    String paramName = param.getName();
    if (paramName != null) {
      dexPool.stringSection.intern(paramName);
    }
  }
  MethodImplementation methodImpl = method.getImplementation();
  if (methodImpl != null) {
    for (DebugItem debugItem: methodImpl.getDebugItems()) {
      switch (debugItem.getDebugItemType()) {
        case DebugItemType.START_LOCAL:
          StartLocal startLocal = (StartLocal)debugItem;
          dexPool.stringSection.internNullable(startLocal.getName());
          dexPool.typeSection.internNullable(startLocal.getType());
          dexPool.stringSection.internNullable(startLocal.getSignature());
          break;
        case DebugItemType.SET_SOURCE_FILE:
          dexPool.stringSection.internNullable(((SetSourceFile) debugItem).getSourceFile());
          break;
      }
    }
  }
}

代码示例来源:origin: JesusFreke/smali

MethodImplementation methodImpl = method.getImplementation();
if (methodImpl != null) {
  for (Instruction instruction: methodImpl.getInstructions()) {

代码示例来源:origin: testwhat/SmaliEx

@Override @Nullable public MethodImplementation getImplementation() {
    return method.getImplementation();
  }
}

代码示例来源:origin: org.smali/dexlib2

@Nullable @Override public MethodImplementation getImplementation() {
    return method.getImplementation();
  }
}

代码示例来源:origin: wala/WALA

@Override
public boolean hasExceptionHandler() {
  List<? extends TryBlock<? extends org.jf.dexlib2.iface.ExceptionHandler>> tries = eMethod.getImplementation().getTryBlocks();
  return tries==null?false:tries.size() > 0;
}

代码示例来源:origin: wala/WALA

/**
 * XXX not fully about the + 2.
 * @return the RegisterCount + 2 to make some room for the return and exception register
 * @see com.ibm.wala.classLoader.ShrikeCTMethod#getMaxLocals()
 */
public int getMaxLocals() {
  return eMethod.getImplementation().getRegisterCount() + 2;
}

代码示例来源:origin: com.ibm.wala/com.ibm.wala.dalvik

/**
 * XXX not fully about the + 2.
 * @return the RegisterCount + 2 to make some room for the return and exception register
 * @see com.ibm.wala.classLoader.ShrikeCTMethod#getMaxLocals()
 */
public int getMaxLocals() {
  return eMethod.getImplementation().getRegisterCount() + 2;
}

代码示例来源:origin: com.ibm.wala/com.ibm.wala.dalvik

@Override
public boolean hasExceptionHandler() {
  List<? extends TryBlock<? extends org.jf.dexlib2.iface.ExceptionHandler>> tries = eMethod.getImplementation().getTryBlocks();
  return tries==null?false:tries.size() > 0;
}

代码示例来源:origin: testwhat/SmaliEx

@Override @Nullable public MethodImplementation getImplementation() {
    return RewriterUtils.rewriteNullable(rewriters.getMethodImplementationRewriter(),
        method.getImplementation());
  }
}

代码示例来源:origin: org.smali/dexlib2

@Override @Nullable public MethodImplementation getImplementation() {
    return RewriterUtils.rewriteNullable(rewriters.getMethodImplementationRewriter(),
        method.getImplementation());
  }
}

代码示例来源:origin: KB5201314/ZjDroid

@Override @Nullable public MethodImplementation getImplementation() {
    return RewriterUtils.rewriteNullable(rewriters.getMethodImplementationRewriter(),
        method.getImplementation());
  }
}

代码示例来源:origin: wala/WALA

private boolean odexMethod() {
  for(org.jf.dexlib2.iface.instruction.Instruction inst : eMethod.getImplementation().getInstructions()) {
    if (inst.getOpcode().odexOnly()) {
      return true;
    }
  }
  
  return false;
}

代码示例来源:origin: com.ibm.wala/com.ibm.wala.dalvik

private boolean odexMethod() {
  for(org.jf.dexlib2.iface.instruction.Instruction inst : eMethod.getImplementation().getInstructions()) {
    if (inst.getOpcode().odexOnly()) {
      return true;
    }
  }
  
  return false;
}

代码示例来源:origin: testwhat/SmaliEx

private void verifyDexFile(DexFile dexFile) {
    Assert.assertEquals(1, dexFile.getClasses().size());
    ClassDef cls = Lists.newArrayList(dexFile.getClasses()).get(0);
    Assert.assertEquals("Lcls1;", cls.getType());
    Assert.assertEquals(1, Lists.newArrayList(cls.getMethods()).size());
    Method method = Iterators.getNext(cls.getMethods().iterator(), null);
    Assert.assertEquals("method1", method.getName());
    Assert.assertEquals(1, Lists.newArrayList(method.getImplementation().getInstructions()).size());
    Instruction instruction = Lists.newArrayList(method.getImplementation().getInstructions().iterator()).get(0);
    Assert.assertEquals(Opcode.INVOKE_CUSTOM, instruction.getOpcode());
    Assert.assertTrue(((Instruction35c) instruction).getReference() instanceof CallSiteReference);
  }
}

相关文章