/** * Mark this method as being synthetic by adding a special attribute. */ public void markSynthetic() { addAttribute(new SyntheticAttr(mCp)); }
/** * Mark this method as being deprecated by adding a special attribute. */ public void markDeprecated() { addAttribute(new DeprecatedAttr(mCp)); }
/** * Add a declared exception that this method may throw. */ public void addException(TypeDesc type) { if (mExceptions == null) { addAttribute(new ExceptionsAttr(mCp)); } // TODO: Special handling for generics ConstantClassInfo cci = mCp.addConstantClass(type); mExceptions.addException(cci); }
static MethodInfo readFrom(ClassFile parent, DataInput din, AttributeFactory attrFactory) throws IOException { ConstantPool cp = parent.getConstantPool(); int modifier = din.readUnsignedShort(); int index = din.readUnsignedShort(); ConstantUTFInfo nameConstant = (ConstantUTFInfo)cp.getConstant(index); index = din.readUnsignedShort(); ConstantUTFInfo descConstant = (ConstantUTFInfo)cp.getConstant(index); MethodInfo info = new MethodInfo(parent, modifier, nameConstant, descConstant); // Read attributes. int size = din.readUnsignedShort(); for (int i=0; i<size; i++) { info.addAttribute(Attribute.readFrom(cp, din, attrFactory)); } return info; } }
/** * Add a runtime invisible annotation. */ public Annotation addRuntimeInvisibleAnnotation(TypeDesc type) { AnnotationsAttr attr = null; for (int i = mAttributes.size(); --i >= 0; ) { Attribute a = mAttributes.get(i); if (a instanceof RuntimeInvisibleAnnotationsAttr) { attr = (AnnotationsAttr) a; } } if (attr == null) { attr = new RuntimeInvisibleAnnotationsAttr(mCp); addAttribute(attr); } Annotation ann = new Annotation(mCp); ann.setType(type); attr.addAnnotation(ann); return ann; }
/** * Add a runtime visible annotation. */ public Annotation addRuntimeVisibleAnnotation(TypeDesc type) { AnnotationsAttr attr = null; for (int i = mAttributes.size(); --i >= 0; ) { Attribute a = mAttributes.get(i); if (a instanceof RuntimeVisibleAnnotationsAttr) { attr = (AnnotationsAttr) a; } } if (attr == null) { attr = new RuntimeVisibleAnnotationsAttr(mCp); addAttribute(attr); } Annotation ann = new Annotation(mCp); ann.setType(type); attr.addAnnotation(ann); return ann; }
MethodInfo(ClassFile parent, Modifiers modifiers, String name, MethodDesc desc) { mParent = parent; mCp = parent.getConstantPool(); mName = name; mDesc = desc; mModifiers = modifiers; mNameConstant = mCp.addConstantUTF(name); mDescriptorConstant = mCp.addConstantUTF(desc.getDescriptor()); if (!modifiers.isAbstract() && !modifiers.isNative()) { addAttribute(new CodeAttr(mCp)); } }
/** * Mark this method as being synthetic by adding a special attribute. */ public void markSynthetic() { addAttribute(new SyntheticAttr(mCp)); }
/** * Mark this method as being deprecated by adding a special attribute. */ public void markDeprecated() { addAttribute(new DeprecatedAttr(mCp)); }
/** * Add a declared exception that this method may throw. */ public void addException(TypeDesc type) { if (mExceptions == null) { addAttribute(new ExceptionsAttr(mCp)); } // TODO: Special handling for generics ConstantClassInfo cci = mCp.addConstantClass(type); mExceptions.addException(cci); }
/** * Add a runtime invisible annotation. */ public Annotation addRuntimeInvisibleAnnotation(TypeDesc type) { AnnotationsAttr attr = null; for (int i = mAttributes.size(); --i >= 0; ) { Attribute a = mAttributes.get(i); if (a instanceof RuntimeInvisibleAnnotationsAttr) { attr = (AnnotationsAttr) a; } } if (attr == null) { attr = new RuntimeInvisibleAnnotationsAttr(mCp); addAttribute(attr); } Annotation ann = new Annotation(mCp); ann.setType(type); attr.addAnnotation(ann); return ann; }
static MethodInfo readFrom(ClassFile parent, DataInput din, AttributeFactory attrFactory) throws IOException { ConstantPool cp = parent.getConstantPool(); int modifier = din.readUnsignedShort(); int index = din.readUnsignedShort(); ConstantUTFInfo nameConstant = (ConstantUTFInfo)cp.getConstant(index); index = din.readUnsignedShort(); ConstantUTFInfo descConstant = (ConstantUTFInfo)cp.getConstant(index); MethodInfo info = new MethodInfo(parent, modifier, nameConstant, descConstant); // Read attributes. int size = din.readUnsignedShort(); for (int i=0; i<size; i++) { info.addAttribute(Attribute.readFrom(cp, din, attrFactory)); } return info; } }
/** * Add a runtime visible annotation. */ public Annotation addRuntimeVisibleAnnotation(TypeDesc type) { AnnotationsAttr attr = null; for (int i = mAttributes.size(); --i >= 0; ) { Attribute a = mAttributes.get(i); if (a instanceof RuntimeVisibleAnnotationsAttr) { attr = (AnnotationsAttr) a; } } if (attr == null) { attr = new RuntimeVisibleAnnotationsAttr(mCp); addAttribute(attr); } Annotation ann = new Annotation(mCp); ann.setType(type); attr.addAnnotation(ann); return ann; }
MethodInfo(ClassFile parent, Modifiers modifiers, String name, MethodDesc desc) { mParent = parent; mCp = parent.getConstantPool(); mName = name; mDesc = desc; mModifiers = modifiers; mNameConstant = mCp.addConstantUTF(name); mDescriptorConstant = mCp.addConstantUTF(desc.getDescriptor()); if (!modifiers.isAbstract() && !modifiers.isNative()) { addAttribute(new CodeAttr(mCp)); } }