01: /*
02: * FindBugs - Find Bugs in Java programs
03: * Copyright (C) 2005, University of Maryland
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: */
19:
20: package edu.umd.cs.findbugs.detect;
21:
22: import org.apache.bcel.classfile.JavaClass;
23:
24: import edu.umd.cs.findbugs.BugReporter;
25: import edu.umd.cs.findbugs.Detector;
26: import edu.umd.cs.findbugs.NonReportingDetector;
27: import edu.umd.cs.findbugs.ba.AnalysisContext;
28: import edu.umd.cs.findbugs.ba.ClassContext;
29: import edu.umd.cs.findbugs.ba.NullnessAnnotationDatabase;
30: import edu.umd.cs.findbugs.bcel.BCELUtil;
31:
32: /**
33: * Scan classes for @NonNull, @PossiblyNull and @CheckForNull annotations,
34: * and convey them to FindNullDeref.
35: *
36: * @deprecated AnnotationDatabases are being phased out, since
37: * annotations are now stored directly in the XClass/XMethod/XField objects.
38: * Resolving nullness annotations will be handled through the
39: * JSR-305 type qualifier code.
40: */
41: public class NoteNonNullAnnotations extends
42: BuildNonNullAnnotationDatabase implements Detector,
43: NonReportingDetector {
44:
45: public NoteNonNullAnnotations(BugReporter bugReporter) {
46: super (
47: AnalysisContext.currentAnalysisContext()
48: .getNullnessAnnotationDatabase() instanceof NullnessAnnotationDatabase ? (NullnessAnnotationDatabase) AnalysisContext
49: .currentAnalysisContext()
50: .getNullnessAnnotationDatabase()
51: : null);
52: }
53:
54: public void visitClassContext(ClassContext classContext) {
55:
56: JavaClass javaClass = classContext.getJavaClass();
57: if (!BCELUtil.preTiger(javaClass))
58: javaClass.accept(this );
59: }
60:
61: public void report() {
62: }
63: }
|