@Override public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { backingAttribute.initContent(data, pool); }
@Override public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { annotations = parseAnnotations(pool, data); }
public String getSignature(int index, int visibleOffset) { return backingAttribute.getDescriptor(index, visibleOffset); } }
if (ATTRIBUTE_INNER_CLASSES.getName().equals(name)) { attr = new StructInnerClassesAttribute(); else if (ATTRIBUTE_CONSTANT_VALUE.getName().equals(name)) { attr = new StructConstantValueAttribute(); else if (ATTRIBUTE_SIGNATURE.getName().equals(name)) { attr = new StructGenericSignatureAttribute(); else if (ATTRIBUTE_ANNOTATION_DEFAULT.getName().equals(name)) { attr = new StructAnnDefaultAttribute(); else if (ATTRIBUTE_EXCEPTIONS.getName().equals(name)) { attr = new StructExceptionsAttribute(); else if (ATTRIBUTE_ENCLOSING_METHOD.getName().equals(name)) { attr = new StructEnclosingMethodAttribute(); else if (ATTRIBUTE_RUNTIME_VISIBLE_ANNOTATIONS.getName().equals(name) || ATTRIBUTE_RUNTIME_INVISIBLE_ANNOTATIONS.getName().equals(name)) { attr = new StructAnnotationAttribute(); else if (ATTRIBUTE_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS.getName().equals(name) || ATTRIBUTE_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS.getName().equals(name)) { attr = new StructAnnotationParameterAttribute(); else if (ATTRIBUTE_RUNTIME_VISIBLE_TYPE_ANNOTATIONS.getName().equals(name) || ATTRIBUTE_RUNTIME_INVISIBLE_TYPE_ANNOTATIONS.getName().equals(name)) { attr = new StructTypeAnnotationAttribute(); else if (ATTRIBUTE_LOCAL_VARIABLE_TABLE.getName().equals(name)) { attr = new StructLocalVariableTableAttribute();
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; }
protected StructGeneralAttribute readAttribute(DataInputFullStream in, ConstantPool pool, String name) throws IOException { StructGeneralAttribute attribute = StructGeneralAttribute.createAttribute(name); int length = in.readInt(); if (attribute == null) { in.discard(length); } else { attribute.initContent(in, pool); } return attribute; } }
public String getName(int index, int visibleOffset) { return matchingVars(index, visibleOffset).map(v -> v.name).findFirst().orElse(null); }
private static boolean findAndRemoveReturnCheck(Statement stat, StructMethod mt) { boolean is_notnull_check = false; // method annotation, refers to the return value StructAnnotationAttribute attr = mt.getAttribute(StructGeneralAttribute.ATTRIBUTE_RUNTIME_INVISIBLE_ANNOTATIONS); if (attr != null) { List<AnnotationExprent> annotations = attr.getAnnotations(); for (AnnotationExprent ann : annotations) { if (ann.getClassName().equals("org/jetbrains/annotations/NotNull")) { is_notnull_check = true; } } } return is_notnull_check && removeReturnCheck(stat, mt); }
@Override public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { defaultValue = StructAnnotationAttribute.parseAnnotationElement(data, pool); }
public void add(StructLocalVariableTypeTableAttribute attr) { backingAttribute.add(attr.backingAttribute); }
public static List<AnnotationExprent> parseAnnotations(ConstantPool pool, DataInputStream data) throws IOException { int len = data.readUnsignedShort(); if (len > 0) { List<AnnotationExprent> annotations = new ArrayList<>(len); for (int i = 0; i < len; i++) { annotations.add(parseAnnotation(data, pool)); } return annotations; } else { return Collections.emptyList(); } }
@Override public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { int len = data.readUnsignedShort(); if (len > 0) { annotations = new ArrayList<>(len); for (int i = 0; i < len; i++) { annotations.add(parse(data, pool)); } } else { annotations = Collections.emptyList(); } }
private boolean isAmbiguous() { MethodWrapper method = (MethodWrapper)DecompilerContext.getProperty(DecompilerContext.CURRENT_METHOD_WRAPPER); if (method != null) { StructLocalVariableTableAttribute attr = method.methodStruct.getLocalVariableAttr(); if (attr != null) { return attr.containsName(name); } } return false; }
public static GenericClassDescriptor getGenericClassDescriptor(StructClass cl) { if (DecompilerContext.getOption(IFernflowerPreferences.DECOMPILE_GENERIC_SIGNATURES)) { StructGenericSignatureAttribute attr = cl.getAttribute(StructGeneralAttribute.ATTRIBUTE_SIGNATURE); if (attr != null) { return GenericMain.parseClassSignature(attr.getSignature()); } } return null; }
public String getDebugName(StructMethod method) { StructLocalVariableTableAttribute attr = method.getLocalVariableAttr(); if (attr != null && processor != null) { Integer origIndex = processor.getVarOriginalIndex(index); if (origIndex != null) { String name = attr.getName(origIndex, visibleOffset); if (name != null && TextUtil.isValidIdentifier(name, method.getClassStruct().getBytecodeVersion())) { return name; } } } return null; }
public <T extends StructGeneralAttribute> T getAttribute(StructGeneralAttribute.Key<T> attribute) { //noinspection unchecked return (T)attributes.get(attribute.getName()); }
@Override public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { int len = data.readUnsignedByte(); if (len > 0) { paramAnnotations = new ArrayList<>(len); for (int i = 0; i < len; i++) { List<AnnotationExprent> annotations = StructAnnotationAttribute.parseAnnotations(pool, data); paramAnnotations.add(annotations); } } else { paramAnnotations = Collections.emptyList(); } }
public String getDescriptor(int index, int visibleOffset) { return matchingVars(index, visibleOffset).map(v -> v.descriptor).findFirst().orElse(null); }
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 hasAttribute(StructGeneralAttribute.Key<?> attribute) { return attributes.containsKey(attribute.getName()); }