Examples of ExceptionWithContext


Examples of org.jf.util.ExceptionWithContext

                        Instruction instruction = DexBackedInstruction.readFrom(reader);

                        // Does the instruction extend past the end of the method?
                        int offset = reader.getOffset();
                        if (offset > endOffset || offset < 0) {
                            throw new ExceptionWithContext("The last instruction in the method is truncated");
                        }
                        return instruction;
                    }
                };
            }
View Full Code Here

Examples of org.jf.util.ExceptionWithContext

            case ReferenceType.METHOD:
                return new DexBackedMethodReference(dexFile, referenceIndex);
            case ReferenceType.FIELD:
                return new DexBackedFieldReference(dexFile, referenceIndex);
            default:
                throw new ExceptionWithContext("Invalid reference type: %d", referenceType);
        }
    }
View Full Code Here

Examples of org.jf.util.ExceptionWithContext

            if (zipEntry == null) {
                throw new NoClassesDexException("zip file %s does not contain a classes.dex file", dexFile.getName());
            }
            long fileLength = zipEntry.getSize();
            if (fileLength < 40) {
                throw new ExceptionWithContext(
                        "The " + dexEntry + " file in %s is too small to be a valid dex file", dexFile.getName());
            } else if (fileLength > Integer.MAX_VALUE) {
                throw new ExceptionWithContext("The " + dexEntry + " file in %s is too large to read in", dexFile.getName());
            }
            byte[] dexBytes = new byte[(int)fileLength];
            ByteStreams.readFully(zipFile.getInputStream(zipEntry), dexBytes);
            return new DexBackedDexFile(opcodes, dexBytes);
        } catch (IOException ex) {
            // don't continue on if we know it's a zip file
            if (isZipFile) {
                throw ex;
            }
        } finally {
            if (zipFile != null) {
                try {
                    zipFile.close();
                } catch (IOException ex) {
                    // just eat it
                }
            }
        }

        InputStream inputStream = new BufferedInputStream(new FileInputStream(dexFile));

        try {
            return DexBackedDexFile.fromInputStream(opcodes, inputStream);
        } catch (DexBackedDexFile.NotADexFile ex) {
            // just eat it
        }

        // Note: DexBackedDexFile.fromInputStream will reset inputStream back to the same position, if it fails

        try {
            return DexBackedOdexFile.fromInputStream(opcodes, inputStream);
        } catch (DexBackedOdexFile.NotAnOdexFile ex) {
            // just eat it
        }

        throw new ExceptionWithContext("%s is not an apk, dex file or odex file.", dexFile.getPath());
    }
View Full Code Here

Examples of org.jf.util.ExceptionWithContext

            int lastCoveredAddress = instructionOffsetMap.getInstructionCodeOffset(lastCoveredIndex);

            for (ExceptionHandler handler: tryBlock.getExceptionHandlers()) {
                int handlerAddress = handler.getHandlerCodeAddress();
                if (handlerAddress >= codeSize) {
                    throw new ExceptionWithContext(
                            "Exception handler offset %d is past the end of the code block.", handlerAddress);
                }

                //use the address from the last covered instruction
                CatchMethodItem catchMethodItem = new CatchMethodItem(classDef.options, labelCache, lastCoveredAddress,
View Full Code Here

Examples of org.jf.util.ExceptionWithContext

                break;
            case SyntheticAccessorResolver.USHR_ASSIGNMENT:
                writer.write(">>>= operator for: ");
                break;
            default:
                throw new ExceptionWithContext("Unknown access type: %d", accessedMember.accessedMemberType);
        }

        int referenceType;
        if (accessedMember.accessedMemberType == SyntheticAccessorResolver.METHOD) {
            referenceType = ReferenceType.METHOD;
View Full Code Here

Examples of org.jf.util.ExceptionWithContext

            case DebugItemType.SET_SOURCE_FILE:
                return new SetSourceFileMethodItem(codeAddress, -3, (SetSourceFile)debugItem);
            case DebugItemType.LINE_NUMBER:
                return new LineNumberMethodItem(codeAddress, -2, (LineNumber)debugItem);
            default:
                throw new ExceptionWithContext("Invalid debug item type: %d", debugItem.getDebugItemType());
        }
    }
View Full Code Here

Examples of org.jf.util.ExceptionWithContext

            case SparseSwitchPayload:
                return new DexBackedSparseSwitchPayload(dexFile, instructionStartOffset);
            case ArrayPayload:
                return new DexBackedArrayPayload(dexFile, instructionStartOffset);
            default:
                throw new ExceptionWithContext("Unexpected opcode format: %s", opcode.format.toString());
        }
    }
View Full Code Here

Examples of org.jf.util.ExceptionWithContext

                break;
            case 0x1f:
                out.annotate(1, "valueArg = %d, valueType = 0x%x: boolean, value=%s", valueArg, valueType, valueArg==1);
                break;
            default:
                throw new ExceptionWithContext("Invalid encoded value type 0x%x at offset 0x%x", valueType,
                        out.getCursor());
        }
    }
View Full Code Here

Examples of org.jf.util.ExceptionWithContext

                    return getRegisterType(DOUBLE_LO, null);
                } else {
                    return getRegisterType(DOUBLE_HI, null);
                }
            default:
                throw new ExceptionWithContext("Cannot use this method for narrow register type: %s", type);
        }
    }
View Full Code Here

Examples of org.jf.util.ExceptionWithContext

                return DOUBLE_LO_TYPE;
            case 'L':
            case '[':
                return getRegisterType(REFERENCE, classPath.getClass(type));
            default:
                throw new ExceptionWithContext("Invalid type: " + type);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.