use of jadx.plugins.input.java.utils.JavaClassParseException in project jadx by skylot.
the class WideDecoder method decode.
@Override
public void decode(CodeDecodeState state) {
DataReader reader = state.reader();
JavaInsnData insn = state.insn();
int opcode = reader.readU1();
if (opcode == IINC) {
int varNum = reader.readU2();
int constValue = reader.readS2();
state.local(0, varNum).local(1, varNum).lit(constValue);
insn.setPayloadSize(5);
insn.setRegsCount(2);
insn.setOpcode(Opcode.ADD_INT_LIT);
return;
}
int index = reader.readU2();
switch(opcode) {
// iload,
case 0x15:
// fload
case 0x17:
case // aload
0x19:
state.local(1, index).push(0);
break;
// lload
case 0x16:
case // dload
0x18:
state.local(1, index).pushWide(0);
break;
case 0x36:
case 0x37:
case 0x38:
case 0x39:
case 0x3a:
// *store
state.pop(1).local(0, index);
break;
default:
throw new JavaClassParseException("Unexpected opcode in 'wide': 0x" + Integer.toHexString(opcode));
}
insn.setPayloadSize(3);
insn.setRegsCount(2);
insn.setOpcode(Opcode.MOVE);
}
use of jadx.plugins.input.java.utils.JavaClassParseException in project jadx by skylot.
the class ConstPoolReader method resolveMethodCallSite.
private CallSite resolveMethodCallSite(int bootstrapMthIdx, int nameIdx, int descIdx) {
JavaBootstrapMethodsAttr bootstrapMethodsAttr = clsData.loadAttribute(data, JavaAttrType.BOOTSTRAP_METHODS);
if (bootstrapMethodsAttr == null) {
throw new JavaClassParseException("Unexpected missing BootstrapMethods attribute");
}
RawBootstrapMethod rawBootstrapMethod = bootstrapMethodsAttr.getList().get(bootstrapMthIdx);
List<EncodedValue> values = new ArrayList<>(6);
values.add(new EncodedValue(EncodedType.ENCODED_METHOD_HANDLE, getMethodHandle(rawBootstrapMethod.getMethodHandleIdx())));
values.add(new EncodedValue(EncodedType.ENCODED_STRING, getUtf8(nameIdx)));
values.add(new EncodedValue(EncodedType.ENCODED_METHOD_TYPE, DescriptorParser.parseToMethodProto(getUtf8(descIdx))));
for (int argConstIdx : rawBootstrapMethod.getArgs()) {
values.add(readAsEncodedValue(argConstIdx));
}
return new CallSite(values);
}
use of jadx.plugins.input.java.utils.JavaClassParseException in project jadx by skylot.
the class LoadConstDecoder method decode.
@Override
public void decode(CodeDecodeState state) {
DataReader reader = state.reader();
JavaInsnData insn = state.insn();
int index;
if (wide) {
index = reader.readU2();
} else {
index = reader.readU1();
}
ConstPoolReader constPoolReader = insn.constPoolReader();
ConstantType constType = constPoolReader.jumpToConst(index);
switch(constType) {
case INTEGER:
case FLOAT:
insn.setLiteral(constPoolReader.readU4());
insn.setOpcode(Opcode.CONST);
state.push(0, SVType.NARROW);
break;
case LONG:
case DOUBLE:
insn.setLiteral(constPoolReader.readU8());
insn.setOpcode(Opcode.CONST_WIDE);
state.push(0, SVType.WIDE);
break;
case STRING:
insn.setIndex(constPoolReader.readU2());
insn.setOpcode(Opcode.CONST_STRING);
state.push(0, SVType.NARROW);
break;
case UTF8:
insn.setIndex(index);
insn.setOpcode(Opcode.CONST_STRING);
state.push(0, SVType.NARROW);
break;
case CLASS:
insn.setIndex(index);
insn.setOpcode(Opcode.CONST_CLASS);
state.push(0, SVType.NARROW);
break;
default:
throw new JavaClassParseException("Unsupported constant type: " + constType);
}
}
use of jadx.plugins.input.java.utils.JavaClassParseException in project jadx by skylot.
the class EncodedValueReader method read.
public static EncodedValue read(JavaClassData clsData, DataReader reader) {
ConstPoolReader constPool = clsData.getConstPoolReader();
char tag = (char) reader.readU1();
switch(tag) {
case 'B':
return new EncodedValue(EncodedType.ENCODED_BYTE, (byte) constPool.getInt(reader.readU2()));
case 'C':
return new EncodedValue(EncodedType.ENCODED_CHAR, (char) constPool.getInt(reader.readU2()));
case 'D':
return new EncodedValue(EncodedType.ENCODED_DOUBLE, constPool.getDouble(reader.readU2()));
case 'F':
return new EncodedValue(EncodedType.ENCODED_FLOAT, constPool.getFloat(reader.readU2()));
case 'I':
return new EncodedValue(EncodedType.ENCODED_INT, constPool.getInt(reader.readU2()));
case 'J':
return new EncodedValue(EncodedType.ENCODED_LONG, constPool.getLong(reader.readU2()));
case 'S':
return new EncodedValue(EncodedType.ENCODED_SHORT, (short) constPool.getInt(reader.readU2()));
case 'Z':
return new EncodedValue(EncodedType.ENCODED_BOOLEAN, 1 == constPool.getInt(reader.readU2()));
case 's':
return new EncodedValue(EncodedType.ENCODED_STRING, constPool.getUtf8(reader.readU2()));
case 'e':
String cls = constPool.getUtf8(reader.readU2());
String name = constPool.getUtf8(reader.readU2());
return new EncodedValue(EncodedType.ENCODED_ENUM, new JadxFieldRef(cls, name, cls));
case 'c':
return new EncodedValue(EncodedType.ENCODED_TYPE, constPool.getUtf8(reader.readU2()));
case '@':
return new EncodedValue(EncodedType.ENCODED_ANNOTATION, JavaAnnotationsAttr.readAnnotation(AnnotationVisibility.RUNTIME, clsData, reader));
case '[':
int len = reader.readU2();
List<EncodedValue> values = new ArrayList<>(len);
for (int i = 0; i < len; i++) {
values.add(read(clsData, reader));
}
return new EncodedValue(EncodedType.ENCODED_ARRAY, values);
default:
throw new JavaClassParseException("Unknown element value tag: " + tag);
}
}
Aggregations