Skip to content

Commit ba3f510

Browse files
committed
Updated bytecode analyzer
1 parent 5bbf976 commit ba3f510

File tree

1 file changed

+31
-26
lines changed

1 file changed

+31
-26
lines changed

bytecode-analyser/bytecode-analyzer.py

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
# N_PROCESSES as best suits
1414
# Finally, simply run the script
1515

16-
PROJECTS_BUILDS_DIR = os.path.abspath('/Users/nhoca/Trabalho/auto-builds-paper/bytecode-analysis/java-builds')
16+
PROJECTS_BUILDS_DIR = os.path.abspath('some-path/builds')
1717
# Need sources to grab local jar files
18-
PROJECTS_SOURCES_DIR = os.path.abspath('/Users/nhoca/Trabalho/auto-builds-paper/bytecode-analysis/java-projects')
19-
JARS_DIR = '/Users/nhoca/Trabalho/auto-builds-paper/bytecode-analysis/jars'
18+
PROJECTS_SOURCES_DIR = os.path.abspath('some-path/java-projects')
19+
JARS_DIR = 'some-path/jars'
2020
N_PROCESSES = 2
2121

2222
#### SHOULD not need to touch anything below ####
@@ -119,18 +119,23 @@ def handle_dependencies(proj_path, pid):
119119
proj_zip_path = None
120120
jar_paths = list()
121121

122+
print(proj_path)
123+
122124
with open(os.path.join(proj_path, 'build-result.json'), 'r') as file:
123125
json_file = json.load(file)
124-
for dep in json_file['depends']:
125-
if dep[5]:
126-
if proj_zip_path is None:
127-
proj_zip_path = os.path.join(PROJECTS_SOURCES_DIR, json_file['file'] + '.zip')
128-
# print(proj_zip_path)
129-
with ZipFile(proj_zip_path, 'r') as proj_zip:
130-
proj_zip.extract(member=dep[4], path=pid)
131-
jar_paths.append(os.path.join(pid, dep[4]))
132-
else:
133-
jar_paths.append(os.path.join(JARS_DIR, dep[4]))
126+
if 'depends' in json_file:
127+
for dep in json_file['depends']:
128+
if dep[5]:
129+
if proj_zip_path is None:
130+
proj_zip_path = os.path.join(PROJECTS_SOURCES_DIR, json_file['file'] + '.zip')
131+
# print(proj_zip_path)
132+
with ZipFile(proj_zip_path, 'r') as proj_zip:
133+
proj_zip.extract(member=dep[4], path=pid)
134+
jar_paths.append(os.path.join(pid, dep[4]))
135+
else:
136+
jar_paths.append(os.path.join(JARS_DIR, dep[4]))
137+
else:
138+
return ' '
134139

135140
# print(jar_paths)
136141
return ':'.join(jar_paths)
@@ -179,20 +184,20 @@ def process(list_projs):
179184
full_filename = os.path.join(root, filename)
180185
# print('Analyzing file', full_filename)
181186

182-
n_class_files += 1
183-
ci = unpack_classfile(full_filename)
184-
185-
# Search for main methods and run the respective class files
186-
main_methods = main_search_string in [m.get_name() for m in ci.methods]
187-
if main_methods:
188-
# print('Has main:', full_filename)
189-
reachable_mains += 1
190-
res = reachable_methods_from_main(root, filename, jar_paths, str(pid))
191-
# res = run_main(root, filename)
192-
reachable_methods += res
193-
194-
# Search for junit and run the respective class files
195187
try:
188+
n_class_files += 1
189+
ci = unpack_classfile(full_filename)
190+
191+
# Search for main methods and run the respective class files
192+
main_methods = main_search_string in [m.get_name() for m in ci.methods]
193+
if main_methods:
194+
# print('Has main:', full_filename)
195+
reachable_mains += 1
196+
res = 0 # reachable_methods_from_main(root, filename, jar_paths, str(pid))
197+
# res = run_main(root, filename)
198+
reachable_methods += res
199+
200+
# Search for junit and run the respective class files
196201
junit_imports = [m for m in ci.get_requires() if junit_search_string in m]
197202
if len(junit_imports) > 0:
198203
# print('Has junit:', full_filename)

0 commit comments

Comments
 (0)