@Override public void setParentInsn(InsnNode parentInsn) { if (parentInsn == wrappedInsn) { throw new JadxRuntimeException("Can't wrap instruction info itself: " + parentInsn); } this.parentInsn = parentInsn; }
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 File createTempFile(String suffix) { File temp; try { temp = File.createTempFile("jadx-tmp-", System.nanoTime() + "-" + suffix); temp.deleteOnExit(); } catch (IOException e) { throw new JadxRuntimeException("Failed to create temp file with suffix: " + suffix); } return temp; }
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 File createTempDir(String suffix) { try { Path path = Files.createTempDirectory("jadx-tmp-" + System.nanoTime() + "-" + suffix); path.toFile().deleteOnExit(); return path.toFile(); } catch (IOException e) { throw new JadxRuntimeException("Failed to create temp directory with suffix: " + suffix); } }
public void load() throws IOException, DecodeException { try (InputStream input = getClass().getResourceAsStream(CLST_FILENAME)) { if (input == null) { throw new JadxRuntimeException("Can't load classpath file: " + CLST_FILENAME); } load(input); } }
private void saveResourceFile(ResourceFile resFile, File outFile) throws JadxException { ResourcesLoader.decodeStream(resFile, (size, is) -> { try (FileOutputStream fileStream = new FileOutputStream(outFile)) { IOUtils.copy(is, fileStream); } catch (Exception e) { throw new JadxRuntimeException("Resource file save error", e); } return null; }); } }
public void bindArg(RegisterArg arg, BlockNode pred) { if (blockBinds.containsValue(pred)) { throw new JadxRuntimeException("Duplicate predecessors in PHI insn: " + pred + ", " + this); } addArg(arg); blockBinds.put(arg, pred); }
public IfRegion(IRegion parent, BlockNode header) { super(parent); if (header.getInstructions().size() != 1) { throw new JadxRuntimeException("Expected only one instruction in 'if' header"); } this.header = header; this.condition = IfCondition.fromIfBlock(header); }
public void addClasspath(ClsSet set) { if (nameMap == null) { nameMap = new HashMap<>(set.getClassesCount()); set.addToMap(nameMap); } else { throw new JadxRuntimeException("Classpath already loaded"); } }
public static boolean hasBreakInsn(IContainer container) { if (container instanceof IBlock) { return BlockUtils.checkLastInsnType((IBlock) container, InsnType.BREAK); } else if (container instanceof IRegion) { List<IContainer> blocks = ((IRegion) container).getSubBlocks(); return !blocks.isEmpty() && hasBreakInsn(blocks.get(blocks.size() - 1)); } else { throw new JadxRuntimeException("Unknown container type: " + container); } }
public static BlockNode getBlockByOffset(int offset, Iterable<BlockNode> casesBlocks) { for (BlockNode block : casesBlocks) { if (block.getStartOffset() == offset) { return block; } } throw new JadxRuntimeException("Can't find block by offset: " + InsnUtils.formatOffset(offset) + " in list " + casesBlocks); }
private static void checkSSAVar(MethodNode mth, InsnNode insn, RegisterArg reg) { SSAVar sVar = reg.getSVar(); if (sVar == null) { throw new JadxRuntimeException("Null SSA var in " + insn + ", mth: " + mth); } for (RegisterArg useArg : sVar.getUseList()) { InsnNode parentInsn = useArg.getParentInsn(); if (parentInsn != null && !parentInsn.containsArg(useArg)) { throw new JadxRuntimeException("Incorrect use info in PHI insn"); } } }
private void consume(char exp) { char c = next(); if (exp != c) { throw new JadxRuntimeException("Consume wrong char: '" + c + "' != '" + exp + "', sign: " + debugString()); } }
public static void getAllRegionBlocks(IContainer container, Set<IBlock> blocks) { if (container instanceof IBlock) { blocks.add((IBlock) container); } else if (container instanceof IRegion) { IRegion region = (IRegion) container; for (IContainer block : region.getSubBlocks()) { getAllRegionBlocks(block, blocks); } } else { throw new JadxRuntimeException(unknownContainerType(container)); } }
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 init() { try { FileUtils.makeDirs(srcOutDir); FileUtils.makeDirs(resOutDir); saveBuildGradle(); skipGeneratedClasses(); } catch (Exception e) { throw new JadxRuntimeException("Gradle export failed", e); } }
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); } }