use of jadx.plugins.input.java.data.attributes.JavaAttrStorage in project jadx by skylot.
the class JavaClassData method parseField.
private void parseField(DataReader reader, JavaFieldData field) {
int accessFlags = reader.readU2();
int nameIdx = reader.readU2();
int typeIdx = reader.readU2();
JavaAttrStorage attributes = attributesReader.load(reader);
field.setAccessFlags(accessFlags);
field.setName(constPoolReader.getUtf8(nameIdx));
field.setType(constPoolReader.getUtf8(typeIdx));
field.setAttributes(attributes);
}
use of jadx.plugins.input.java.data.attributes.JavaAttrStorage in project jadx by skylot.
the class JavaClassData method getAttributes.
@Override
public List<IJadxAttribute> getAttributes() {
data.absPos(offsets.getAttributesOffset());
JavaAttrStorage attributes = attributesReader.load(data);
int size = attributes.size();
if (size == 0) {
return Collections.emptyList();
}
List<IJadxAttribute> list = new ArrayList<>(size);
Utils.addToList(list, JavaAnnotationsAttr.merge(attributes));
Utils.addToList(list, attributes.get(JavaAttrType.INNER_CLASSES));
Utils.addToList(list, attributes.get(JavaAttrType.SOURCE_FILE));
Utils.addToList(list, attributes.get(JavaAttrType.SIGNATURE));
return list;
}
use of jadx.plugins.input.java.data.attributes.JavaAttrStorage in project jadx by skylot.
the class JavaClassData method parseMethod.
private void parseMethod(DataReader reader, JavaMethodData method, int id) {
int accessFlags = reader.readU2();
int nameIdx = reader.readU2();
int descriptorIdx = reader.readU2();
JavaAttrStorage attributes = attributesReader.load(reader);
JavaMethodRef methodRef = method.getMethodRef();
methodRef.reset();
methodRef.initUniqId(clsReader, id, false);
methodRef.setName(constPoolReader.getUtf8(nameIdx));
methodRef.setDescr(constPoolReader.getUtf8(descriptorIdx));
if (methodRef.getName().equals("<init>")) {
// java bytecode don't use that flag
accessFlags |= AccessFlags.CONSTRUCTOR;
}
method.setData(accessFlags, attributes);
}
use of jadx.plugins.input.java.data.attributes.JavaAttrStorage in project jadx by skylot.
the class JavaCodeReader method getDebugInfo.
@Override
@Nullable
public IDebugInfo getDebugInfo() {
int maxStack = readMaxStack();
reader.skip(2);
reader.skip(reader.readU4());
reader.skip(reader.readU2() * 8);
JavaAttrStorage attrs = clsData.getAttributesReader().load(reader);
LineNumberTableAttr linesAttr = attrs.get(JavaAttrType.LINE_NUMBER_TABLE);
LocalVarsAttr varsAttr = attrs.get(JavaAttrType.LOCAL_VAR_TABLE);
if (linesAttr == null && varsAttr == null) {
return null;
}
Map<Integer, Integer> linesMap = linesAttr != null ? linesAttr.getLineMap() : Collections.emptyMap();
List<ILocalVar> vars;
if (varsAttr == null) {
vars = Collections.emptyList();
} else {
List<JavaLocalVar> javaVars = varsAttr.getVars();
LocalVarTypesAttr typedVars = attrs.get(JavaAttrType.LOCAL_VAR_TYPE_TABLE);
if (typedVars != null && !typedVars.getVars().isEmpty()) {
// merge signature from typedVars into javaVars
Map<JavaLocalVar, JavaLocalVar> varsMap = new HashMap<>(javaVars.size());
javaVars.forEach(v -> varsMap.put(v, v));
for (JavaLocalVar typedVar : typedVars.getVars()) {
JavaLocalVar jv = varsMap.get(typedVar);
if (jv != null) {
jv.setSignature(typedVar.getSignature());
}
}
}
javaVars.forEach(v -> v.shiftRegNum(maxStack));
vars = Collections.unmodifiableList(javaVars);
}
return new DebugInfo(linesMap, vars);
}
Aggregations