From 843e600bb17ad3581cc5769dc919664ec6fa0fd2 Mon Sep 17 00:00:00 2001 From: jrm Date: Tue, 23 Jun 2015 07:59:31 -0700 Subject: [PATCH] [infer][java] call inferlib programmatically instead of calling inferJ from the command line Summary: @public This should simplify the process of passing around command line arguments Test Plan: Infer CI. No functional change intended --- infer/bin/jwlib.py | 2 +- infer/lib/capture/javac.py | 19 ++++--------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/infer/bin/jwlib.py b/infer/bin/jwlib.py index 94727b866..0c5aa1549 100644 --- a/infer/bin/jwlib.py +++ b/infer/bin/jwlib.py @@ -16,7 +16,7 @@ current_directory = os.getcwd() parser.add_argument('-version', action='store_true') parser.add_argument('-cp', '-classpath', type=str, dest='classpath') parser.add_argument('-bootclasspath', type=str) -parser.add_argument('-d', dest='classes_out') +parser.add_argument('-d', dest='classes_out', default=current_directory) class CompilerCall: diff --git a/infer/lib/capture/javac.py b/infer/lib/capture/javac.py index 3a6d49acf..eb1df54a8 100644 --- a/infer/lib/capture/javac.py +++ b/infer/lib/capture/javac.py @@ -3,7 +3,8 @@ import subprocess import traceback import util -import utils # this is module located in ../utils.py +import inferlib + MODULE_NAME = __name__ MODULE_DESCRIPTION = '''Run analysis of code built with a command like: javac @@ -22,23 +23,11 @@ create_argparser = util.base_argparser(MODULE_DESCRIPTION, MODULE_NAME) class JavacCapture: def __init__(self, args, cmd): - self.args = args - self.cmd = cmd + self.analysis = inferlib.Infer(args, cmd[1:]) def capture(self): - # run inferJ only in capture mode - # pass all the frontend args (if any) - capture_cmd = [utils.get_cmd_in_bin_dir('inferJ')] - capture_cmd += ['--out', self.args.infer_out] - capture_cmd += ['--analyzer', self.args.analyzer] - if self.args.no_filtering: - capture_cmd.append('--no-filtering') - if self.args.debug: - capture_cmd.append('-g') - capture_cmd += self.cmd - try: - subprocess.check_call(capture_cmd) + self.analysis.start() return os.EX_OK except subprocess.CalledProcessError as exc: if self.args.debug: