@Override public void setParentInsn(InsnNode parentInsn) { if (parentInsn == wrappedInsn) { throw new JadxRuntimeException("Can't wrap instruction info itself: " + parentInsn); } this.parentInsn = parentInsn; }
private static void checkDir(File dir) { if (dir != null && dir.exists() && !dir.isDirectory()) { throw new JadxArgsValidateException("Output directory exists as file " + dir); } }
private void find9patchChunk(DataInput di) throws JadxException, IOException { di.skipBytes(8); while (true) { int size; try { size = di.readInt(); } catch (IOException ex) { throw new JadxException("Cant find nine patch chunk", ex); } if (di.readInt() == NP_CHUNK_TYPE) { return; } di.skipBytes(size + 4); } }
private static void computeDominanceFrontier(MethodNode mth) { for (BlockNode exit : mth.getExitBlocks()) { exit.setDomFrontier(EMPTY); } for (BlockNode block : mth.getBasicBlocks()) { try { computeBlockDF(mth, block); } catch (StackOverflowError e) { throw new JadxOverflowException("Failed compute block dominance frontier"); } catch (Exception e) { throw new JadxRuntimeException("Failed compute block dominance frontier", e); } } }
private void fallbackOnlyInsn(InsnNode insn) throws CodegenException { if (!fallback) { throw new CodegenException(insn.getType() + " can be used only in fallback mode"); } }
public void push(IRegion region) { stack.push(curState); if (stack.size() > REGIONS_STACK_LIMIT) { throw new JadxOverflowException("Regions stack size limit reached"); } curState = curState.copy(); curState.region = region; if (DEBUG) { LOG.debug("Stack push: {}: {}", size(), curState); } }
@Override public void setArg(int n, InsnArg arg) { throw new JadxRuntimeException("Unsupported operation for PHI node"); }
private static void checkFile(File file) { if (!file.exists()) { throw new JadxArgsValidateException("File not found " + file.getAbsolutePath()); } if (file.isDirectory()) { throw new JadxArgsValidateException("Expected file but found directory instead: " + file.getAbsolutePath()); } }
private static BlockNode getBlock(int offset, Map<Integer, BlockNode> blocksMap) { BlockNode block = blocksMap.get(offset); if (block == null) { throw new JadxRuntimeException("Missing block: " + offset); } return block; }
private String processVar(String varName) { String str = values.get(varName); if (str == null) { throw new JadxRuntimeException("Unknown variable: '" + varName + "' in template: " + templateName); } return str; } }
public static ImageIcon openIcon(String name) { String iconPath = "/icons-16/" + name + ".png"; URL resource = Utils.class.getResource(iconPath); if (resource == null) { throw new JadxRuntimeException("Icon not found: " + iconPath); } return new ImageIcon(resource); }
public static void makeDirs(@Nullable File dir) { if (dir != null) { synchronized (MKDIR_SYNC) { if (!dir.mkdirs() && !dir.isDirectory()) { throw new JadxRuntimeException("Can't create directory " + dir); } } } }
public static Image openImage(String path) { URL resource = Utils.class.getResource(path); if (resource == null) { throw new JadxRuntimeException("Image not found: " + path); } return Toolkit.getDefaultToolkit().createImage(resource); }
private void consume(char exp) { char c = next(); if (exp != c) { throw new JadxRuntimeException("Consume wrong char: '" + c + "' != '" + exp + "', sign: " + debugString()); } }
public void addClasspath(ClsSet set) { if (nameMap == null) { nameMap = new HashMap<>(set.getClassesCount()); set.addToMap(nameMap); } else { throw new JadxRuntimeException("Classpath already loaded"); } }
@Override public boolean replaceArg(InsnArg from, InsnArg to) { if (!(from instanceof RegisterArg) || !(to instanceof RegisterArg)) { return false; } BlockNode pred = getBlockByArg((RegisterArg) from); if (pred == null) { throw new JadxRuntimeException("Unknown predecessor block by arg " + from + " in PHI: " + this); } if (removeArg(from)) { bindArg((RegisterArg) to, pred); } return true; }
private ClassInfo(RootNode root, ArgType type, boolean inner) { if (!type.isObject() || type.isGeneric()) { throw new JadxRuntimeException("Not class type: " + type); } this.type = type; this.alias = this; splitNames(root, inner); }
public void lock() { cleanSuccessors = lockList(cleanSuccessors); successors = lockList(successors); predecessors = lockList(predecessors); dominatesOn = lockList(dominatesOn); if (domFrontier == null) { throw new JadxRuntimeException("Dominance frontier not set for block: " + this); } }
public void init() { try { FileUtils.makeDirs(srcOutDir); FileUtils.makeDirs(resOutDir); saveBuildGradle(); skipGeneratedClasses(); } catch (Exception e) { throw new JadxRuntimeException("Gradle export failed", e); } }
public static int getArg(DecodedInstruction insn, int arg) { switch (arg) { case 0: return insn.getA(); case 1: return insn.getB(); case 2: return insn.getC(); case 3: return insn.getD(); case 4: return insn.getE(); default: throw new JadxRuntimeException("Wrong argument number: " + arg); } }