KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > ba > DebugRepositoryLookupFailureCallback


1 /*
2  * FindBugs - Find Bugs in Java programs
3  * Copyright (C) 2005, University of Maryland
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
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.ba;
21
22 import edu.umd.cs.findbugs.annotations.SuppressWarnings;
23 import edu.umd.cs.findbugs.classfile.ClassDescriptor;
24 import edu.umd.cs.findbugs.classfile.MethodDescriptor;
25
26 /**
27  * DebugRepositoryLookupFailureCallback implementation for debugging.
28  * (Test drivers, etc.) It just prints a message and exits.
29  *
30  * @author David Hovemeyer
31  */

32 public class DebugRepositoryLookupFailureCallback implements
33         RepositoryLookupFailureCallback {
34
35     /* (non-Javadoc)
36      * @see edu.umd.cs.findbugs.ba.RepositoryLookupFailureCallback#reportMissingClass(java.lang.ClassNotFoundException)
37      */

38     @SuppressWarnings JavaDoc("DM_EXIT")
39     public void reportMissingClass(ClassNotFoundException JavaDoc ex) {
40         System.out.println("Missing class");
41         ex.printStackTrace();
42         System.exit(1);
43     }
44     
45     /* (non-Javadoc)
46      * @see edu.umd.cs.findbugs.classfile.IErrorLogger#reportMissingClass(edu.umd.cs.findbugs.classfile.ClassDescriptor)
47      */

48     @SuppressWarnings JavaDoc("DM_EXIT")
49     public void reportMissingClass(ClassDescriptor classDescriptor) {
50         System.out.println("Missing class: " + classDescriptor);
51         System.exit(1);
52     }
53
54     /* (non-Javadoc)
55      * @see edu.umd.cs.findbugs.ba.RepositoryLookupFailureCallback#logError(java.lang.String)
56      */

57     @SuppressWarnings JavaDoc("DM_EXIT")
58     public void logError(String JavaDoc message) {
59         System.err.println("Error: " + message);
60         System.exit(1);
61     }
62
63     /* (non-Javadoc)
64      * @see edu.umd.cs.findbugs.ba.RepositoryLookupFailureCallback#logError(java.lang.String, java.lang.Throwable)
65      */

66     @SuppressWarnings JavaDoc("DM_EXIT")
67     public void logError(String JavaDoc message, Throwable JavaDoc e) {
68         if (e instanceof MissingClassException) {
69             MissingClassException missingClassEx = (MissingClassException) e;
70             ClassNotFoundException JavaDoc cnfe = missingClassEx.getClassNotFoundException();
71
72             reportMissingClass(cnfe);
73             // Don't report dataflow analysis exceptions due to missing classes.
74
// Too much noise.
75
return;
76
77         }
78         if (e instanceof MethodUnprofitableException) {
79             // TODO: log this
80
return;
81         }
82         System.err.println("Error: " + message);
83         e.printStackTrace();
84         System.exit(1);
85     }
86
87     /**
88      * Report that we skipped some analysis of a method
89      * @param method
90      */

91     public void reportSkippedAnalysis(MethodDescriptor method) {
92         System.err.println("Skipping " + method);
93     }
94 }
95
Popular Tags