Package org.jf.dexlib2.analysis
Class ClassProto
java.lang.Object
org.jf.dexlib2.analysis.ClassProto
- All Implemented Interfaces:
TypeProto
A class "prototype". This contains things like the interfaces, the superclass, the vtable and the instance fields
and their offsets.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final com.google.common.base.Supplier<SparseArray<FieldReference>> This is the vtable supplier for a version of art that had buggy vtable calculation logic.private final com.google.common.base.Supplier<ClassDef> protected final ClassPathprivate final com.google.common.base.Supplier<SparseArray<FieldReference>> protected booleanprivate static final byteprivate final com.google.common.base.Supplier<LinkedHashMap<String, ClassDef>> This calculates the interfaces in the order required for vtable generation for post-default method ARTprivate final com.google.common.base.Supplier<LinkedHashMap<String, ClassDef>> This calculates the interfaces in the order required for vtable generation for dalvik and pre-default method ARTprivate static final byteprotected final Stringprotected booleanprivate static final byte -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddToVtable(Iterable<? extends Method> localMethods, List<Method> vtable, boolean replaceExisting, boolean sort) private booleancheckInterface(ClassProto other) This is a helper method for getCommonSuperclass It checks if this class is an interface, and if so, if other implements it.private intfindMethodIndexInVtable(List<Method> vtable, MethodReference method) intprivate intfindMethodIndexInVtableReverse(List<Method> vtable, MethodReference method) getCommonSuperclass(TypeProto other) Gets the interfaces directly implemented by this class, or the interfaces they transitively implement.getFieldByOffset(int fieldOffset) private static bytegetFieldType(FieldReference field) protected LinkedHashMap<String, ClassDef> Returns the set of interfaces that this class implements as a Mapinvalid input: '<'String, ClassDef>.getMethodByVtableIndex(int vtableIndex) private intgetType()private static intgetTypeSize(char type) booleanimplementsInterface(String iface) Checks if this class implements the given interface.private booleaninterfaceMethodOverrides(Method method, Method method2) Checks if the interface method overrides the virtual or interface method2booleanReturns true if this class is an interface.private booleanisOverridableByDefaultMethod(Method method) toString()
-
Field Details
-
REFERENCE
private static final byte REFERENCE- See Also:
-
WIDE
private static final byte WIDE- See Also:
-
OTHER
private static final byte OTHER- See Also:
-
classPath
-
type
-
vtableFullyResolved
protected boolean vtableFullyResolved -
interfacesFullyResolved
protected boolean interfacesFullyResolved -
unresolvedInterfaces
-
classDefSupplier
-
preDefaultMethodInterfaceSupplier
@Nonnull private final com.google.common.base.Supplier<LinkedHashMap<String,ClassDef>> preDefaultMethodInterfaceSupplierThis calculates the interfaces in the order required for vtable generation for dalvik and pre-default method ART -
postDefaultMethodInterfaceSupplier
@Nonnull private final com.google.common.base.Supplier<LinkedHashMap<String,ClassDef>> postDefaultMethodInterfaceSupplierThis calculates the interfaces in the order required for vtable generation for post-default method ART -
dalvikInstanceFieldsSupplier
@Nonnull private final com.google.common.base.Supplier<SparseArray<FieldReference>> dalvikInstanceFieldsSupplier -
artInstanceFieldsSupplier
@Nonnull private final com.google.common.base.Supplier<SparseArray<FieldReference>> artInstanceFieldsSupplier -
preDefaultMethodVtableSupplier
-
buggyPostDefaultMethodVtableSupplier
@Nonnull private final com.google.common.base.Supplier<List<Method>> buggyPostDefaultMethodVtableSupplierThis is the vtable supplier for a version of art that had buggy vtable calculation logic. In some cases it can produce multiple vtable entries for a given virtual method. This supplier duplicates this buggy logic in order to generate an identical vtable -
postDefaultMethodVtableSupplier
-
-
Constructor Details
-
ClassProto
-
-
Method Details
-
toString
-
getClassPath
- Specified by:
getClassPathin interfaceTypeProto
-
getType
-
getClassDef
-
isInterface
public boolean isInterface()Returns true if this class is an interface. If this class is not defined, then this will throw an UnresolvedClassException- Specified by:
isInterfacein interfaceTypeProto- Returns:
- True if this class is an interface
-
getInterfaces
Returns the set of interfaces that this class implements as a Mapinvalid input: '<'String, ClassDef>. The ClassDef value will be present only for the interfaces that this class directly implements (including any interfaces transitively implemented), but not for any interfaces that are only implemented by a superclass of this class For any interfaces that are only implemented by a superclass (or the class itself, if the class is an interface), the value will be null. If any interface couldn't be resolved, then the interfacesFullyResolved field will be set to false upon return.- Returns:
- the set of interfaces that this class implements as a Mapinvalid input: '<'String, ClassDef>.
-
getUnresolvedInterfaces
-
getDirectInterfaces
Gets the interfaces directly implemented by this class, or the interfaces they transitively implement. This does not include any interfaces that are only implemented by a superclass- Returns:
- An iterables of ClassDefs representing the directly or transitively implemented interfaces
- Throws:
UnresolvedClassException- if interfaces could not be fully resolved
-
implementsInterface
Checks if this class implements the given interface. If the interfaces of this class cannot be fully resolved then this method will either return true or throw an UnresolvedClassException- Specified by:
implementsInterfacein interfaceTypeProto- Parameters:
iface- The interface to check for- Returns:
- true if this class implements the given interface, otherwise false
- Throws:
UnresolvedClassException- if the interfaces for this class could not be fully resolved, and the interface is not one of the interfaces that were successfully resolved
-
getSuperclass
- Specified by:
getSuperclassin interfaceTypeProto
-
checkInterface
This is a helper method for getCommonSuperclass It checks if this class is an interface, and if so, if other implements it. If this class is undefined, we go ahead and check if it is listed in other's interfaces. If not, we throw an UndefinedClassException If the interfaces of other cannot be fully resolved, we check the interfaces that can be resolved. If not found, we throw an UndefinedClassException- Parameters:
other- The class to check the interfaces of- Returns:
- true if this class is an interface (or is undefined) other implements this class
-
getCommonSuperclass
- Specified by:
getCommonSuperclassin interfaceTypeProto
-
getFieldByOffset
- Specified by:
getFieldByOffsetin interfaceTypeProto
-
getMethodByVtableIndex
- Specified by:
getMethodByVtableIndexin interfaceTypeProto
-
findMethodIndexInVtable
- Specified by:
findMethodIndexInVtablein interfaceTypeProto
-
findMethodIndexInVtable
-
findMethodIndexInVtableReverse
-
getInstanceFields
-
getNextFieldOffset
private int getNextFieldOffset() -
getTypeSize
private static int getTypeSize(char type) -
getVtable
-
addToVtable
-
getFieldType
-
isOverridableByDefaultMethod
-
interfaceMethodOverrides
Checks if the interface method overrides the virtual or interface method2- Parameters:
method- A Method from an interfacemethod2- A Method from an interface or a class- Returns:
- true if the interface method overrides the virtual or interface method2
-