EncodedMethodpublic final class EncodedMethod extends EncodedMember implements ComparableClass that representats a method of a class. |
Fields Summary |
---|
private final com.android.dx.rop.cst.CstMethodRef | method{@code non-null;} constant for the method | private final CodeItem | code{@code null-ok;} code for the method, if the method is neither
{@code abstract} nor {@code native} |
Methods Summary |
---|
public void | addContents(DexFile file){@inheritDoc}
MethodIdsSection methodIds = file.getMethodIds();
MixedItemSection wordData = file.getWordData();
methodIds.intern(method);
if (code != null) {
wordData.add(code);
}
| public int | compareTo(com.android.dx.dex.file.EncodedMethod other){@inheritDoc}
Note: 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).
return method.compareTo(other.method);
| public void | debugPrint(java.io.PrintWriter out, boolean verbose){@inheritDoc}
if (code == null) {
out.println(getRef().toHuman() + ": abstract or native");
} else {
code.debugPrint(out, " ", verbose);
}
| public int | encode(DexFile file, com.android.dx.util.AnnotatedOutput out, int lastIndex, int dumpSeq){@inheritDoc}
int methodIdx = file.getMethodIds().indexOf(method);
int diff = methodIdx - lastIndex;
int accessFlags = getAccessFlags();
int codeOff = OffsettedItem.getAbsoluteOffsetOr0(code);
boolean hasCode = (codeOff != 0);
boolean shouldHaveCode = (accessFlags &
(AccessFlags.ACC_ABSTRACT | AccessFlags.ACC_NATIVE)) == 0;
/*
* Verify that code appears if and only if a method is
* declared to have it.
*/
if (hasCode != shouldHaveCode) {
throw new UnsupportedOperationException(
"code vs. access_flags mismatch");
}
if (out.annotates()) {
out.annotate(0, String.format(" [%x] %s", dumpSeq,
method.toHuman()));
out.annotate(Leb128.unsignedLeb128Size(diff),
" method_idx: " + Hex.u4(methodIdx));
out.annotate(Leb128.unsignedLeb128Size(accessFlags),
" access_flags: " +
AccessFlags.methodString(accessFlags));
out.annotate(Leb128.unsignedLeb128Size(codeOff),
" code_off: " + Hex.u4(codeOff));
}
out.writeUleb128(diff);
out.writeUleb128(accessFlags);
out.writeUleb128(codeOff);
return methodIdx;
| public boolean | equals(java.lang.Object other){@inheritDoc}
if (! (other instanceof EncodedMethod)) {
return false;
}
return compareTo((EncodedMethod) other) == 0;
| public final com.android.dx.rop.cst.CstString | getName(){@inheritDoc}
return method.getNat().getName();
| public final com.android.dx.rop.cst.CstMethodRef | getRef()Gets the constant for the method.
return method;
| public final java.lang.String | toHuman(){@inheritDoc}
return method.toHuman();
| public java.lang.String | toString(){@inheritDoc}
StringBuffer sb = new StringBuffer(100);
sb.append(getClass().getName());
sb.append('{");
sb.append(Hex.u2(getAccessFlags()));
sb.append(' ");
sb.append(method);
if (code != null) {
sb.append(' ");
sb.append(code);
}
sb.append('}");
return sb.toString();
|
|