HashMap<String, Integer> getGlobalRequirementsMethods() { HashMap<String, Integer> map = new HashMap<String, Integer>(); // <2do> this is extremely braindead, since inefficient // it would be much better to do this with Class<?> instead of ClassInfo, but // then we need a JPF- ClassLoader, since the path might be different. As a // middle ground, we could use BCEL for (ClassCoverage cc : classes.values()) { ClassInfo ci = ClassInfo.getResolvedClassInfo(cc.className); for (MethodInfo mi : ci.getDeclaredMethodInfos()) { AnnotationInfo ai = getRequirementsAnnotation(mi); if (ai != null) { for (String id : ai.getValueAsStringArray()) { Integer n = map.get(id); if (n == null) { map.put(id, 1); } else { map.put(id, n + 1); } } } } } return map; }
public void instructionExecuted(JVM vm) { Instruction insn = vm.getLastInstruction(); MethodCoverage mc = getMethodCoverage(vm); if (mc != null) { mc.setExecuted(vm.getLastThreadInfo(), insn); if (showRequirements) { if (insn.getPosition() == 0) { // first insn in method, check for Requirements AnnotationInfo ai = getRequirementsAnnotation(mc.getMethodInfo()); if (ai != null) { String[] ids = ai.getValueAsStringArray(); updateRequirementsCoverage(ids, mc); } } } } }