changeset 14546:942c4daa9db9

added findbugs command to mx
author Doug Simon <doug.simon@oracle.com>
date Sat, 15 Mar 2014 01:42:27 +0100
parents 4877b0cb446f
children 0d5923064a88
files graal/findbugsExcludeFilter.xml mx/mx_graal.py mx/projects
diffstat 3 files changed, 74 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/findbugsExcludeFilter.xml	Sat Mar 15 01:42:27 2014 +0100
@@ -0,0 +1,41 @@
+<FindBugsFilter>
+
+  <Match>
+    <Class name="com.oracle.graal.hotspot.CompilationTask" />
+    <Method name="run" />
+    <Bug pattern="NN_NAKED_NOTIFY" />
+  </Match>
+
+  <!-- justification = "concurrent abstraction calls are in synchronized block" -->
+  <Match>
+    <Class name="com.oracle.graal.hotspot.debug.BenchmarkCounters" />
+    <Method name="getIndex" />
+    <Bug pattern="AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION" />
+  </Match>
+
+  <!-- justification = "counters are only used for statistics" -->
+  <Match>
+    <Class name="com.oracle.graal.hotspot.meta.HotSpotGraphCache" />
+    <Or>
+      <Method name="get" />
+      <Method name="put" />
+      <Method name="removeGraphs" />
+    </Or>
+    <Bug pattern="VO_VOLATILE_INCREMENT" />
+  </Match>
+
+  <!-- justification = "reference equality on the receiver is what we want" -->
+  <Match>
+    <Class name="com.oracle.graal.replacements.StringSubstitutions" />
+    <Method name="equals" />
+    <Bug pattern="ES_COMPARING_PARAMETER_STRING_WITH_EQ" />
+  </Match>
+
+  <!-- justification = "reference equality to test whether string is interned" -->
+  <Match>
+    <Class name="com.oracle.graal.hotspot.phases.AheadOfTimeVerificationPhase" />
+    <Method name="isInternedString" />
+    <Bug pattern="ES_COMPARING_STRINGS_WITH_EQ" />
+  </Match>
+
+</FindBugsFilter>
--- a/mx/mx_graal.py	Fri Mar 14 22:56:59 2014 +0100
+++ b/mx/mx_graal.py	Sat Mar 15 01:42:27 2014 +0100
@@ -1638,6 +1638,38 @@
     valueMap = parser.parse(output.getvalue())
     return valueMap
 
+def findbugs(args):
+    '''run FindBugs against non-test Java projects'''
+    findBugsHome = mx.get_env('FINDBUGS_HOME', None)
+    if findBugsHome:
+        findbugsJar = join(findBugsHome, 'lib', 'findbugs.jar')
+    else:
+        findbugsLib = join(_graal_home, 'lib', 'findbugs-3.0.0')
+        if not exists(findbugsLib):
+            tmp = tempfile.mkdtemp(prefix='findbugs-download-tmp', dir=_graal_home)
+            try:
+                findbugsDist = join(tmp, 'findbugs.zip')
+                mx.download(findbugsDist, ['http://sourceforge.net/projects/findbugs/files/findbugs/3.0.0/findbugs-3.0.0-dev-20131204-e3cbbd5.zip'])
+                with zipfile.ZipFile(findbugsDist) as zf:
+                    candidates = [e for e in zf.namelist() if e.endswith('/lib/findbugs.jar')]
+                    assert len(candidates) == 1, candidates
+                    libDirInZip = os.path.dirname(candidates[0])
+                    zf.extractall(tmp)
+                shutil.copytree(join(tmp, libDirInZip), findbugsLib)
+            finally:
+                shutil.rmtree(tmp)
+        findbugsJar = join(findbugsLib, 'findbugs.jar')
+    assert exists(findbugsJar)
+    nonTestProjects = [p for p in mx.projects() if not p.name.endswith('.test') and not p.name.endswith('.jtt')]
+    outputDirs = [p.output_dir() for p in nonTestProjects]
+    findbugsResults = join(_graal_home, 'findbugs.results')
+    exitcode = mx.run_java(['-jar', findbugsJar, '-textui', '-low', '-maxRank', '15', '-exclude', join(_graal_home, 'graal', 'findbugsExcludeFilter.xml'),
+                 '-auxclasspath', mx.classpath([p.name for p in nonTestProjects]), '-output', findbugsResults, '-progress', '-exitcode'] + args + outputDirs, nonZeroIsFatal=False)
+    if exitcode != 0:
+        with open(findbugsResults) as fp:
+            mx.log(fp.read())
+    os.unlink(findbugsResults)
+    return exitcode
 
 def mx_init(suite):
     commands = {
@@ -1646,6 +1678,7 @@
         'buildvms': [buildvms, '[-options]'],
         'c1visualizer' : [c1visualizer, ''],
         'clean': [clean, ''],
+        'findbugs': [findbugs, ''],
         'generateZshCompletion' : [generateZshCompletion, ''],
         'hsdis': [hsdis, '[att]'],
         'hcfdis': [hcfdis, ''],
--- a/mx/projects	Fri Mar 14 22:56:59 2014 +0100
+++ b/mx/projects	Sat Mar 15 01:42:27 2014 +0100
@@ -13,9 +13,6 @@
 library@CHECKSTYLE@path=lib/checkstyle-5.5-all.jar
 library@CHECKSTYLE@urls=jar:http://sourceforge.net/projects/checkstyle/files/checkstyle/5.5/checkstyle-5.5-bin.zip/download!/checkstyle-5.5/checkstyle-5.5-all.jar
 
-library@FINDBUGS@path=lib/findbugs-3.0.0-dev-20131204-e3cbbd5.jar
-library@FINDBUGS@urls=jar:http://sourceforge.net/projects/findbugs/files/findbugs/3.0.0/findbugs-3.0.0-dev-20131204-e3cbbd5.zip/download!/findbugs-3.0.0-dev-20131204-e3cbbd5/lib/findbugs.jar
-
 library@DACAPO@path=lib/dacapo-9.12-bach.jar
 library@DACAPO@urls=http://softlayer.dl.sourceforge.net/project/dacapobench/9.12-bach/dacapo-9.12-bach.jar