Object obj = toanalyze.iterator().next();
ClassDescriptor cd = (ClassDescriptor) obj;
toanalyze.remove(cd);
+
if (!cd.isInterface()) {
for (Iterator method_it = cd.getMethods(); method_it.hasNext();) {
MethodDescriptor md = (MethodDescriptor) method_it.next();
checkMethodBody(cd, md);
}
}
+
}
for (Iterator iterator = annotatedMDSet.iterator(); iterator.hasNext();) {
MethodDescriptor md = (MethodDescriptor) iterator.next();
- ssjava.putHasAnnotation(md);
+ ssjava.addAnnotationRequire(md);
}
Set<Pair> visited = new HashSet<Pair>();
while (!tovisit.isEmpty()) {
MethodDescriptor callerMD = tovisit.iterator().next();
tovisit.remove(callerMD);
+
Set<MethodDescriptor> calleeSet = caller2calleeSet.get(callerMD);
if (calleeSet != null) {
for (Iterator iterator = calleeSet.iterator(); iterator.hasNext();) {
Pair p = new Pair(callerMD, calleeMD);
if (!visited.contains(p)) {
visited.add(p);
+
tovisit.add(calleeMD);
- ssjava.putHasAnnotation(calleeMD);
+
+ Set<MethodDescriptor> possibleCalleeSet =
+ (Set<MethodDescriptor>) ssjava.getCallGraph().getMethods(calleeMD);
+
+ for (Iterator iterator2 = possibleCalleeSet.iterator(); iterator2.hasNext();) {
+ MethodDescriptor possibleCallee = (MethodDescriptor) iterator2.next();
+
+ if (!possibleCallee.isAbstract()) {
+ ssjava.addAnnotationRequire(possibleCallee);
+ tovisit.add(possibleCallee);
+ }
+
+ }
+
}
}
}
// be annotated.
Set<MethodDescriptor> tovisit = new HashSet<MethodDescriptor>();
- tovisit.addAll(ssjava.getMd2hasAnnotation().keySet());
+ tovisit.addAll(ssjava.getAnnotationRequireSet());
while (!tovisit.isEmpty()) {
MethodDescriptor md = tovisit.iterator().next();
MethodDescriptor matchmd = (MethodDescriptor) methodit.next();
if (md.matches(matchmd)) {
if (matchmd.getClassDesc().equals(subCD)) {
- ssjava.putHasAnnotation(matchmd);
+ ssjava.addAnnotationRequire(matchmd);
}
}
}
}
}
+
+ // need to check super classess if the current method is inherited from
+ // them, all of ancestor method should be annoated
+ ClassDescriptor currentCd = cd;
+ ClassDescriptor superCd = tu.getSuper(currentCd);
+ while (!superCd.getSymbol().equals("Object")) {
+ Set possiblematches = superCd.getMethodTable().getSet(md.getSymbol());
+ for (Iterator methodit = possiblematches.iterator(); methodit.hasNext();) {
+ MethodDescriptor matchmd = (MethodDescriptor) methodit.next();
+ if (md.matches(matchmd)) {
+ ssjava.addAnnotationRequire(matchmd);
+ }
+ }
+ currentCd = superCd;
+ superCd = tu.getSuper(currentCd);
+ }
+
+ Set<ClassDescriptor> superIFSet = tu.getSuperIFs(cd);
+ for (Iterator iterator = superIFSet.iterator(); iterator.hasNext();) {
+ ClassDescriptor parentInterface = (ClassDescriptor) iterator.next();
+ Set possiblematches = parentInterface.getMethodTable().getSet(md.getSymbol());
+ for (Iterator methodit = possiblematches.iterator(); methodit.hasNext();) {
+ MethodDescriptor matchmd = (MethodDescriptor) methodit.next();
+ if (md.matches(matchmd)) {
+ ssjava.addAnnotationRequire(matchmd);
+ }
+ }
+ }
+
}
}
break;
case Kind.DeclarationNode:
- // checkLocationFromDeclarationNode(md, nametable, (DeclarationNode) bsn);
+ checkDeclarationNode(md, nametable, (DeclarationNode) bsn, flag);
break;
case Kind.IfStatementNode:
}
}
- void checkDeclarationNode(MethodDescriptor md, SymbolTable nametable, DeclarationNode dn,
+ private void checkDeclarationNode(MethodDescriptor md, SymbolTable nametable, DeclarationNode dn,
boolean flag) {
if (dn.getExpression() != null) {
checkExpressionNode(md, nametable, dn.getExpression(), flag);
}
}
- void checkReturnNode(MethodDescriptor md, SymbolTable nametable, ReturnNode rn, boolean flag) {
+ private void checkReturnNode(MethodDescriptor md, SymbolTable nametable, ReturnNode rn,
+ boolean flag) {
if (rn.getReturnExpression() != null) {
if (md.getReturnType() != null) {
checkExpressionNode(md, nametable, rn.getReturnExpression(), flag);
}
}
- void checkLoopNode(MethodDescriptor md, SymbolTable nametable, LoopNode ln, boolean flag) {
+ private void checkLoopNode(MethodDescriptor md, SymbolTable nametable, LoopNode ln, boolean flag) {
if (ln.getType() == LoopNode.WHILELOOP || ln.getType() == LoopNode.DOWHILELOOP) {
checkExpressionNode(md, nametable, ln.getCondition(), flag);
checkBlockNode(md, nametable, ln.getBody(), flag);
}
}
- void checkIfStatementNode(MethodDescriptor md, SymbolTable nametable, IfStatementNode isn,
- boolean flag) {
+ private void checkIfStatementNode(MethodDescriptor md, SymbolTable nametable,
+ IfStatementNode isn, boolean flag) {
checkExpressionNode(md, nametable, isn.getCondition(), flag);
checkBlockNode(md, nametable, isn.getTrueBlock(), flag);
if (isn.getFalseBlock() != null) {