01: package tide.bytecode.asm;
02:
03: import edu.umd.cs.findbugs.annotations.When;
04: import java.util.*;
05:
06: /** Used both for methods annotated with MustOverride (in the detection phase)
07: * and the methods overriding or missing to call super.
08: * Also used in the RecurseChecker
09: */
10: public final class ASMethod {
11: final public String classJavaName, sourceName; // abc.Hello Hello.java
12: final public String methodName; // hello
13: final String argsRAW; // I[[Ljava.lang.String;DLjava... ...S
14: final List<String> javaNames;
15: final public String javaSig; // int,java.lang.String[][],double,java.lang.Object,short
16:
17: public boolean callsOverridedMethod = false;
18: public boolean isCalledInSubclass = false;
19:
20: public boolean callsRecursively = false;
21:
22: public int issuePriority = 1;
23:
24: public int begLine = -1;
25:
26: public When annotationWhen = When.ANYTIME;
27:
28: // opt: the analysis pass here a message (failure)
29: private String failureMessage = "", failureCategory = "";
30:
31: public ASMethod(String classJavaName, String sourceName,
32: String method, String args) {
33: this .classJavaName = classJavaName;
34: this .sourceName = sourceName;
35: this .methodName = method;
36: this .argsRAW = args.substring(1, args.length() - 1);
37:
38: //System.out.println("\n\n====Analysing "+args);
39: javaNames = ASMUtils.readJavaNamesFromSignature(args);
40:
41: StringBuilder sb = new StringBuilder();
42: for (int i = 0; i < javaNames.size(); i++) {
43: if (i > 0)
44: sb.append(",");
45: sb.append(javaNames.get(i));
46: }
47: javaSig = sb.toString();
48: }
49:
50: public void setFailure(String mess, String cat) {
51: failureMessage = mess;
52: failureCategory = cat;
53: }
54:
55: public String getFailureMessage() {
56: return failureMessage;
57: }
58:
59: public String getFailureCategory() {
60: return failureCategory;
61: }
62:
63: @Override
64: public final String toString() {
65: return classJavaName + "(" + sourceName + ":" + begLine + "): "
66: + getSignature(true);
67: }
68:
69: public final String getSignature(boolean withFullClassName) {
70: StringBuilder sb = new StringBuilder();
71: if (withFullClassName) {
72: sb.append(classJavaName);
73: sb.append(".");
74: }
75: sb.append(methodName);
76: sb.append("(");
77: sb.append(javaSig);
78: sb.append(")");
79: return sb.toString();
80: }
81:
82: }
|