private static void appendAnnotations(TextBuffer buffer, int indent, StructMember mb, int targetType) { Set<String> filter = new HashSet<>(); for (StructGeneralAttribute.Key<?> key : ANNOTATION_ATTRIBUTES) { StructAnnotationAttribute attribute = (StructAnnotationAttribute)mb.getAttribute(key); if (attribute != null) { for (AnnotationExprent annotation : attribute.getAnnotations()) { String text = annotation.toJava(indent, BytecodeMappingTracer.DUMMY).toString(); filter.add(text); buffer.append(text).appendLineSeparator(); } } } appendTypeAnnotations(buffer, indent, mb, targetType, -1, filter); }
public boolean isSynthetic() { return hasModifier(CodeConstants.ACC_SYNTHETIC) || hasAttribute(StructGeneralAttribute.ATTRIBUTE_SYNTHETIC); }
protected Map<String, StructGeneralAttribute> readAttributes(DataInputFullStream in, ConstantPool pool) throws IOException { int length = in.readUnsignedShort(); Map<String, StructGeneralAttribute> attributes = new HashMap<>(length); for (int i = 0; i < length; i++) { int nameIndex = in.readUnsignedShort(); String name = pool.getPrimitiveConstant(nameIndex).getString(); StructGeneralAttribute attribute = readAttribute(in, pool, name); if (attribute != null) { if (StructGeneralAttribute.ATTRIBUTE_LOCAL_VARIABLE_TABLE.getName().equals(name) && attributes.containsKey(name)) { // merge all variable tables StructLocalVariableTableAttribute table = (StructLocalVariableTableAttribute)attributes.get(name); table.add((StructLocalVariableTableAttribute)attribute); } else if (StructGeneralAttribute.ATTRIBUTE_LOCAL_VARIABLE_TYPE_TABLE.getName().equals(name) && attributes.containsKey(name)) { // merge all variable tables StructLocalVariableTypeTableAttribute table = (StructLocalVariableTypeTableAttribute)attributes.get(name); table.add((StructLocalVariableTypeTableAttribute)attribute); } else { attributes.put(attribute.getName(), attribute); } } } return attributes; }
public boolean isSynthetic() { return hasModifier(CodeConstants.ACC_SYNTHETIC) || hasAttribute(StructGeneralAttribute.ATTRIBUTE_SYNTHETIC); }
private static void appendTypeAnnotations(TextBuffer buffer, int indent, StructMember mb, int targetType, int index, Set<String> filter) { for (StructGeneralAttribute.Key<?> key : TYPE_ANNOTATION_ATTRIBUTES) { StructTypeAnnotationAttribute attribute = (StructTypeAnnotationAttribute)mb.getAttribute(key); if (attribute != null) { for (TypeAnnotation annotation : attribute.getAnnotations()) { if (annotation.isTopLevel() && annotation.getTargetType() == targetType && (index < 0 || annotation.getIndex() == index)) { String text = annotation.getAnnotation().toJava(indent, BytecodeMappingTracer.DUMMY).toString(); if (!filter.contains(text)) { buffer.append(text); if (indent < 0) { buffer.append(' '); } else { buffer.appendLineSeparator(); } } } } } } }
@Override protected StructGeneralAttribute readAttribute(DataInputFullStream in, ConstantPool pool, String name) throws IOException { if (StructGeneralAttribute.ATTRIBUTE_CODE.getName().equals(name)) { if (!classStruct.isOwn()) { // skip code in foreign classes in.discard(8); in.discard(in.readInt()); in.discard(8 * in.readUnsignedShort()); } else { containsCode = true; in.discard(6); localVariables = in.readUnsignedShort(); codeLength = in.readInt(); in.discard(codeLength); int excLength = in.readUnsignedShort(); in.discard(excLength * 8); codeFullLength = codeLength + excLength * 8 + 2; } codeAttributes = readAttributes(in, pool); return null; } return super.readAttribute(in, pool, name); }
private static void appendAnnotations(TextBuffer buffer, int indent, StructMember mb, int targetType) { Set<String> filter = new HashSet<>(); for (String name : ANNOTATION_ATTRIBUTES) { StructAnnotationAttribute attribute = (StructAnnotationAttribute)mb.getAttribute(name); if (attribute != null) { for (AnnotationExprent annotation : attribute.getAnnotations()) { String text = annotation.toJava(indent, BytecodeMappingTracer.DUMMY).toString(); filter.add(text); buffer.append(text).appendLineSeparator(); } } } appendTypeAnnotations(buffer, indent, mb, targetType, -1, filter); }
protected Map<String, StructGeneralAttribute> readAttributes(DataInputFullStream in, ConstantPool pool) throws IOException { int length = in.readUnsignedShort(); Map<String, StructGeneralAttribute> attributes = new HashMap<>(length); for (int i = 0; i < length; i++) { int nameIndex = in.readUnsignedShort(); String name = pool.getPrimitiveConstant(nameIndex).getString(); StructGeneralAttribute attribute = readAttribute(in, pool, name); if (attribute != null) { if (StructGeneralAttribute.ATTRIBUTE_LOCAL_VARIABLE_TABLE.equals(name) && attributes.containsKey(name)) { // merge all variable tables StructLocalVariableTableAttribute table = (StructLocalVariableTableAttribute)attributes.get(name); table.add((StructLocalVariableTableAttribute)attribute); } else if (StructGeneralAttribute.ATTRIBUTE_LOCAL_VARIABLE_TYPE_TABLE.equals(name) && attributes.containsKey(name)) { // merge all variable tables StructLocalVariableTypeTableAttribute table = (StructLocalVariableTypeTableAttribute)attributes.get(name); table.add((StructLocalVariableTypeTableAttribute)attribute); } else { attributes.put(attribute.getName(), attribute); } } } return attributes; }
private static void appendTypeAnnotations(TextBuffer buffer, int indent, StructMember mb, int targetType, int index, Set<String> filter) { for (String name : TYPE_ANNOTATION_ATTRIBUTES) { StructTypeAnnotationAttribute attribute = (StructTypeAnnotationAttribute)mb.getAttribute(name); if (attribute != null) { for (TypeAnnotation annotation : attribute.getAnnotations()) { if (annotation.isTopLevel() && annotation.getTargetType() == targetType && (index < 0 || annotation.getIndex() == index)) { String text = annotation.getAnnotation().toJava(indent, BytecodeMappingTracer.DUMMY).toString(); if (!filter.contains(text)) { buffer.append(text); if (indent < 0) { buffer.append(' '); } else { buffer.appendLineSeparator(); } } } } } } }
@Override protected StructGeneralAttribute readAttribute(DataInputFullStream in, ConstantPool pool, String name) throws IOException { if (StructGeneralAttribute.ATTRIBUTE_CODE.equals(name)) { if (!classStruct.isOwn()) { // skip code in foreign classes in.discard(8); in.discard(in.readInt()); in.discard(8 * in.readUnsignedShort()); } else { containsCode = true; in.discard(6); localVariables = in.readUnsignedShort(); codeLength = in.readInt(); in.discard(codeLength); int excLength = in.readUnsignedShort(); in.discard(excLength * 8); codeFullLength = codeLength + excLength * 8 + 2; } codeAttributes = readAttributes(in, pool); return null; } return super.readAttribute(in, pool, name); }