Make ClassDef implement TypeReference

This commit is contained in:
Ben Gruver 2012-11-04 22:49:36 -08:00
parent b116cb0ac9
commit db389aa3a1
8 changed files with 17 additions and 15 deletions

View File

@ -100,7 +100,7 @@ public class ClassDefinition {
private void writeClass(IndentingWriter writer) throws IOException {
writer.write(".class ");
writeAccessFlags(writer);
writer.write(classDef.getName());
writer.write(classDef.getType());
writer.write('\n');
}

View File

@ -68,7 +68,7 @@ public class DexBackedClassDef implements ClassDef {
@Nonnull
@Override
public String getName() {
public String getType() {
return dexBuf.getType(dexBuf.readSmallUint(classDefOffset + CLASS_NAME_OFFSET));
}

View File

@ -85,7 +85,7 @@ public class DexBackedField implements Field {
return dexBuf.getType(dexBuf.readUshort(getFieldIdItemOffset() + TYPE_OFFSET));
}
@Nonnull @Override public String getContainingClass() { return classDef.getName(); }
@Nonnull @Override public String getContainingClass() { return classDef.getType(); }
@Override public int getAccessFlags() { return accessFlags; }
@Nullable @Override public EncodedValue getInitialValue() { return initialValue; }

View File

@ -98,7 +98,7 @@ public class DexBackedMethod implements Method {
this.parameterAnnotationSetListOffset = paramaterAnnotationIterator.seekTo(methodIndex);
}
@Nonnull @Override public String getContainingClass() { return classDef.getName(); }
@Nonnull @Override public String getContainingClass() { return classDef.getType(); }
@Override public int getAccessFlags() { return accessFlags; }
@Nonnull

View File

@ -113,7 +113,7 @@ public abstract class DebugInfo implements Iterable<DebugItem> {
// add the local info for the "this" parameter
locals[parameterIndex++] = new LocalInfo() {
@Override public String getName() { return "this"; }
@Override public String getType() { return methodImpl.method.classDef.getName(); }
@Override public String getType() { return methodImpl.method.classDef.getType(); }
@Override public String getSignature() { return null; }
};
}

View File

@ -31,12 +31,14 @@
package org.jf.dexlib2.iface;
import org.jf.dexlib2.iface.reference.TypeReference;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
public interface ClassDef {
@Nonnull String getName();
public interface ClassDef extends TypeReference {
@Nonnull String getType();
int getAccessFlags();
@Nullable String getSuperclass();
@Nonnull List<String> getInterfaces();

View File

@ -44,7 +44,7 @@ import javax.annotation.Nullable;
import java.util.List;
public class ImmutableClassDef implements ClassDef {
@Nonnull public final String name;
@Nonnull public final String type;
public final int accessFlags;
@Nullable public final String superclass;
@Nonnull public final ImmutableList<String> interfaces;
@ -53,7 +53,7 @@ public class ImmutableClassDef implements ClassDef {
@Nonnull public final ImmutableList<? extends ImmutableField> fields;
@Nonnull public final ImmutableList<? extends ImmutableMethod> methods;
public ImmutableClassDef(@Nonnull String name,
public ImmutableClassDef(@Nonnull String type,
int accessFlags,
@Nullable String superclass,
@Nullable List<String> interfaces,
@ -61,7 +61,7 @@ public class ImmutableClassDef implements ClassDef {
@Nullable List<? extends Annotation> annotations,
@Nullable List<? extends Field> fields,
@Nullable List<? extends Method> methods) {
this.name = name;
this.type = type;
this.accessFlags = accessFlags;
this.superclass = superclass;
this.interfaces = interfaces==null ? ImmutableList.<String>of() : ImmutableList.copyOf(interfaces);
@ -71,7 +71,7 @@ public class ImmutableClassDef implements ClassDef {
this.methods = ImmutableMethod.immutableListOf(methods);
}
public ImmutableClassDef(@Nonnull String name,
public ImmutableClassDef(@Nonnull String type,
int accessFlags,
@Nullable String superclass,
@Nullable ImmutableList<String> interfaces,
@ -79,7 +79,7 @@ public class ImmutableClassDef implements ClassDef {
@Nullable ImmutableList<? extends ImmutableAnnotation> annotations,
@Nullable ImmutableList<? extends ImmutableField> fields,
@Nullable ImmutableList<? extends ImmutableMethod> methods) {
this.name = name;
this.type = type;
this.accessFlags = accessFlags;
this.superclass = superclass;
this.interfaces = ImmutableListUtils.nullToEmptyList(interfaces);
@ -94,7 +94,7 @@ public class ImmutableClassDef implements ClassDef {
return (ImmutableClassDef)classDef;
}
return new ImmutableClassDef(
classDef.getName(),
classDef.getType(),
classDef.getAccessFlags(),
classDef.getSuperclass(),
classDef.getInterfaces(),
@ -104,7 +104,7 @@ public class ImmutableClassDef implements ClassDef {
classDef.getMethods());
}
@Nonnull @Override public String getName() { return name; }
@Nonnull @Override public String getType() { return type; }
@Override public int getAccessFlags() { return accessFlags; }
@Nullable @Override public String getSuperclass() { return superclass; }
@Nonnull @Override public ImmutableList<String> getInterfaces() { return interfaces; }

View File

@ -39,7 +39,7 @@ public class MethodUtil {
public static String buildFullMethodString(ClassDef classDef, Method method) {
//TODO: consider using a cached thread-local StringBuilder
StringBuilder sb = new StringBuilder();
sb.append(classDef.getName());
sb.append(classDef.getType());
sb.append("->");
sb.append(method.getName());
sb.append("(");