use of jadx.core.utils.exceptions.JadxRuntimeException in project jadx by skylot.
the class JadxDecompiler method getJavaClassByNode.
@Nullable("For not generated classes")
@ApiStatus.Internal
public JavaClass getJavaClassByNode(ClassNode cls) {
JavaClass javaClass = classesMap.get(cls);
if (javaClass != null && javaClass.getClassNode() == cls) {
return javaClass;
}
// load parent class if inner
ClassNode parentClass = cls.getTopParentClass();
if (parentClass.contains(AFlag.DONT_GENERATE)) {
return null;
}
if (parentClass != cls) {
JavaClass parentJavaClass = classesMap.get(parentClass);
if (parentJavaClass == null) {
getClasses();
parentJavaClass = classesMap.get(parentClass);
}
loadJavaClass(parentJavaClass);
javaClass = classesMap.get(cls);
if (javaClass != null) {
return javaClass;
}
}
// class or parent classes can be excluded from generation
if (cls.hasNotGeneratedParent()) {
return null;
}
throw new JadxRuntimeException("JavaClass not found by ClassNode: " + cls);
}
use of jadx.core.utils.exceptions.JadxRuntimeException in project jadx by skylot.
the class JadxDecompiler method appendSourcesSave.
private void appendSourcesSave(List<Runnable> tasks, File outDir) {
Predicate<String> classFilter = args.getClassFilter();
List<JavaClass> classes = getClasses();
List<JavaClass> processQueue = new ArrayList<>(classes.size());
for (JavaClass cls : classes) {
if (cls.getClassNode().contains(AFlag.DONT_GENERATE)) {
continue;
}
if (classFilter != null && !classFilter.test(cls.getFullName())) {
continue;
}
processQueue.add(cls);
}
List<List<JavaClass>> batches;
try {
batches = decompileScheduler.buildBatches(processQueue);
} catch (Exception e) {
throw new JadxRuntimeException("Decompilation batches build failed", e);
}
for (List<JavaClass> decompileBatch : batches) {
tasks.add(() -> {
for (JavaClass cls : decompileBatch) {
try {
ICodeInfo code = cls.getCodeInfo();
SaveCode.save(outDir, cls.getClassNode(), code);
} catch (Exception e) {
LOG.error("Error saving class: {}", cls, e);
}
}
});
}
}
use of jadx.core.utils.exceptions.JadxRuntimeException in project jadx by skylot.
the class InsnDecoder method invoke.
private InsnNode invoke(InsnData insn, InvokeType type, boolean isRange) {
IMethodRef mthRef = InsnDataUtils.getMethodRef(insn);
if (mthRef == null) {
throw new JadxRuntimeException("Failed to load method reference for insn: " + insn);
}
MethodInfo mthInfo = MethodInfo.fromRef(root, mthRef);
return new InvokeNode(mthInfo, insn, type, isRange);
}
use of jadx.core.utils.exceptions.JadxRuntimeException in project jadx by skylot.
the class CustomLambdaCall method buildLambdaMethodCall.
public static InvokeCustomNode buildLambdaMethodCall(MethodNode mth, InsnData insn, boolean isRange, List<EncodedValue> values) {
IMethodHandle callMthHandle = (IMethodHandle) values.get(4).getValue();
if (callMthHandle.getType().isField()) {
throw new JadxRuntimeException("Not yet supported");
}
InvokeCustomNode resNode = buildMethodCall(mth, insn, isRange, values, callMthHandle);
int resReg = insn.getResultReg();
if (resReg != -1) {
resNode.setResult(InsnArg.reg(resReg, mth.getReturnType()));
}
return resNode;
}
use of jadx.core.utils.exceptions.JadxRuntimeException in project jadx by skylot.
the class BlockNode method lock.
public void lock() {
try {
List<BlockNode> successorsList = successors;
successors = lockList(successorsList);
cleanSuccessors = successorsList == cleanSuccessors ? this.successors : lockList(cleanSuccessors);
predecessors = lockList(predecessors);
dominatesOn = lockList(dominatesOn);
if (domFrontier == null) {
throw new JadxRuntimeException("Dominance frontier not set for block: " + this);
}
} catch (Exception e) {
throw new JadxRuntimeException("Failed to lock block: " + this, e);
}
}
Aggregations