001: package edu.umd.cs.findbugs.ba;
002:
003: import java.lang.annotation.ElementType;
004: import java.util.Collection;
005:
006: import edu.umd.cs.findbugs.TigerSubstitutes;
007: import edu.umd.cs.findbugs.annotations.CheckForNull;
008: import edu.umd.cs.findbugs.classfile.CheckedAnalysisException;
009: import edu.umd.cs.findbugs.classfile.ClassDescriptor;
010: import edu.umd.cs.findbugs.classfile.Global;
011: import edu.umd.cs.findbugs.classfile.MethodDescriptor;
012: import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject;
013: import edu.umd.cs.findbugs.classfile.analysis.AnnotationValue;
014: import edu.umd.cs.findbugs.classfile.analysis.ClassInfo;
015: import edu.umd.cs.findbugs.internalAnnotations.DottedClassName;
016:
017: /**
018: * XMethod implementation for unresolvable methods.
019: * Returns some kind of reasonable default answer to questions
020: * that can't be answered (e.g., what are the access flags).
021: */
022: class UnresolvedXMethod extends AbstractMethod implements XMethod {
023: protected UnresolvedXMethod(@DottedClassName
024: String className, String methodName, String methodSig,
025: int accessFlags) {
026: super (className, methodName, methodSig, accessFlags);
027: if (XFactory.DEBUG_UNRESOLVED) {
028: System.out.println("Unresolved xmethod: " + this );
029: }
030: }
031:
032: protected UnresolvedXMethod(MethodDescriptor m) {
033: super (m.getClassDescriptor().getDottedClassName(), m.getName(),
034: m.getSignature(), 0);
035: if (XFactory.DEBUG_UNRESOLVED) {
036: System.out.println("Unresolved xmethod: " + this );
037: }
038: }
039:
040: /* (non-Javadoc)
041: * @see edu.umd.cs.findbugs.ba.XMethod#isReturnTypeReferenceType()
042: */
043: public boolean isReturnTypeReferenceType() {
044: SignatureParser parser = new SignatureParser(getSignature());
045: String returnTypeSig = parser.getReturnTypeSignature();
046: return SignatureParser.isReferenceType(returnTypeSig);
047: }
048:
049: /* (non-Javadoc)
050: * @see java.lang.Comparable#compareTo(java.lang.Object)
051: */
052: public int compareTo(Object o) {
053: if (o instanceof XMethod) {
054: return XFactory.compare((XMethod) this , (XMethod) o);
055: }
056: throw new ClassCastException("Don't know how to compare "
057: + this .getClass().getName() + " to "
058: + o.getClass().getName());
059: }
060:
061: /* (non-Javadoc)
062: * @see edu.umd.cs.findbugs.ba.XMethod#getAnnotation(edu.umd.cs.findbugs.classfile.ClassDescriptor)
063: */
064: public AnnotationValue getAnnotation(ClassDescriptor desc) {
065: return null;
066: }
067:
068: /* (non-Javadoc)
069: * @see edu.umd.cs.findbugs.ba.XMethod#getAnnotationDescriptors()
070: */
071: public Collection<ClassDescriptor> getAnnotationDescriptors() {
072: return TigerSubstitutes.emptyList();
073: }
074:
075: /* (non-Javadoc)
076: * @see edu.umd.cs.findbugs.ba.XMethod#getAnnotations()
077: */
078: public Collection<AnnotationValue> getAnnotations() {
079: return TigerSubstitutes.emptyList();
080: }
081:
082: /* (non-Javadoc)
083: * @see edu.umd.cs.findbugs.ba.XMethod#getParameterAnnotation(int, edu.umd.cs.findbugs.classfile.ClassDescriptor)
084: */
085: public AnnotationValue getParameterAnnotation(int param,
086: ClassDescriptor desc) {
087: return null;
088: }
089:
090: /* (non-Javadoc)
091: * @see edu.umd.cs.findbugs.ba.XMethod#getParameterAnnotationDescriptors(int)
092: */
093: public Collection<ClassDescriptor> getParameterAnnotationDescriptors(
094: int param) {
095: return TigerSubstitutes.emptyList();
096: }
097:
098: /* (non-Javadoc)
099: * @see edu.umd.cs.findbugs.ba.XMethod#getParameterAnnotations(int)
100: */
101: public Collection<AnnotationValue> getParameterAnnotations(int param) {
102: return TigerSubstitutes.emptyList();
103: }
104:
105: public ElementType getElementType() {
106: if (getName().equals("<init>"))
107: return ElementType.CONSTRUCTOR;
108: return ElementType.METHOD;
109: }
110:
111: public @CheckForNull
112: AnnotatedObject getContainingScope() {
113: try {
114: return (ClassInfo) Global.getAnalysisCache()
115: .getClassAnalysis(XClass.class,
116: getClassDescriptor());
117: } catch (CheckedAnalysisException e) {
118: return null;
119: }
120: }
121:
122: /* (non-Javadoc)
123: * @see edu.umd.cs.findbugs.ba.XMethod#getThrownExceptions()
124: */
125: public String[] getThrownExceptions() {
126:
127: return new String[0];
128: }
129:
130: /* (non-Javadoc)
131: * @see edu.umd.cs.findbugs.ba.XMethod#isUnconditionalThrower()
132: */
133: public boolean isUnconditionalThrower() {
134: return false;
135: }
136:
137: /* (non-Javadoc)
138: * @see edu.umd.cs.findbugs.ba.XMethod#isAbstract()
139: */
140: public boolean isAbstract() {
141: return false;
142: }
143:
144: /* (non-Javadoc)
145: * @see edu.umd.cs.findbugs.ba.AccessibleEntity#isSynthetic()
146: */
147: public boolean isSynthetic() {
148: // TODO Auto-generated method stub
149: return false;
150: }
151:
152: /* (non-Javadoc)
153: * @see edu.umd.cs.findbugs.ba.AccessibleEntity#isDeprecated()
154: */
155: public boolean isDeprecated() {
156: // TODO Auto-generated method stub
157: return false;
158: }
159:
160: }
|