@Nullable @Override public MethodImplementation getImplementation() { return method.getImplementation(); } }
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]); }
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(); }
MethodImplementation code = method.getImplementation(); if (code == null) { throw new RuntimeException("error: no code for method " + method.getName());
MethodImplementation methodImpl = method.getImplementation(); if (methodImpl != null) { methodImpl = new BuilderMutableMethodImplementation(dexBuilder, methodImpl);
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;
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; } } } }
MethodImplementation methodImpl = method.getImplementation(); if (methodImpl != null) { for (Instruction instruction: methodImpl.getInstructions()) {
@Override @Nullable public MethodImplementation getImplementation() { return method.getImplementation(); } }
@Nullable @Override public MethodImplementation getImplementation() { return method.getImplementation(); } }
@Override public boolean hasExceptionHandler() { List<? extends TryBlock<? extends org.jf.dexlib2.iface.ExceptionHandler>> tries = eMethod.getImplementation().getTryBlocks(); return tries==null?false:tries.size() > 0; }
/** * 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; }
/** * 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; }
@Override public boolean hasExceptionHandler() { List<? extends TryBlock<? extends org.jf.dexlib2.iface.ExceptionHandler>> tries = eMethod.getImplementation().getTryBlocks(); return tries==null?false:tries.size() > 0; }
@Override @Nullable public MethodImplementation getImplementation() { return RewriterUtils.rewriteNullable(rewriters.getMethodImplementationRewriter(), method.getImplementation()); } }
@Override @Nullable public MethodImplementation getImplementation() { return RewriterUtils.rewriteNullable(rewriters.getMethodImplementationRewriter(), method.getImplementation()); } }
@Override @Nullable public MethodImplementation getImplementation() { return RewriterUtils.rewriteNullable(rewriters.getMethodImplementationRewriter(), method.getImplementation()); } }
private boolean odexMethod() { for(org.jf.dexlib2.iface.instruction.Instruction inst : eMethod.getImplementation().getInstructions()) { if (inst.getOpcode().odexOnly()) { return true; } } return false; }
private boolean odexMethod() { for(org.jf.dexlib2.iface.instruction.Instruction inst : eMethod.getImplementation().getInstructions()) { if (inst.getOpcode().odexOnly()) { return true; } } return false; }
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); } }