本文整理汇总了Java中org.jf.dexlib2.iface.reference.MethodReference类的典型用法代码示例。如果您正苦于以下问题:Java MethodReference类的具体用法?Java MethodReference怎么用?Java MethodReference使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MethodReference类属于org.jf.dexlib2.iface.reference包,在下文中一共展示了MethodReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMethodDescriptor
import org.jf.dexlib2.iface.reference.MethodReference; //导入依赖的package包/类
public static String getMethodDescriptor(MethodReference methodReference, boolean useImplicitReference) {
StringBuilder sb = new StringBuilder();
if (!useImplicitReference) {
String clazz = methodReference.getDefiningClass();//TypeGenUtil.newType(methodReference.getDefiningClass());
sb.append(clazz);
sb.append("->");
}
sb.append(methodReference.getName());
sb.append('(');
for (CharSequence paramType : methodReference.getParameterTypes()) {
sb.append(paramType);
}
sb.append(')');
sb.append(methodReference.getReturnType());
return sb.toString();
}
示例2: writeReference
import org.jf.dexlib2.iface.reference.MethodReference; //导入依赖的package包/类
public static void writeReference(IndentingWriter writer, int referenceType,
Reference reference) throws IOException {
switch (referenceType) {
case ReferenceType.STRING:
writeStringReference(writer, ((StringReference)reference).getString());
return;
case ReferenceType.TYPE:
writer.write(((TypeReference)reference).getType());
return;
case ReferenceType.METHOD:
ReferenceUtil.writeMethodDescriptor(writer, (MethodReference) reference);
return;
case ReferenceType.FIELD:
ReferenceUtil.writeFieldDescriptor(writer, (FieldReference)reference);
return;
default:
throw new IllegalStateException("Unknown reference type");
}
}
示例3: analyzeMoveResult
import org.jf.dexlib2.iface.reference.MethodReference; //导入依赖的package包/类
private void analyzeMoveResult(@Nonnull AnalyzedInstruction analyzedInstruction) {
AnalyzedInstruction previousInstruction = analyzedInstructions.valueAt(analyzedInstruction.instructionIndex-1);
if (!previousInstruction.instruction.getOpcode().setsResult()) {
throw new AnalysisException(analyzedInstruction.instruction.getOpcode().name + " must occur after an " +
"invoke-*/fill-new-array instruction");
}
RegisterType resultRegisterType;
ReferenceInstruction invokeInstruction = (ReferenceInstruction)previousInstruction.instruction;
Reference reference = invokeInstruction.getReference();
if (reference instanceof MethodReference) {
resultRegisterType = RegisterType.getRegisterType(classPath, ((MethodReference)reference).getReturnType());
} else {
resultRegisterType = RegisterType.getRegisterType(classPath, (TypeReference)reference);
}
setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, resultRegisterType);
}
示例4: isUsedAsFloatingPoint
import org.jf.dexlib2.iface.reference.MethodReference; //导入依赖的package包/类
/**
* Determine if register is used as floating point.
*
* Abstraction for static and non-static methods. Non-static methods need to ignore the first parameter (this)
* @param isStatic if this method is static
*/
protected boolean isUsedAsFloatingPoint(DexBody body, int register, boolean isStatic) {
MethodReference item = (MethodReference) ((ReferenceInstruction) instruction).getReference();
List<? extends CharSequence> paramTypes = item.getParameterTypes();
List<Integer> regs = getUsedRegistersNums();
if (paramTypes == null)
return false;
for (int i = 0, j = 0; i < regs.size(); i++, j++) {
if (!isStatic && i == 0) {
j--;
continue;
}
if (regs.get(i) == register && isFloatLike(DexType.toSoot(paramTypes.get(j).toString())))
return true;
if (DexType.isWide(paramTypes.get(j).toString()))
i++;
}
return false;
}
示例5: isUsedAsObject
import org.jf.dexlib2.iface.reference.MethodReference; //导入依赖的package包/类
/**
* Determine if register is used as object.
*
* Abstraction for static and non-static methods. Non-static methods need to ignore the first parameter (this)
* @param isStatic if this method is static
*/
protected boolean isUsedAsObject(DexBody body, int register, boolean isStatic) {
MethodReference item = (MethodReference) ((ReferenceInstruction) instruction).getReference();
List<? extends CharSequence> paramTypes = item.getParameterTypes();
List<Integer> regs = getUsedRegistersNums();
if (paramTypes == null)
return false;
// we call a method on the register
if (!isStatic && regs.get(0) == register)
return true;
// we call a method with register as a reftype paramter
for (int i = 0, j = 0; i < regs.size(); i++, j++) {
if (!isStatic && i == 0) {
j--;
continue;
}
if (regs.get(i) == register && (DexType.toSoot(paramTypes.get(j).toString()) instanceof RefType))
return true;
if (DexType.isWide(paramTypes.get(j).toString()))
i++;
}
return false;
}
示例6: analyzeMoveResult
import org.jf.dexlib2.iface.reference.MethodReference; //导入依赖的package包/类
private void analyzeMoveResult(@Nonnull AnalyzedInstruction analyzedInstruction) {
AnalyzedInstruction previousInstruction = null;
if (analyzedInstruction.instructionIndex > 0) {
previousInstruction = analyzedInstructions.valueAt(analyzedInstruction.instructionIndex-1);
}
if (previousInstruction == null || !previousInstruction.instruction.getOpcode().setsResult()) {
throw new AnalysisException(analyzedInstruction.instruction.getOpcode().name + " must occur after an " +
"invoke-*/fill-new-array instruction");
}
RegisterType resultRegisterType;
ReferenceInstruction invokeInstruction = (ReferenceInstruction)previousInstruction.instruction;
Reference reference = invokeInstruction.getReference();
if (reference instanceof MethodReference) {
resultRegisterType = RegisterType.getRegisterType(classPath, ((MethodReference)reference).getReturnType());
} else {
resultRegisterType = RegisterType.getRegisterType(classPath, (TypeReference)reference);
}
setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, resultRegisterType);
}
示例7: analyze
import org.jf.dexlib2.iface.reference.MethodReference; //导入依赖的package包/类
private void analyze(@Nonnull DexBackedMethodImplementation implementation) {
cyclomaticComplexity = calculateComplexity(implementation);
registerCount = implementation.getRegisterCount();
tryCatchCount = implementation.getTryBlocks().size();
debugItemCount = Utils.makeCollection(implementation.getDebugItems()).size();
for (Instruction instruction : implementation.getInstructions()) {
instructionCount++;
Opcode op = instruction.getOpcode();
opCounts.adjustOrPutValue(op, 1, 1);
if (instruction instanceof ReferenceInstruction) {
ReferenceInstruction refInstr = (ReferenceInstruction) instruction;
switch (op.referenceType) {
case ReferenceType.METHOD:
MethodReference methodRef = (MethodReference) refInstr.getReference();
if (fullMethodSignatures) {
apiCounts.adjustOrPutValue(methodRef, 1, 1);
} else {
ShortMethodReference shortMethodRef = new ShortMethodReference(methodRef);
apiCounts.adjustOrPutValue(shortMethodRef, 1, 1);
}
break;
case ReferenceType.FIELD:
FieldReference fieldRef = (FieldReference) refInstr.getReference();
fieldReferenceCounts.adjustOrPutValue(fieldRef, 1, 1);
break;
case ReferenceType.STRING:
StringReference stringRef = (StringReference) refInstr.getReference();
stringReferenceCounts.adjustOrPutValue(stringRef, 1, 1);
break;
}
}
}
}
示例8: addUsedMethods
import org.jf.dexlib2.iface.reference.MethodReference; //导入依赖的package包/类
public static void addUsedMethods(MethodReference methodReference) {
String className = methodReference.getDefiningClass();
// if (Build.addClasses.contains(className.substring(1, className.length() - 1).replace('/', '.'))){
// return;
// }
String method = methodReference.getName();
String params;
if (APatchTool.mappingMap == null) {
params = methodReference.getParameterTypes().toString().replace(',', '|').replaceAll(" ", "");
} else {
params = getParamsType(methodReference.getParameterTypes());
}
System.out.println("add used method:" + className + "->" + method + ":" + params
+ " " + methodReference.getReturnType());
String record = className.substring(1, className.length() - 1).replace('/', '.') + ":" +
method + ":" + params + ":" + methodReference.getReturnType();
if (Build.usedMethods.contains(record)) {
return;
}
if (p.matcher(className).find()) {
return;
}
Build.usedMethods.add(record);
}
示例9: writeMethodDescriptor
import org.jf.dexlib2.iface.reference.MethodReference; //导入依赖的package包/类
public static void writeMethodDescriptor(Writer writer, MethodReference methodReference,
boolean useImplicitReference) throws IOException {
if (!useImplicitReference) {
String clazz = TypeGenUtil.newType(methodReference.getDefiningClass());
writer.write(clazz);
writer.write("->");
}
writer.write(methodReference.getName());
writer.write('(');
for (CharSequence paramType : methodReference.getParameterTypes()) {
writer.write(paramType.toString());
}
writer.write(')');
writer.write(methodReference.getReturnType());
}
示例10: of
import org.jf.dexlib2.iface.reference.MethodReference; //导入依赖的package包/类
@Nonnull
public static ImmutableMethodReference of(@Nonnull MethodReference methodReference) {
if (methodReference instanceof ImmutableMethodReference) {
return (ImmutableMethodReference)methodReference;
}
return new ImmutableMethodReference(
methodReference.getDefiningClass(),
methodReference.getName(),
methodReference.getParameterTypes(),
methodReference.getReturnType());
}
示例11: equals
import org.jf.dexlib2.iface.reference.MethodReference; //导入依赖的package包/类
@Override
public boolean equals(@Nullable Object o) {
if (o != null && o instanceof MethodReference) {
MethodReference other = (MethodReference)o;
return getDefiningClass().equals(other.getDefiningClass()) &&
getName().equals(other.getName()) &&
getReturnType().equals(other.getReturnType()) &&
CharSequenceUtils.listEquals(getParameterTypes(), other.getParameterTypes());
}
return false;
}
示例12: compareTo
import org.jf.dexlib2.iface.reference.MethodReference; //导入依赖的package包/类
@Override
public int compareTo(@Nonnull MethodReference o) {
int res = getDefiningClass().compareTo(o.getDefiningClass());
if (res != 0) return res;
res = getName().compareTo(o.getName());
if (res != 0) return res;
res = getReturnType().compareTo(o.getReturnType());
if (res != 0) return res;
return CollectionUtils.compareAsIterable(Ordering.usingToString(), getParameterTypes(), o.getParameterTypes());
}
示例13: makeInstructionWriter
import org.jf.dexlib2.iface.reference.MethodReference; //导入依赖的package包/类
@Nonnull static <StringRef extends StringReference, TypeRef extends TypeReference, FieldRefKey extends FieldReference, MethodRefKey extends MethodReference>
InstructionWriter<StringRef, TypeRef, FieldRefKey, MethodRefKey>
makeInstructionWriter(
@Nonnull DexDataWriter writer,
@Nonnull StringSection<?, StringRef> stringSection,
@Nonnull TypeSection<?, ?, TypeRef> typeSection,
@Nonnull FieldSection<?, ?, FieldRefKey, ?> fieldSection,
@Nonnull MethodSection<?, ?, ?, MethodRefKey, ?> methodSection) {
return new InstructionWriter<StringRef, TypeRef, FieldRefKey, MethodRefKey>(
writer, stringSection, typeSection, fieldSection, methodSection);
}
示例14: intern
import org.jf.dexlib2.iface.reference.MethodReference; //导入依赖的package包/类
public void intern(@Nonnull MethodReference method) {
Integer prev = internedItems.put(method, 0);
if (prev == null) {
typePool.intern(method.getDefiningClass());
protoPool.intern(method);
stringPool.intern(method.getName());
}
}
示例15: intern
import org.jf.dexlib2.iface.reference.MethodReference; //导入依赖的package包/类
public void intern(@Nonnull MethodReference method) {
// We can't use method directly, because it is likely a full MethodReference. We use a wrapper that computes
// hashCode and equals based only on the prototype fields
Key key = new Key(method);
Integer prev = internedItems.put(key, 0);
if (prev == null) {
stringPool.intern(key.getShorty());
typePool.intern(method.getReturnType());
typeListPool.intern(method.getParameterTypes());
}
}