use of jadx.core.utils.exceptions.JadxRuntimeException in project jadx by skylot.
the class JNodeCache method convert.
private JNode convert(JavaNode node) {
if (node == null) {
return null;
}
if (node instanceof JavaClass) {
return convert(((JavaClass) node));
}
if (node instanceof JavaMethod) {
return new JMethod((JavaMethod) node, makeFrom(node.getDeclaringClass()));
}
if (node instanceof JavaField) {
return new JField((JavaField) node, makeFrom(node.getDeclaringClass()));
}
if (node instanceof JavaVariable) {
JavaVariable javaVar = (JavaVariable) node;
JMethod jMth = (JMethod) makeFrom(javaVar.getMth());
return new JVariable(jMth, javaVar);
}
throw new JadxRuntimeException("Unknown type for JavaNode: " + node.getClass());
}
use of jadx.core.utils.exceptions.JadxRuntimeException in project jadx by skylot.
the class ClassNode method addSyntheticClass.
public static ClassNode addSyntheticClass(RootNode root, String name, int accessFlags) {
ClassInfo clsInfo = ClassInfo.fromName(root, name);
ClassNode existCls = root.resolveClass(clsInfo);
if (existCls != null) {
throw new JadxRuntimeException("Class already exist: " + name);
}
return addSyntheticClass(root, clsInfo, accessFlags);
}
use of jadx.core.utils.exceptions.JadxRuntimeException in project jadx by skylot.
the class SignatureParser method consumeMethodArgs.
public List<ArgType> consumeMethodArgs(int argsCount) {
consume('(');
if (lookAhead(')')) {
consume(')');
return Collections.emptyList();
}
List<ArgType> args = new ArrayList<>(argsCount);
// just prevent endless loop, args count can be different for synthetic methods
int limit = argsCount + 10;
do {
ArgType type = consumeType();
if (type == null) {
throw new JadxRuntimeException("Unexpected end of signature");
}
args.add(type);
if (args.size() > limit) {
throw new JadxRuntimeException("Arguments count limit reached: " + args.size());
}
} while (!lookAhead(')'));
consume(')');
return args;
}
use of jadx.core.utils.exceptions.JadxRuntimeException in project jadx by skylot.
the class SignatureParser method consumeObjectType.
private ArgType consumeObjectType(boolean innerType) {
mark();
int ch;
do {
if (innerType && lookAhead('.')) {
// stop before next nested inner class
return ArgType.object(inclusiveSlice());
}
ch = next();
if (ch == STOP_CHAR) {
return null;
}
} while (ch != '<' && ch != ';');
if (ch == ';') {
String obj;
if (innerType) {
obj = slice().replace('/', '.');
} else {
obj = inclusiveSlice();
}
return ArgType.object(obj);
}
// generic type start ('<')
String obj = slice();
if (!innerType) {
obj += ';';
} else {
obj = obj.replace('/', '.');
}
List<ArgType> typeVars = consumeGenericArgs();
consume('>');
ArgType genericType = ArgType.generic(obj, typeVars);
if (!lookAhead('.')) {
consume(';');
return genericType;
}
consume('.');
next();
// type parsing not completed, proceed to inner class
ArgType inner = consumeObjectType(true);
if (inner == null) {
throw new JadxRuntimeException("No inner type found: " + debugString());
}
// for every nested inner type create nested type object
while (lookAhead('.')) {
genericType = ArgType.outerGeneric(genericType, inner);
consume('.');
next();
inner = consumeObjectType(true);
if (inner == null) {
throw new JadxRuntimeException("Unexpected inner type found: " + debugString());
}
}
return ArgType.outerGeneric(genericType, inner);
}
use of jadx.core.utils.exceptions.JadxRuntimeException in project jadx by skylot.
the class SignatureParser method consumeType.
public ArgType consumeType() {
char ch = next();
switch(ch) {
case 'L':
ArgType obj = consumeObjectType(false);
if (obj != null) {
return obj;
}
break;
case 'T':
next();
mark();
String typeVarName = consumeUntil(';');
if (typeVarName != null) {
consume(';');
if (typeVarName.contains(")")) {
throw new JadxRuntimeException("Bad name for type variable: " + typeVarName);
}
return ArgType.genericType(typeVarName);
}
break;
case '[':
return ArgType.array(consumeType());
case STOP_CHAR:
return null;
default:
// primitive type (one char)
ArgType type = ArgType.parse(ch);
if (type != null) {
return type;
}
break;
}
throw new JadxRuntimeException("Can't parse type: " + debugString() + ", unexpected: " + ch);
}
Aggregations