MethodId(TypeId<D> declaringType, TypeId<R> returnType, String name, TypeList parameters) { if (declaringType == null || returnType == null || name == null || parameters == null) { throw new NullPointerException(); } this.declaringType = declaringType; this.returnType = returnType; this.name = name; this.parameters = parameters; this.nat = new CstNat(new CstString(name), new CstString(descriptor(false))); this.constant = new CstMethodRef(declaringType.constant, nat); }
private void addDependencies(ConstantPool pool) { for (Constant constant : pool.getEntries()) { if (constant instanceof CstType) { checkDescriptor(((CstType) constant).getClassType()); } else if (constant instanceof CstFieldRef) { checkDescriptor(((CstFieldRef) constant).getType()); } else if (constant instanceof CstMethodRef) { Prototype proto = ((CstMethodRef) constant).getPrototype(); checkDescriptor(proto.getReturnType()); StdTypeList args = proto.getParameterTypes(); for (int i = 0; i < args.size(); i++) { checkDescriptor(args.get(i)); } } } }
/** * {@inheritDoc} * * <p><b>Note:</b> This compares the method constants only, * ignoring any associated code, because it should never be the * case that two different items with the same method constant * ever appear in the same list (or same file, even).</p> */ public int compareTo(EncodedMethod other) { return method.compareTo(other.method); }
case ByteOps.INVOKESPECIAL: { /* * Determine whether the opcode should be * INVOKE_DIRECT or INVOKE_SUPER. See vmspec-2 section 6 * on "invokespecial" as well as section 4.8.2 (7th * bullet point) for the gory details. */ CstMethodRef ref = (CstMethodRef) cst; if (ref.isInstanceInit() || (ref.getDefiningClass() == method.getDefiningClass()) || !method.getAccSuper()) { return RegOps.INVOKE_DIRECT; } return RegOps.INVOKE_SUPER;
Method one = methods.get(i); try { CstMethodRef meth = new CstMethodRef(thisClass, one.getNat()); int accessFlags = one.getAccessFlags(); boolean isStatic = AccessFlags.isStatic(accessFlags); boolean isNative = AccessFlags.isNative(accessFlags); boolean isAbstract = AccessFlags.isAbstract(accessFlags); boolean isConstructor = meth.isInstanceInit() || meth.isClassInit(); DalvCode code; int paramSize; paramSize = meth.getParameterWordCount(isStatic); new EncodedMethod(meth, accessFlags, code, exceptions); if (meth.isInstanceInit() || meth.isClassInit() || isStatic || isPrivate) { out.addDirectMethod(mi);
private static CstMethodRef makePolymorphicMethod(final CstMethodRef callSiteMethod) { CstType definingClass= callSiteMethod.getDefiningClass(); CstString cstMethodName = callSiteMethod.getNat().getName(); String methodName = callSiteMethod.getNat().getName().getString(); return new CstMethodRef(definingClass, cstNat); return new CstMethodRef(definingClass, cstNat); return new CstMethodRef(definingClass, cstNat); return new CstMethodRef(definingClass, cstNat); callSiteMethod.toHuman());
if (ref.getDefiningClass().equals(method.getDefiningClass())) { for (int i = 0; i < methods.size(); ++i) { final Method m = methods.get(i); if (AccessFlags.isPrivate(m.getAccessFlags()) && ref.getNat().equals(m.getNat())) { return RegOps.INVOKE_DIRECT; if (ref.isSignaturePolymorphic()) { return RegOps.INVOKE_POLYMORPHIC; if (ref.isInstanceInit() || (ref.getDefiningClass().equals(method.getDefiningClass()))) { return RegOps.INVOKE_DIRECT;
if (ref.getDefiningClass().equals(method.getDefiningClass())) { for (int i = 0; i < methods.size(); ++i) { final Method m = methods.get(i); if (AccessFlags.isPrivate(m.getAccessFlags()) && ref.getNat().equals(m.getNat())) { return RegOps.INVOKE_DIRECT; if (ref.isInstanceInit() || (ref.getDefiningClass().equals(method.getDefiningClass())) || !method.getAccSuper()) { return RegOps.INVOKE_DIRECT;
/** {@inheritDoc} */ public boolean equals(Object other) { if (! (other instanceof MethodAnnotationStruct)) { return false; } return method.equals(((MethodAnnotationStruct) other).method); }
/** {@inheritDoc} */ @Override public String toHuman() { return ref.toHuman(); }
/** {@inheritDoc} */ @Override public int hashCode() { return method.hashCode(); }
private static CstMethodRef makeInvokeMethod(final CstMethodRef callSiteMethod) { // The name is either invoke or invokeExact. The INVOKE_DESCRIPTOR is fixed. CstNat cstNat = new CstNat(callSiteMethod.getNat().getName(), INVOKE_DESCRIPTOR); return new CstMethodRef(CstType.METHOD_HANDLE, cstNat); }
/** * Get the in registers count. * * @return the count */ private int getInsSize() { return ref.getParameterWordCount(isStatic); }
/** {@inheritDoc} */ @Override public final CstString getName() { return method.getNat().getName(); }
/** * Extracts the code block from the given method of the given class, or * <code>null</code>, if method is native or abstract. */ private static DalvCode getCode(Method method, DirectClassFile classFile) { boolean isNative= AccessFlags.isNative(method.getAccessFlags()); boolean isStatic= AccessFlags.isStatic(method.getAccessFlags()); boolean isAbstract= AccessFlags.isAbstract(method.getAccessFlags()); if (isNative || isAbstract) { return null; } ConcreteMethod concrete= new ConcreteMethod(method, classFile, false, false); TranslationAdvice advice= DexTranslationAdvice.THE_ONE; RopMethod rmeth= Ropper.convert(concrete, advice); CstMethodRef meth= new CstMethodRef(method.getDefiningClass(), method.getNat()); int paramSize= meth.getParameterWordCount(isStatic); DalvCode code= RopTranslator.translate(rmeth, PositionList.NONE, null, paramSize); DalvCode.AssignIndicesCallback callback= new DalvCode.AssignIndicesCallback() { public int getIndex(Constant cst) { // Everything is at index 0! return 0; } }; code.assignIndices(callback); return code; }
"invoking a %s interface method %s.%s strictly requires " + "--min-sdk-version >= %d (experimental at current API level %d)", invokeKind, callee.getDefiningClass().toHuman(), callee.getNat().toHuman(), DexFormat.API_INVOKE_INTERFACE_METHODS, dexOptions.minSdkVersion); warn(reason); "invoking a %s interface method %s.%s strictly requires " + "--min-sdk-version >= %d (blocked at current API level %d)", invokeKind, callee.getDefiningClass().toHuman(), callee.getNat().toHuman(), DexFormat.API_INVOKE_INTERFACE_METHODS, dexOptions.minSdkVersion); fail(reason);
Method one = methods.get(i); try { CstMethodRef meth = new CstMethodRef(thisClass, one.getNat()); int accessFlags = one.getAccessFlags(); boolean isStatic = AccessFlags.isStatic(accessFlags); boolean isNative = AccessFlags.isNative(accessFlags); boolean isAbstract = AccessFlags.isAbstract(accessFlags); boolean isConstructor = meth.isInstanceInit() || meth.isClassInit(); DalvCode code; int paramSize; paramSize = meth.getParameterWordCount(isStatic); new EncodedMethod(meth, accessFlags, code, exceptions); if (meth.isInstanceInit() || meth.isClassInit() || isStatic || isPrivate) { out.addDirectMethod(mi);
if (ref.getDefiningClass().equals(method.getDefiningClass())) { for (int i = 0; i < methods.size(); ++i) { final Method m = methods.get(i); if (AccessFlags.isPrivate(m.getAccessFlags()) && ref.getNat().equals(m.getNat())) { return RegOps.INVOKE_DIRECT; if (ref.isSignaturePolymorphic()) { return RegOps.INVOKE_POLYMORPHIC; if (ref.isInstanceInit()) { return RegOps.INVOKE_DIRECT; } else if (ref.getDefiningClass().equals(method.getDefiningClass())) { for (int i = 0; i < methods.size(); ++i) { final Method m = methods.get(i); if (!ref.getNat().equals(m.getNat())) { continue;
if (ref.getDefiningClass().equals(method.getDefiningClass())) { for (int i = 0; i < methods.size(); ++i) { final Method m = methods.get(i); if (AccessFlags.isPrivate(m.getAccessFlags()) && ref.getNat().equals(m.getNat())) { return RegOps.INVOKE_DIRECT; if (ref.isInstanceInit() || (ref.getDefiningClass().equals(method.getDefiningClass())) || !method.getAccSuper()) { return RegOps.INVOKE_DIRECT;
/** {@inheritDoc} */ @Override public boolean equals(Object other) { if (! (other instanceof MethodAnnotationStruct)) { return false; } return method.equals(((MethodAnnotationStruct) other).method); }