use of edu.umd.cs.findbugs.OpcodeStack in project fb-contrib by mebigfatguy.
the class WiringIssues method visitClassContext.
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value = "SF_SWITCH_NO_DEFAULT", justification = "Only a few cases need special handling")
@Override
public void visitClassContext(ClassContext classContext) {
try {
JavaClass cls = classContext.getJavaClass();
Field[] fields = cls.getFields();
if (fields.length > 0) {
Map<WiringType, FieldAnnotation> wiredFields = new HashMap<>();
boolean loadedParents = false;
for (Field field : fields) {
boolean hasAutowired = false;
String qualifier = "";
for (AnnotationEntry entry : field.getAnnotationEntries()) {
switch(entry.getAnnotationType()) {
case SPRING_AUTOWIRED:
if (!loadedParents) {
loadParentAutowireds(cls.getSuperClass(), wiredFields);
loadedParents = true;
}
hasAutowired = true;
break;
case SPRING_QUALIFIER:
qualifier = entry.getElementValuePairs()[0].getValue().stringifyValue();
break;
}
}
if (hasAutowired) {
WiringType wt = new WiringType(field.getSignature(), field.getGenericSignature(), qualifier);
FieldAnnotation existingAnnotation = wiredFields.get(wt);
if (existingAnnotation == null) {
wiredFields.put(wt, FieldAnnotation.fromBCELField(cls.getClassName(), field));
} else {
bugReporter.reportBug(new BugInstance(this, BugType.WI_DUPLICATE_WIRED_TYPES.name(), NORMAL_PRIORITY).addClass(cls).addField(FieldAnnotation.fromBCELField(cls, field)).addField(existingAnnotation));
wiredFields.remove(wt);
}
}
}
}
stack = new OpcodeStack();
super.visitClassContext(classContext);
} catch (ClassNotFoundException e) {
bugReporter.reportMissingClass(e);
} finally {
stack = null;
}
}
use of edu.umd.cs.findbugs.OpcodeStack in project fb-contrib by mebigfatguy.
the class DubiousSetOfCollections method visitClassContext.
/**
* implement the visitor to set up the opcode stack, and make sure that collection, set and map classes could be loaded.
*
* @param clsContext
* the context object of the currently parsed class
*/
@Override
public void visitClassContext(ClassContext clsContext) {
try {
if ((collectionCls == null) || (setCls == null) || (mapCls == null)) {
return;
}
stack = new OpcodeStack();
super.visitClassContext(clsContext);
} finally {
stack = null;
}
}
use of edu.umd.cs.findbugs.OpcodeStack in project fb-contrib by mebigfatguy.
the class ExceptionSoftening method visitClassContext.
/**
* overrides the visitor to reset the stack
*
* @param classContext
* the context object of the currently parsed class
*/
@Override
public void visitClassContext(ClassContext classContext) {
try {
if (runtimeClass != null) {
stack = new OpcodeStack();
super.visitClassContext(classContext);
}
} finally {
stack = null;
}
}
use of edu.umd.cs.findbugs.OpcodeStack in project fb-contrib by mebigfatguy.
the class InvalidConstantArgument method visitClassContext.
/**
* overrides the visitor to initialize the opcode stack
*
* @param classContext
* the context of the currently parsed class
*/
@Override
public void visitClassContext(ClassContext classContext) {
try {
stack = new OpcodeStack();
super.visitClassContext(classContext);
} finally {
stack = null;
}
}
use of edu.umd.cs.findbugs.OpcodeStack in project fb-contrib by mebigfatguy.
the class JDBCVendorReliance method visitClassContext.
/**
* implements the visitor to reset the stack and jdbc locals
*
* @param classContext
* the context object of the currently parsed class
*/
@Override
public void visitClassContext(ClassContext classContext) {
stack = new OpcodeStack();
jdbcLocals = new HashMap<>();
super.visitClassContext(classContext);
stack = null;
jdbcLocals = null;
}
Aggregations