当前位置: 首页>>代码示例>>Java>>正文


Java ExceptionWithContext.withContext方法代码示例

本文整理汇总了Java中org.jf.dexlib.Util.ExceptionWithContext.withContext方法的典型用法代码示例。如果您正苦于以下问题:Java ExceptionWithContext.withContext方法的具体用法?Java ExceptionWithContext.withContext怎么用?Java ExceptionWithContext.withContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jf.dexlib.Util.ExceptionWithContext的用法示例。


在下文中一共展示了ExceptionWithContext.withContext方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:DocGerd,项目名称:DalvikSSA,代码行数:26,代码来源:ClassPath.java

示例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);
    }
}
 
开发者ID:Sukelluskello,项目名称:VectorAttackScanner,代码行数:25,代码来源:ClassPath.java

示例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);
}
 
开发者ID:Sukelluskello,项目名称:VectorAttackScanner,代码行数:22,代码来源:ClassPath.java

示例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;
}
 
开发者ID:longluo,项目名称:smali,代码行数:26,代码来源:ClassPath.java

示例5: 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);
    }
}
 
开发者ID:DocGerd,项目名称:DalvikSSA,代码行数:15,代码来源:IndexedSection.java

示例6: 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()));
        }
    }
}
 
开发者ID:DocGerd,项目名称:DalvikSSA,代码行数:14,代码来源:ClassPath.java

示例7: loadDexFile

import org.jf.dexlib.Util.ExceptionWithContext; //导入方法依赖的package包/类
private void loadDexFile(String dexFilePath, DexFile dexFile) {
    for (ClassDefItem classDefItem: dexFile.ClassDefsSection.getItems()) {
        try {
            UnresolvedClassInfo unresolvedClassInfo = new UnresolvedClassInfo(dexFilePath, classDefItem);

            if (!unloadedClasses.containsKey(unresolvedClassInfo.classType)) {
                unloadedClasses.put(unresolvedClassInfo.classType, unresolvedClassInfo);
            }
        } catch (Exception ex) {
            throw ExceptionWithContext.withContext(ex, String.format("Error while loading class %s",
                    classDefItem.getClassType().getTypeDescriptor()));
        }
    }
}
 
开发者ID:longluo,项目名称:smali,代码行数:15,代码来源:ClassPath.java

示例8: getClassDef

import org.jf.dexlib.Util.ExceptionWithContext; //导入方法依赖的package包/类
@Nonnull
public static ClassDef getClassDef(String classType, boolean createUnresolvedClassDef)  {
    ClassDef classDef = theClassPath.classDefs.get(classType);
    if (classDef == null) {
        //if it's an array class, try to create it
        if (classType.charAt(0) == '[') {
            return theClassPath.createArrayClassDef(classType);
        } else {
            try {
                classDef = loadClassDef(classType);
                if (classDef == null) {
                    throw new ExceptionWithContext(
                            String.format("Could not find definition for class %s", classType));
                }
            } catch (Exception ex) {
                RuntimeException exWithContext = ExceptionWithContext.withContext(ex,
                        String.format("Error while loading ClassPath class %s", classType));
                if (createUnresolvedClassDef) {
                    //TODO: add warning message
                    return theClassPath.createUnresolvedClassDef(classType);
                } else {
                    throw exWithContext;
                }
            }
        }
    }
    return classDef;
}
 
开发者ID:longluo,项目名称:smali,代码行数:29,代码来源:ClassPath.java

示例9: loadInterfaceTable

import org.jf.dexlib.Util.ExceptionWithContext; //导入方法依赖的package包/类
private LinkedHashMap<String, ClassDef> loadInterfaceTable(UnresolvedClassInfo classInfo) {
    if (classInfo.interfaces == null) {
        return null;
    }

    LinkedHashMap<String, ClassDef> interfaceTable = new LinkedHashMap<String, ClassDef>();

    for (String interfaceType: classInfo.interfaces) {
        if (!interfaceTable.containsKey(interfaceType)) {
            ClassDef interfaceDef;
            try {
                interfaceDef = ClassPath.getClassDef(interfaceType);
            } catch (Exception ex) {
                throw ExceptionWithContext.withContext(ex,
                        String.format("Could not find interface %s", interfaceType));
            }
            interfaceTable.put(interfaceType, interfaceDef);

            if (interfaceDef.interfaceTable != null) {
                for (ClassDef superInterface: interfaceDef.interfaceTable.values()) {
                    if (!interfaceTable.containsKey(superInterface.classType)) {
                        interfaceTable.put(superInterface.classType, superInterface);
                    }
                }
            }
        }
    }

    return interfaceTable;
}
 
开发者ID:longluo,项目名称:smali,代码行数:31,代码来源:ClassPath.java

示例10: MethodDefinition

import org.jf.dexlib.Util.ExceptionWithContext; //导入方法依赖的package包/类
public MethodDefinition(ClassDataItem.EncodedMethod encodedMethod) {


        try {
            this.encodedMethod = encodedMethod;

            //TODO: what about try/catch blocks inside the dead code? those will need to be commented out too. ugh.

            if (encodedMethod.codeItem != null) {
                Instruction[] instructions = encodedMethod.codeItem.getInstructions();

                packedSwitchMap = new SparseIntArray(1);
                sparseSwitchMap = new SparseIntArray(1);
                instructionMap = new SparseIntArray(instructions.length);

                int currentCodeAddress = 0;
                for (int i=0; i<instructions.length; i++) {
                    Instruction instruction = instructions[i];
                    if (instruction.opcode == Opcode.PACKED_SWITCH) {
                        packedSwitchMap.append(
                                currentCodeAddress +
                                        ((OffsetInstruction)instruction).getTargetAddressOffset(),
                                currentCodeAddress);
                    } else if (instruction.opcode == Opcode.SPARSE_SWITCH) {
                        sparseSwitchMap.append(
                                currentCodeAddress +
                                        ((OffsetInstruction)instruction).getTargetAddressOffset(),
                                currentCodeAddress);
                    }
                    instructionMap.append(currentCodeAddress, i);
                    currentCodeAddress += instruction.getSize(currentCodeAddress);
                }
            } else {
                packedSwitchMap = null;
                sparseSwitchMap = null;
                instructionMap = null;
                methodAnalyzer = null;
            }
        }catch (Exception ex) {
            throw ExceptionWithContext.withContext(ex, String.format("Error while processing method %s",
                    encodedMethod.method.getMethodString()));
        }
    }
 
开发者ID:DocGerd,项目名称:DalvikSSA,代码行数:44,代码来源:MethodDefinition.java

示例11: addExceptionContext

import org.jf.dexlib.Util.ExceptionWithContext; //导入方法依赖的package包/类
/**
 * This method is called to add item specific context information to an exception, to identify the "current item"
 * when the exception occured. It adds the value returned by <code>getConciseIdentity</code> as context for the
 * exception
 * @param ex The exception that occured
 * @return A RuntimeException with additional details about the item added
 */
protected final RuntimeException addExceptionContext(Exception ex) {
    return ExceptionWithContext.withContext(ex, getConciseIdentity());
}
 
开发者ID:DocGerd,项目名称:DalvikSSA,代码行数:11,代码来源:Item.java


注:本文中的org.jf.dexlib.Util.ExceptionWithContext.withContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。