/** * Methods marked with the "Synthetic" attribute do not appear in the source * code */ private boolean isSynthetic(Method m) { if ((m.getAccessFlags() & Const.ACC_SYNTHETIC) != 0) { return true; } Attribute[] attrs = m.getAttributes(); for (Attribute attr : attrs) { if (attr instanceof Synthetic) { return true; } } return false; }
private boolean markedAsNotUsable(Method obj) { for (Attribute a : obj.getAttributes()) { if (a instanceof Deprecated) { return true; } } Code code = obj.getCode(); if (code == null) { return false; } byte[] codeBytes = code.getCode(); if (codeBytes.length > 1 && codeBytes.length < 10) { int lastOpcode = codeBytes[codeBytes.length - 1] & 0xff; if (lastOpcode != Const.ATHROW) { return false; } for (int b : codeBytes) { if ((b & 0xff) == Const.RETURN) { return false; } } return true; } return false; }
fout.write(RBRA); ArrayList<LocalVariable[]> locals = new ArrayList<>(); for (Attribute a : m.getAttributes()) { if (a.getTag() == org.apache.bcel.Const.ATTR_EXCEPTIONS) { for (int i : ((ExceptionTable) a).getExceptionIndexTable()) {
public void doVisitMethod(Method method) { if (visitingMethod) { throw new IllegalStateException("doVisitMethod called when already visiting a method"); } visitingMethod = true; try { this.method = method; methodName = methodSig = dottedMethodSig = fullyQualifiedMethodName = null; thisMethodInfo = (MethodInfo) thisClassInfo.findMethod(getMethodName(), getMethodSig(), method.isStatic()); assert thisMethodInfo != null : "Can't get method info for " + getFullyQualifiedMethodName(); this.method.accept(this); Attribute[] attributes = method.getAttributes(); for (Attribute attribute : attributes) { attribute.accept(this); } } finally { visitingMethod = false; this.method = null; this.thisMethodInfo = null; } }
GenericSignatureParser parser = null; String genericSignature = null; for (Attribute a : target.getAttributes()) { if (a instanceof Signature) {
Attribute[] atts = getMethod().getAttributes(); for (Attribute att : atts) { if (att.getClass().equals(Synthetic.class)) {
for (Attribute a : obj.getAttributes()) { if (a instanceof Code) { code = (Code) a;
/** * @return Annotations on the parameters of a method * @since 6.0 */ public ParameterAnnotationEntry[] getParameterAnnotationEntries() { if (parameterAnnotationEntries == null) { parameterAnnotationEntries = ParameterAnnotationEntry.createParameterAnnotationEntries(getAttributes()); } return parameterAnnotationEntries; } }
/** * Methods marked with the "Synthetic" attribute do not appear in the source * code */ private boolean isSynthetic(Method m) { if ((m.getAccessFlags() & Constants.ACC_SYNTHETIC) != 0) { return true; } Attribute[] attrs = m.getAttributes(); for (Attribute attr : attrs) { if (attr instanceof Synthetic) { return true; } } return false; }
@Override public void visitMethod(final Method method) { stack.push(method); method.accept(visitor); final Attribute[] attributes = method.getAttributes(); for (final Attribute attribute : attributes) { attribute.accept(this); } stack.pop(); }
public void visitMethod(Method method) { stack.push(method); method.accept(visitor); Attribute[] attributes = method.getAttributes(); for(int i=0; i < attributes.length; i++) attributes[i].accept(this); stack.pop(); }
private boolean markedAsNotUsable(Method obj) { for (Attribute a : obj.getAttributes()) { if (a instanceof Deprecated) { return true; } } Code code = obj.getCode(); if (code == null) { return false; } byte[] codeBytes = code.getCode(); if (codeBytes.length > 1 && codeBytes.length < 10) { int lastOpcode = codeBytes[codeBytes.length - 1] & 0xff; if (lastOpcode != ATHROW) { return false; } for (int b : codeBytes) { if ((b & 0xff) == RETURN) { return false; } } return true; } return false; }
public ClassModelMethod(org.apache.bcel.classfile.Method method, int _index) { index = _index; methodAccessFlags = method.getAccessFlags(); nameIndex = method.getNameIndex(); descriptorIndex = method.getSignatureIndex(); methodAttributePool = new AttributePool(method.getAttributes(), getName()); codeEntry = methodAttributePool.codeEntry; }
public void doVisitMethod(Method method) { if (visitingMethod) { throw new IllegalStateException("doVisitMethod called when already visiting a method"); } visitingMethod = true; try { this.method = method; methodName = methodSig = dottedMethodSig = fullyQualifiedMethodName = null; thisMethodInfo = (MethodInfo) thisClassInfo.findMethod(getMethodName(), getMethodSig(), method.isStatic()); assert thisMethodInfo != null : "Can't get method info for " + getFullyQualifiedMethodName(); this.method.accept(this); Attribute[] attributes = method.getAttributes(); for (Attribute attribute : attributes) { attribute.accept(this); } } finally { visitingMethod = false; this.method = null; this.thisMethodInfo = null; } }
GenericSignatureParser parser = null; String genericSignature = null; for (Attribute a : target.getAttributes()) { if (a instanceof Signature) {
/** * implements the visitor to find methods that declare template parameters that are not bound to any parameter. * * @param obj * the context object of the currently parsed method */ @Override public void visitMethod(Method obj) { Attribute[] attributes = obj.getAttributes(); for (Attribute a : attributes) { if ("Signature".equals(a.getName())) { TemplateSignature ts = parseSignatureAttribute((Signature) a); if (ts != null) { for (TemplateItem templateParm : ts.templateParameters) { if (!ts.signature.contains(Values.SIG_GENERIC_TEMPLATE + templateParm.templateType + Values.SIG_QUALIFIED_CLASS_SUFFIX_CHAR) && !isTemplateParent(templateParm.templateType, ts.templateParameters)) { bugReporter.reportBug(new BugInstance(this, BugType.UMTP_UNBOUND_METHOD_TEMPLATE_PARAMETER.name(), NORMAL_PRIORITY).addClass(this) .addMethod(this).addString("Template Parameter: " + templateParm.templateType)); return; } } } return; } } }
/** * implements the visitor to find methods that declare template parameters that are not bound to any parameter. * * @param obj * the context object of the currently parsed method */ @Override public void visitMethod(Method obj) { Attribute[] attributes = obj.getAttributes(); for (Attribute a : attributes) { if ("Signature".equals(a.getName())) { TemplateSignature ts = parseSignatureAttribute((Signature) a); if (ts != null) { for (TemplateItem templateParm : ts.templateParameters) { if (!ts.signature.contains(Values.SIG_GENERIC_TEMPLATE + templateParm.templateType + Values.SIG_QUALIFIED_CLASS_SUFFIX_CHAR) && !isTemplateParent(templateParm.templateType, ts.templateParameters)) { bugReporter.reportBug(new BugInstance(this, BugType.UMTP_UNBOUND_METHOD_TEMPLATE_PARAMETER.name(), NORMAL_PRIORITY).addClass(this) .addMethod(this).addString("Template Parameter: " + templateParm.templateType)); return; } } } return; } } }
Attribute[] atts = getMethod().getAttributes(); for (Attribute att : atts) { if (att.getClass().equals(Synthetic.class)) {
private void addDefaults(Type type) { try { ClassUnit classUnit= Project.singleton.getClassUnit(type.toString()); JavaClass aClass= Repository.lookupClass(type.toString()); for (Method method : aClass.getMethods()) { final AnnotationDefault a= (AnnotationDefault) findAttribute("AnnotationDefault", method.getAttributes()); if (a != null) if (a.getDefaultValue() instanceof ClassElementValue) { ClassElementValue aClass1= (ClassElementValue) a.getDefaultValue(); classUnit.addAnnotationDefault(method.getName(), aClass1.getClassString()); } else classUnit.addAnnotationDefault(method.getName(), a.getDefaultValue().toString()); } } catch (Exception e) { throw new RuntimeException(e); } }
/** * For values in an annotation that have default values, we should be able * to query the AnnotationDefault attribute against the method to discover * the default value that was originally declared. */ public void testMethodAnnotations() throws ClassNotFoundException { final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.SimpleAnnotation"); final Method m = getMethod(clazz, "fruit"); final AnnotationDefault a = (AnnotationDefault) findAttribute( "AnnotationDefault", m.getAttributes()); final SimpleElementValue val = (SimpleElementValue) a.getDefaultValue(); assertTrue("Should be STRING but is " + val.getElementValueType(), val .getElementValueType() == ElementValue.STRING); assertTrue("Should have default of bananas but default is " + val.getValueString(), val.getValueString().equals("bananas")); } }