本文整理汇总了Java中org.jf.dexlib.Util.ExceptionWithContext类的典型用法代码示例。如果您正苦于以下问题:Java ExceptionWithContext类的具体用法?Java ExceptionWithContext怎么用?Java ExceptionWithContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExceptionWithContext类属于org.jf.dexlib.Util包,在下文中一共展示了ExceptionWithContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadClassDef
import org.jf.dexlib.Util.ExceptionWithContext; //导入依赖的package包/类
/**
* This method checks if the given class has been loaded yet. If it has, it returns the loaded ClassDef. If not,
* then it looks up the TempClassItem for the given class and (possibly recursively) loads the ClassDef.
* @param classType the class to load
* @return the existing or newly loaded ClassDef object for the given class, or null if the class cannot be found
*/
private static ClassDef loadClassDef(String classType) {
ClassDef classDef = getClassDef(classType, false);
if (classDef == null) {
TempClassInfo classInfo = theClassPath.tempClasses.get(classType);
if (classInfo == null) {
return null;
}
try {
classDef = new ClassDef(classInfo);
theClassPath.classDefs.put(classDef.classType, classDef);
} catch (Exception ex) {
throw ExceptionWithContext.withContext(ex, String.format("Error while loading class %s from file %s",
classInfo.classType, classInfo.dexFilePath));
}
}
return classDef;
}
示例2: ClassPath
import org.jf.dexlib.Util.ExceptionWithContext; //导入依赖的package包/类
private ClassPath(String[] bootClassPath, DexFile dexFile) {
if (bootClassPath == null || bootClassPath.length == 0) {
throw new ExceptionWithContext("No BOOTCLASSPATH entries were given");
}
classDefs = new HashMap<String, ClassDef>();
for (String bootClassPathEntry: bootClassPath) {
loadBootClassPath(bootClassPathEntry);
}
loadDexFile(dexFile);
try {
javaLangObjectClassDef = getClassDef("Ljava/lang/Object;");
} catch (ClassNotFoundException ex) {
throw ExceptionWithContext.withContext(ex, "Ljava/lang/Object; must be present in the classpath");
}
for (String primitiveType: new String[]{"Z", "B", "S", "C", "I", "J", "F", "D"}) {
ClassDef classDef = new PrimitiveClassDef(primitiveType);
classDefs.put(primitiveType, classDef);
}
}
示例3: loadBootClassPath
import org.jf.dexlib.Util.ExceptionWithContext; //导入依赖的package包/类
private void loadBootClassPath(String bootClassPathEntry) {
File file = new File(bootClassPathEntry);
if (!file.exists()) {
throw new ExceptionWithContext("ClassPath entry \"" + bootClassPathEntry + "\" does not exist.");
}
if (!file.canRead()) {
throw new ExceptionWithContext("Cannot read ClassPath entry \"" + bootClassPathEntry + "\".");
}
DexFile dexFile;
try {
dexFile = new DexFile(file);
} catch (Exception ex) {
throw ExceptionWithContext.withContext(ex, "Error while reading ClassPath entry \"" +
bootClassPathEntry + "\".");
}
loadDexFile(dexFile);
}
示例4: loadClassDef
import org.jf.dexlib.Util.ExceptionWithContext; //导入依赖的package包/类
/**
* This method loads the given class (and any dependent classes, as needed), removing them from unloadedClasses
* @param classType the class to load
* @return the newly loaded ClassDef object for the given class, or null if the class cannot be found
*/
@Nullable
private static ClassDef loadClassDef(String classType) {
ClassDef classDef = null;
UnresolvedClassInfo classInfo = theClassPath.unloadedClasses.get(classType);
if (classInfo == null) {
return null;
}
try {
classDef = new ClassDef(classInfo);
theClassPath.classDefs.put(classDef.classType, classDef);
} catch (Exception ex) {
throw ExceptionWithContext.withContext(ex, String.format("Error while loading class %s from file %s",
classInfo.classType, classInfo.dexFilePath));
}
theClassPath.unloadedClasses.remove(classType);
return classDef;
}
示例5: iterateFieldAnnotations
import org.jf.dexlib.Util.ExceptionWithContext; //导入依赖的package包/类
/**
* Iterates over the field annotations, calling delegate.processFieldAnnotations for each
* @param delegate the delegate to call
*/
public void iterateFieldAnnotations(FieldAnnotationIteratorDelegate delegate) {
for (int i=0; i<fieldAnnotationFields.length; i++) {
try {
delegate.processFieldAnnotations(fieldAnnotationFields[i], fieldAnnotations[i]);
} catch (Exception ex) {
throw addExceptionContext(ExceptionWithContext.withContext(ex,
"Error occured while processing field annotations for field: " +
fieldAnnotationFields[i].getFieldString()));
}
}
}
示例6: iterateMethodAnnotations
import org.jf.dexlib.Util.ExceptionWithContext; //导入依赖的package包/类
/**
* Iterates over the method annotations, calling delegate.processMethodAnnotations for each
* @param delegate the delegate to call
*/
public void iterateMethodAnnotations(MethodAnnotationIteratorDelegate delegate) {
for (int i=0; i<methodAnnotationMethods.length; i++) {
try {
delegate.processMethodAnnotations(methodAnnotationMethods[i], methodAnnotations[i]);
} catch (Exception ex) {
throw addExceptionContext(ExceptionWithContext.withContext(ex,
"Error occured while processing method annotations for method: " +
methodAnnotationMethods[i].getMethodString()));
}
}
}
示例7: iterateParameterAnnotations
import org.jf.dexlib.Util.ExceptionWithContext; //导入依赖的package包/类
/**
* Iterates over the parameter annotations, calling delegate.processParameterAnnotations for each
* @param delegate the delegate to call
*/
public void iterateParameterAnnotations(ParameterAnnotationIteratorDelegate delegate) {
for (int i=0; i<parameterAnnotationMethods.length; i++) {
try {
delegate.processParameterAnnotations(parameterAnnotationMethods[i], parameterAnnotations[i]);
} catch (Exception ex) {
throw addExceptionContext(ExceptionWithContext.withContext(ex,
"Error occured while processing parameter annotations for method: " +
parameterAnnotationMethods[i].getMethodString()));
}
}
}
示例8: getItemByIndex
import org.jf.dexlib.Util.ExceptionWithContext; //导入依赖的package包/类
/**
* Gets the item at the specified index in this section
* @param index the index of the item to get
* @return the item at the specified index in this section
*/
public T getItemByIndex(int index) {
try {
//if index is out of bounds, just let it throw an exception
return items.get(index);
} catch (Exception ex) {
throw ExceptionWithContext.withContext(ex, "Error occured while retrieving the " + this.ItemType.TypeName +
" item at index " + index);
}
}
示例9: getDestinationRegister
import org.jf.dexlib.Util.ExceptionWithContext; //导入依赖的package包/类
public int getDestinationRegister() {
if (!this.instruction.opcode.setsRegister()) {
throw new ExceptionWithContext("Cannot call getDestinationRegister() for an instruction that doesn't "
+ "store a value");
}
return ((SingleRegisterInstruction) instruction).getRegisterA();
}
示例10: InitializeClassPath
import org.jf.dexlib.Util.ExceptionWithContext; //导入依赖的package包/类
/**
* Initialize the class path using the given boot class path entries
* @param classPathDirs The directories to search for boot class path files
* @param bootClassPath A list of the boot class path entries to search for and load
* @param dexFilePath The path of the dex file (used for error reporting purposes only)
* @param dexFile the DexFile to load
* @param errorHandler a ClassPathErrorHandler object to receive and handle any errors that occur while loading
* classes
*/
public static void InitializeClassPath(String[] classPathDirs, String[] bootClassPath,
String[] extraBootClassPathEntries, String dexFilePath, DexFile dexFile,
ClassPathErrorHandler errorHandler) {
if (theClassPath != null) {
throw new ExceptionWithContext("Cannot initialize ClassPath multiple times");
}
theClassPath = new ClassPath();
theClassPath.initClassPath(classPathDirs, bootClassPath, extraBootClassPathEntries, dexFilePath, dexFile,
errorHandler);
}
示例11: loadDexFile
import org.jf.dexlib.Util.ExceptionWithContext; //导入依赖的package包/类
private void loadDexFile(String dexFilePath, DexFile dexFile) {
for (ClassDefItem classDefItem: dexFile.ClassDefsSection.getItems()) {
try {
//TODO: need to check if the class already exists. (and if so, what to do about it?)
TempClassInfo tempClassInfo = new TempClassInfo(dexFilePath, classDefItem);
tempClasses.put(tempClassInfo.classType, tempClassInfo);
} catch (Exception ex) {
throw ExceptionWithContext.withContext(ex, String.format("Error while loading class %s",
classDefItem.getClassType().getTypeDescriptor()));
}
}
}
示例12: getDestinationRegister
import org.jf.dexlib.Util.ExceptionWithContext; //导入依赖的package包/类
public int getDestinationRegister() {
if (!this.instruction.opcode.setsRegister()) {
throw new ExceptionWithContext("Cannot call getDestinationRegister() for an instruction that doesn't " +
"store a value");
}
return ((SingleRegisterInstruction)instruction).getRegisterA();
}
示例13: InitializeClassPath
import org.jf.dexlib.Util.ExceptionWithContext; //导入依赖的package包/类
public static void InitializeClassPath(String[] bootClassPath, DexFile dexFile) {
if (theClassPath != null) {
throw new ExceptionWithContext("Cannot initialize ClassPath multiple times");
}
theClassPath = new ClassPath(bootClassPath, dexFile);
}
示例14: loadSuperclass
import org.jf.dexlib.Util.ExceptionWithContext; //导入依赖的package包/类
private ClassDef loadSuperclass(ClassDefItem classDefItem) {
if (classDefItem.getClassType().getTypeDescriptor().equals("Ljava/lang/Object;")) {
if (classDefItem.getSuperclass() != null) {
throw new ExceptionWithContext("Invalid superclass " +
classDefItem.getSuperclass().getTypeDescriptor() + " for Ljava/lang/Object;. " +
"The Object class cannot have a superclass");
}
return null;
} else {
TypeIdItem superClass = classDefItem.getSuperclass();
if (superClass == null) {
throw new ExceptionWithContext(classDefItem.getClassType().getTypeDescriptor() +
" has no superclass");
}
ClassDef superclass = ClassPath.getClassDef(superClass.getTypeDescriptor());
if (!isInterface && superclass.isInterface) {
throw new ValidationException("Class " + classType + " has the interface " + superclass.classType +
" as its superclass");
}
if (isInterface && !superclass.isInterface && superclass !=
ClassPath.theClassPath.javaLangObjectClassDef) {
throw new ValidationException("Interface " + classType + " has the non-interface class " +
superclass.classType + " as its superclass");
}
return superclass;
}
}
示例15: InitializeClassPath
import org.jf.dexlib.Util.ExceptionWithContext; //导入依赖的package包/类
/**
* Initialize the class path using the given boot class path entries
* @param classPathDirs The directories to search for boot class path files
* @param bootClassPath A list of the boot class path entries to search for and load
* @param dexFilePath The path of the dex file (used for error reporting purposes only)
* @param dexFile the DexFile to load
* classes
*/
public static void InitializeClassPath(String[] classPathDirs, String[] bootClassPath,
String[] extraBootClassPathEntries, String dexFilePath, DexFile dexFile,
boolean checkPackagePrivateAccess) {
if (theClassPath != null) {
throw new ExceptionWithContext("Cannot initialize ClassPath multiple times");
}
theClassPath = new ClassPath();
theClassPath.initClassPath(classPathDirs, bootClassPath, extraBootClassPathEntries, dexFilePath, dexFile,
checkPackagePrivateAccess);
}